ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 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 / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
209 lines
4.5 KiB
Plaintext
209 lines
4.5 KiB
Plaintext
package player
|
|
|
|
import (
|
|
"aego/anim"
|
|
"aego/audio"
|
|
"aego/camera"
|
|
"aego/input"
|
|
"aego/log"
|
|
"aego/math"
|
|
"aego/save"
|
|
"aego/settings"
|
|
"mygame/enemy"
|
|
)
|
|
|
|
script PlayerController {
|
|
@export
|
|
var EnemyA NodeRef
|
|
|
|
@export
|
|
var EnemyB NodeRef
|
|
|
|
@export(min=0)
|
|
var LandShake float = 9
|
|
|
|
@export(gizmo="vector")
|
|
var Bounce Vec2 = Vec2{0, -9}
|
|
|
|
@export
|
|
var JumpSound AssetRef<AudioEvent>
|
|
|
|
@export
|
|
var HitSound AssetRef<AudioEvent>
|
|
|
|
@export
|
|
var Theme AssetRef<Clip>
|
|
|
|
@export(tip="Hitbox that the Hit frame of the attack clip pulses")
|
|
var Slash NodeRef
|
|
|
|
@export(tip="Landing dust emitter")
|
|
var Dust NodeRef
|
|
|
|
@export(tip="Sparks for the sword swing")
|
|
var Sparks NodeRef
|
|
|
|
@export(min=0)
|
|
var Reach float = 0.6
|
|
|
|
@persist
|
|
var kills int
|
|
var facing float = 1
|
|
var hit int
|
|
var motionPhase float
|
|
var stompBouncing bool
|
|
|
|
func Ready() {
|
|
watch(EnemyA)
|
|
watch(EnemyB)
|
|
m := node.Get<Motion2D>()
|
|
m.Jumped.Connect(OnJumped)
|
|
m.Landed.Connect(OnLanded)
|
|
m.Climbed.Connect(OnClimbed)
|
|
node.Get<Hitbox2D>().Hit.Connect(OnStomp)
|
|
node.Get<Health>().Damaged.Connect(OnDamaged)
|
|
hit = anim.EventID("Hit")
|
|
if Slash != nil && Slash.IsAlive() {
|
|
Slash.SetPosition(Vec2{facing * Reach, 0})
|
|
}
|
|
audio.Music(Theme, 1.5)
|
|
}
|
|
|
|
func watch(n NodeRef) {
|
|
if n != nil && n.IsAlive() {
|
|
n.GetScript<enemy.EnemyAI>().Died.Connect(OnEnemyDied)
|
|
}
|
|
}
|
|
|
|
func OnEnemyDied() {
|
|
kills++
|
|
save.SetGlobalInt("kills", save.GlobalInt("kills", 0) + 1)
|
|
}
|
|
|
|
func OnStomp(target NodeRef, damage int) {
|
|
m := node.Get<Motion2D>()
|
|
if target == nil || !target.IsAlive() || damage <= 0 || stompBouncing || m.Velocity.Y <= 0 {
|
|
return
|
|
}
|
|
playerPos := node.WorldPosition()
|
|
targetPos := target.WorldPosition()
|
|
// The player's feet must be above the enemy, with the player centered over its body.
|
|
if playerPos.Y > targetPos.Y - 0.8 || math.Abs(playerPos.X - targetPos.X) > 0.45 {
|
|
return
|
|
}
|
|
stompBouncing = true
|
|
m.AddVelocity(Vec2{0, Bounce.Y - m.Velocity.Y})
|
|
}
|
|
|
|
func OnJumped() {
|
|
audio.PlayEvent(JumpSound)
|
|
if Dust != nil && Dust.IsAlive() {
|
|
Dust.Get<ParticleSystem2D>().Burst(5)
|
|
}
|
|
}
|
|
|
|
func OnClimbed() {
|
|
if Dust != nil && Dust.IsAlive() {
|
|
Dust.Get<ParticleSystem2D>().Burst(6)
|
|
}
|
|
}
|
|
|
|
func OnLanded(speed float) {
|
|
if Dust != nil && Dust.IsAlive() {
|
|
Dust.Get<ParticleSystem2D>().Burst(8)
|
|
}
|
|
if speed > LandShake {
|
|
camera.Shake(0.35)
|
|
}
|
|
}
|
|
|
|
func OnDamaged(amount int, source NodeRef) {
|
|
audio.PlayEvent(HitSound)
|
|
node.Get<Animator>().SetTrigger("Hurt")
|
|
}
|
|
|
|
func OnAnimEvent(id int, payload float) {
|
|
if id == hit && Slash != nil {
|
|
Slash.SetPosition(Vec2{facing * Reach, 0})
|
|
Slash.Get<Hitbox2D>().Pulse()
|
|
camera.Shake(0.08)
|
|
if Sparks != nil && Sparks.IsAlive() {
|
|
Sparks.Get<ParticleSystem2D>().Burst(8)
|
|
}
|
|
}
|
|
}
|
|
|
|
func FixedUpdate(dt float) {
|
|
m := node.Get<Motion2D>()
|
|
if m.Velocity.Y < 0 {
|
|
stompBouncing = false
|
|
}
|
|
x := input.Axis("Move")
|
|
m.Move(x)
|
|
if input.Pressed("Jump") {
|
|
m.Jump()
|
|
}
|
|
if input.Released("Jump") {
|
|
m.JumpReleased()
|
|
}
|
|
if x != 0 {
|
|
facing = math.Sign(x)
|
|
node.Get<SpriteRenderer>().FlipX = x < 0
|
|
if Slash != nil {
|
|
Slash.SetPosition(Vec2{facing * Reach, 0})
|
|
Slash.Get<SpriteRenderer>().FlipX = x < 0
|
|
}
|
|
}
|
|
node.Get<Hitbox2D>().Active = !m.Grounded && m.Velocity.Y > 0
|
|
a := node.Get<Animator>()
|
|
if a.State != "Hurt" {
|
|
node.Get<MaterialOverride>().Reset("Flash")
|
|
}
|
|
a.SetFloat("Speed", math.Abs(m.Velocity.X))
|
|
a.SetBool("Grounded", m.Grounded)
|
|
a.SetFloat("VerticalSpeed", m.Velocity.Y)
|
|
a.SetBool("Climbing", m.Climbing)
|
|
if input.Pressed("Attack") {
|
|
a.SetTrigger("Attack")
|
|
}
|
|
if Slash != nil && a.State != "Hit" {
|
|
Slash.Get<SpriteRenderer>().Tint = Color{1, 1, 1, 0}
|
|
}
|
|
}
|
|
|
|
func Update(dt float) {
|
|
motionPhase += dt
|
|
m := node.Get<Motion2D>()
|
|
if node.Get<Animator>().State != "Hit" && node.Get<Animator>().State != "Climb" && !m.Climbing {
|
|
if !m.Grounded {
|
|
if m.Velocity.Y < 0 {
|
|
node.Get<SpriteRenderer>().Size = Vec2{0.92, 1.1}
|
|
} else {
|
|
node.Get<SpriteRenderer>().Size = Vec2{1.08, 0.94}
|
|
}
|
|
} else {
|
|
pulse := math.Sin(motionPhase * 4) * 0.025
|
|
if math.Abs(m.Velocity.X) > 0.2 {
|
|
pulse = math.Sin(motionPhase * 20) * 0.045
|
|
}
|
|
node.Get<SpriteRenderer>().Size = Vec2{1 - pulse, 1 + pulse}
|
|
}
|
|
}
|
|
if input.Pressed("QuickSave") {
|
|
save.Save("quick")
|
|
}
|
|
if input.Pressed("QuickLoad") && save.Exists("quick") {
|
|
save.Load("quick")
|
|
}
|
|
if input.Pressed("Pause") {
|
|
settings.OpenView()
|
|
}
|
|
}
|
|
|
|
func OnSettingChanged(id string) {
|
|
if id == "audio.bus.music.volume" {
|
|
log.Info("music volume " + string(settings.GetFloat(id)))
|
|
}
|
|
}
|
|
}
|