Files
DesktopGoose2/DesktopDuck/Goose.swift
T
2026-10-14 08:58:26 +01:00

59 lines
1.3 KiB
Swift

//
// Goose.swift
// DesktopDuck
//
// Created by neon443 on 06/10/2026.
//
import Foundation
import Cocoa
class Goose: NSViewController {
var state: GooseState
var gooseView: NSView
init() {
self.state = .idle
self.gooseView = NSView(frame: .zero)
super.init(nibName: nil, bundle: nil)
self.view.frame = NSScreen.main!.frame
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup() {
gooseView.frame = NSRect(x: 100, y: 100, width: 25, height: 25)
self.view.addSubview(gooseView)
let bodyView = NSImageView(image: NSImage(named: "body")!)
gooseView.addSubview(bodyView)
bodyView.translatesAutoresizingMaskIntoConstraints = false
bodyView.rotate(byDegrees: 50)
NSLayoutConstraint.activate([
bodyView.widthAnchor.constraint(equalToConstant: 50),
bodyView.heightAnchor.constraint(equalToConstant: 50)
])
let neckView = NSImageView(image: NSImage(named: "body")!)
gooseView.addSubview(neckView)
neckView.translatesAutoresizingMaskIntoConstraints = false
neckView.rotate(byDegrees: 90)
NSLayoutConstraint.activate([
neckView.widthAnchor.constraint(equalToConstant: 25),
neckView.heightAnchor.constraint(equalToConstant: 25)
])
}
}
enum GooseState {
case idle
case wander
case draggingMessage
case draggingMouse
case running
case aggro
}