ci-platforms / darwin arm64 smoke (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 12m19s
ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / windows amd64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / checks (push) Failing after 23m57s
ci / release (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: failure
GitHub / darwin arm64 native GitHub-hosted native CI: failure
GitHub / darwin amd64 native GitHub-hosted native CI: failure
GitHub / linux amd64 native GitHub-hosted native CI: success
61 lines
1.3 KiB
Plaintext
61 lines
1.3 KiB
Plaintext
package demo
|
|
|
|
import (
|
|
"aego/debug"
|
|
"aego/input"
|
|
)
|
|
|
|
// Runner walks with A/D on the built-in platformer controller; Space jumps (Grounded is false in the air), J triggers Hit.
|
|
script Runner {
|
|
var vy float
|
|
var floor float
|
|
var air bool
|
|
|
|
func Update(dt float) {
|
|
a := node.Get<Animator>()
|
|
dir := 0.0
|
|
if input.Down(input.KeyA) || input.Down(input.KeyLeft) {
|
|
dir -= 1
|
|
}
|
|
if input.Down(input.KeyD) || input.Down(input.KeyRight) {
|
|
dir += 1
|
|
}
|
|
speed := dir
|
|
if speed < 0 {
|
|
speed = -speed
|
|
node.Get<SpriteRenderer>().FlipX = true
|
|
} else if speed > 0 {
|
|
node.Get<SpriteRenderer>().FlipX = false
|
|
}
|
|
a.SetFloat("Speed", speed * 3)
|
|
p := node.Position()
|
|
if !air {
|
|
floor = p.Y
|
|
if input.KeyPressed(input.KeySpace) {
|
|
air = true
|
|
vy = -7
|
|
a.SetBool("Grounded", false)
|
|
}
|
|
}
|
|
if air {
|
|
vy += 20 * dt
|
|
p.Y += vy * dt
|
|
if p.Y >= floor {
|
|
p.Y = floor
|
|
air = false
|
|
a.SetBool("Grounded", true)
|
|
}
|
|
}
|
|
if input.KeyPressed(input.KeyJ) {
|
|
a.SetTrigger("Attack")
|
|
}
|
|
node.SetPosition(Vec2{p.X + dir * 3 * dt, p.Y})
|
|
label := a.State
|
|
if a.Blending {
|
|
label = label + " (blending)"
|
|
}
|
|
debug.Text(Vec2{p.X - 2, p.Y - 1.4}, label + " " + string(a.Progress), Color{0.85, 0.85, 0.85, 1})
|
|
debug.Text(Vec2{-4.5, 2}, "A/D walk Space jump J hit", Color{0.6, 0.6, 0.6, 1})
|
|
}
|
|
}
|