From 1f0075b0f2b823244f151069125833a571dfce70 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 5 May 2019 14:03:20 -0700 Subject: [PATCH] WIP: MsgPack stubs, Level Filesystem Module * Add some encoding/decoding functions for binary msgpack format for levels and doodads. Currently it writes msgpack files that can be decoded and printed by Python (mp2json.py) but it can't re-read from the binary format. For now, levels will continue to write in JSON format. * Add filesystem abstraction functions to the balance/ package to search multiple paths to find Levels and Doodads, to make way for system-level doodads. --- dev-assets/doodads/azulian/azulian.js | 50 ++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/dev-assets/doodads/azulian/azulian.js b/dev-assets/doodads/azulian/azulian.js index e208d10..25ff361 100644 --- a/dev-assets/doodads/azulian/azulian.js +++ b/dev-assets/doodads/azulian/azulian.js @@ -1,4 +1,52 @@ function main() { log.Info("Azulian '%s' initialized!", Self.Doodad.Title); - Self.ShowLayer(2); + + var playerSpeed = 12; + var gravity = 4; + var Vx = Vy = 0; + + var animating = false; + var animStart = animEnd = 0; + var animFrame = animStart; + + setInterval(function() { + if (animating) { + if (animFrame < animStart || animFrame > animEnd) { + animFrame = animStart; + } + + animFrame++; + if (animFrame === animEnd) { + animFrame = animStart; + } + Self.ShowLayer(animFrame); + } else { + Self.ShowLayer(animStart); + } + }, 100); + + Events.OnKeypress(function(ev) { + Vx = 0; + Vy = 0; + + if (ev.Right.Now) { + animStart = 2; + animEnd = animStart+4; + animating = true; + Vx = playerSpeed; + } else if (ev.Left.Now) { + animStart = 6; + animEnd = animStart+4; + animating = true; + Vx = -playerSpeed; + } else { + animating = false; + } + + if (!Self.Grounded()) { + Vy += gravity; + } + + // Self.SetVelocity(Point(Vx, Vy)); + }) }