diff --git a/dev-assets/doodads/boy/boy.js b/dev-assets/doodads/boy/boy.js new file mode 100644 index 0000000..9d17f5c --- /dev/null +++ b/dev-assets/doodads/boy/boy.js @@ -0,0 +1,37 @@ +function main() { + var playerSpeed = 12; + var gravity = 4; + var Vx = Vy = 0; + + var animating = false; + var animStart = animEnd = 0; + var animFrame = animStart; + + Self.SetMobile(true); + Self.SetGravity(true); + Self.SetHitbox(0, 0, 29, 52); + Self.AddAnimation("walk-left", 200, ["stand-left", "walk-left-1", "walk-left-2", "walk-left-3", "walk-left-2", "walk-left-1"]); + Self.AddAnimation("walk-right", 200, ["stand-right", "walk-right-1", "walk-right-2", "walk-right-3", "walk-right-2", "walk-right-1"]); + + Events.OnKeypress(function(ev) { + Vx = 0; + Vy = 0; + + if (ev.Right) { + if (!Self.IsAnimating()) { + Self.PlayAnimation("walk-right", null); + } + Vx = playerSpeed; + } else if (ev.Left) { + if (!Self.IsAnimating()) { + Self.PlayAnimation("walk-left", null); + } + Vx = -playerSpeed; + } else { + Self.StopAnimation(); + animating = false; + } + + // Self.SetVelocity(Point(Vx, Vy)); + }) +} diff --git a/dev-assets/doodads/boy/stand-left.png b/dev-assets/doodads/boy/stand-left.png new file mode 100644 index 0000000..3ce4be7 Binary files /dev/null and b/dev-assets/doodads/boy/stand-left.png differ diff --git a/dev-assets/doodads/boy/stand-right.png b/dev-assets/doodads/boy/stand-right.png new file mode 100644 index 0000000..66a85d1 Binary files /dev/null and b/dev-assets/doodads/boy/stand-right.png differ diff --git a/dev-assets/doodads/boy/walk-left-1.png b/dev-assets/doodads/boy/walk-left-1.png new file mode 100644 index 0000000..733624d Binary files /dev/null and b/dev-assets/doodads/boy/walk-left-1.png differ diff --git a/dev-assets/doodads/boy/walk-left-2.png b/dev-assets/doodads/boy/walk-left-2.png new file mode 100644 index 0000000..1256cc6 Binary files /dev/null and b/dev-assets/doodads/boy/walk-left-2.png differ diff --git a/dev-assets/doodads/boy/walk-left-3.png b/dev-assets/doodads/boy/walk-left-3.png new file mode 100644 index 0000000..39128c4 Binary files /dev/null and b/dev-assets/doodads/boy/walk-left-3.png differ diff --git a/dev-assets/doodads/boy/walk-right-1.png b/dev-assets/doodads/boy/walk-right-1.png new file mode 100644 index 0000000..c422cfa Binary files /dev/null and b/dev-assets/doodads/boy/walk-right-1.png differ diff --git a/dev-assets/doodads/boy/walk-right-2.png b/dev-assets/doodads/boy/walk-right-2.png new file mode 100644 index 0000000..2aac09e Binary files /dev/null and b/dev-assets/doodads/boy/walk-right-2.png differ diff --git a/dev-assets/doodads/boy/walk-right-3.png b/dev-assets/doodads/boy/walk-right-3.png new file mode 100644 index 0000000..0bd2b72 Binary files /dev/null and b/dev-assets/doodads/boy/walk-right-3.png differ diff --git a/dev-assets/doodads/boy/walk-right.gif b/dev-assets/doodads/boy/walk-right.gif new file mode 100644 index 0000000..e6e2d30 Binary files /dev/null and b/dev-assets/doodads/boy/walk-right.gif differ diff --git a/dev-assets/doodads/build.sh b/dev-assets/doodads/build.sh index f7afb2b..784a47c 100755 --- a/dev-assets/doodads/build.sh +++ b/dev-assets/doodads/build.sh @@ -8,6 +8,19 @@ fi mkdir -p ../../assets/doodads +boy() { + cd boy/ + + doodad convert -t "Boy" stand-right.png stand-left.png \ + walk-right-1.png walk-right-2.png walk-right-3.png \ + walk-left-1.png walk-left-2.png walk-left-3.png \ + boy.doodad + doodad install-script boy.js boy.doodad + + cp *.doodad ../../../assets/doodads/ + cd .. +} + buttons() { cd buttons/ @@ -123,6 +136,7 @@ onoff() { cd .. } +boy buttons switches doors @@ -132,3 +146,4 @@ objects onoff doodad edit-doodad -quiet -lock -author "Noah" ../../assets/doodads/*.doodad doodad edit-doodad -hide ../../assets/doodads/azu-blu.doodad +doodad edit-doodad -hide ../../assets/doodads/boy.doodad diff --git a/pkg/balance/numbers.go b/pkg/balance/numbers.go index 0d23bd4..d2221b7 100644 --- a/pkg/balance/numbers.go +++ b/pkg/balance/numbers.go @@ -43,6 +43,12 @@ var ( } DefaultEraserBrushSize = 8 MaxEraserBrushSize = 32 // the bigger, the slower + + // Default player character doodad in Play Mode. + PlayerCharacterDoodad = "boy.doodad" + + // Level name for the title screen. + DemoLevelName = "example 1.level" ) // Edit Mode Values diff --git a/pkg/main_scene.go b/pkg/main_scene.go index 71b780c..0310a74 100644 --- a/pkg/main_scene.go +++ b/pkg/main_scene.go @@ -171,7 +171,7 @@ func (s *MainScene) SetupDemoLevel(d *Doodle) error { s.canvas.SetScriptSupervisor(s.scripting) // Title screen level to load. - if lvl, err := level.LoadFile("example1.level"); err == nil { + if lvl, err := level.LoadFile(balance.DemoLevelName); err == nil { s.canvas.LoadLevel(d.Engine, lvl) s.canvas.InstallActors(lvl.Actors) diff --git a/pkg/play_scene.go b/pkg/play_scene.go index d3928e1..1c4a5bc 100644 --- a/pkg/play_scene.go +++ b/pkg/play_scene.go @@ -193,7 +193,7 @@ func (s *PlayScene) Setup(d *Doodle) error { // setupPlayer creates and configures the Player Character in the level. func (s *PlayScene) setupPlayer() { // Load in the player character. - player, err := doodads.LoadFile("azu-blu.doodad") + player, err := doodads.LoadFile(balance.PlayerCharacterDoodad) if err != nil { log.Error("PlayScene.Setup: failed to load player doodad: %s", err) player = doodads.NewDummy(32)