Stage 2: render pipeline and UI toolkit over gpu/platform. Stage 3: schema registry, asset pipeline + runtime loader, scene graph and ECS. Stage 4: editor — docking, inspector, scene/game views, play mode, asset browser, console, profiler; 4.5 adds the 3D foundation (mixed 2D/3D spaces, meshes, depth). Stage 5: Aego Script — compiler (lexer/parser/types/resolver/checker/asm/compiler), bytecode with verifier and register VM, instance runtime, stdlib, native bindings, and editor/CLI integration (aego run/edit/check/test/dump).
61 lines
901 B
Plaintext
61 lines
901 B
Plaintext
package player
|
|
|
|
import (
|
|
"aego/input"
|
|
"aego/log"
|
|
"aego/math"
|
|
"mygame/combat"
|
|
)
|
|
|
|
enum State {
|
|
Idle
|
|
Run
|
|
}
|
|
|
|
type Stats struct {
|
|
Hp int
|
|
Armor float
|
|
}
|
|
|
|
const MaxSpeed float = 600
|
|
|
|
script PlayerController {
|
|
@export(min=0, max=600, unit="px/s")
|
|
var Speed float = 220
|
|
|
|
@export
|
|
var Target NodeRef
|
|
|
|
@export
|
|
var Sprite AssetRef<Texture>
|
|
|
|
var state State
|
|
var stats Stats
|
|
var hits []int
|
|
|
|
func Ready() {
|
|
stats = Stats{Hp: 10, Armor: 0.5}
|
|
log.Info("ready")
|
|
}
|
|
|
|
func Update(dt float) {
|
|
x := input.Axis("horizontal")
|
|
if x != 0 {
|
|
state = State.Run
|
|
} else {
|
|
state = State.Idle
|
|
}
|
|
t := node.Transform2D()
|
|
t.Position.X += math.Clamp(x*Speed, -MaxSpeed, MaxSpeed) * dt
|
|
node.SetTransform2D(t)
|
|
|
|
if node.Has<SpriteRenderer>() {
|
|
sr := node.Get<SpriteRenderer>()
|
|
sr.FlipX = x < 0
|
|
}
|
|
if Target != nil && input.Pressed(input.KeySpace) {
|
|
combat.Damage(Target, 5)
|
|
}
|
|
}
|
|
}
|