From ca9ad6e3a81281796e71b572964067faf3854cc5 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sun, 2 Jan 2022 22:36:32 -0800 Subject: [PATCH] Spit and polish * New doodad: Invisible Warp Door * All warp doors require the player to be grounded (if affected by gravity) to open them. No jumping or falling thru and opening a warp door mid-air! * Title Screen now randomly selects from a couple of levels. * Title Screen: if it fails to load a level it sets up a basic blank level with a wallpaper instead. * New developer shell command: titlescreen Opens the MainScene with a custom user level as the background. * Add Auto-save to the Editor to save your drawing every 5 minutes * Add a MenuBar to the Play Scene for easier navigation to other features of the game. * Doodad JS API: time.Since() now available. --- dev-assets/doodads/regions/Makefile | 7 ++- dev-assets/doodads/regions/warp-door-64.png | Bin 0 -> 821 bytes dev-assets/doodads/warp-door/Makefile | 4 +- dev-assets/doodads/warp-door/warp-door.js | 45 +++++++++++++++++++- 4 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 dev-assets/doodads/regions/warp-door-64.png diff --git a/dev-assets/doodads/regions/Makefile b/dev-assets/doodads/regions/Makefile index 7d8c6b2..6ea450f 100644 --- a/dev-assets/doodads/regions/Makefile +++ b/dev-assets/doodads/regions/Makefile @@ -23,7 +23,12 @@ build: doodad convert -t "Power Source" power-64.png power-source.doodad doodad install-script power.js power-source.doodad + # Warp Door + doodad convert -t "Invisible Warp Door" warp-door-64.png reg-warp-door.doodad + doodad edit-doodad --tag "color=invisible" reg-warp-door.doodad + doodad install-script ../warp-door/warp-door.js reg-warp-door.doodad + for i in *.doodad; do\ doodad edit-doodad --tag "category=technical" $${i};\ done - cp *.doodad ../../../assets/doodads/ \ No newline at end of file + cp *.doodad ../../../assets/doodads/ diff --git a/dev-assets/doodads/regions/warp-door-64.png b/dev-assets/doodads/regions/warp-door-64.png new file mode 100644 index 0000000000000000000000000000000000000000..f2b31d43b9e052d0dc7ed90a7a068015bd500e37 GIT binary patch literal 821 zcmV-51Iqk~P)EX>4Tx04R}tkv&MmP!xqvQ$>-AgGEFHGgLvaAS&XhRVYG*P%E_RVDi#GXws0R zxHt-~1qXi?s}3&Cx;nTDg5VE`qmz@OiTyrGnJet4ik&{7FJrA6-y{D4^000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2j&3-0umG4(lG)600A*cL_t(|+U=WB4uc>JhQW9j z@8dytA5Y_+%m~5NVvu6LFWJL{ZS=R4w%g*mggsR7*+SIJ*M3gx_dl3|bKDCMQ`gbD z-KeBCvjq?U0emw{fg%r#rR!&b^z3Xt=1AkO@qo`3;_)aME{(GVdJC{FVVCa8s5!)R z*PvXOC*8Mc5NuVblwMnk36G`1H5HZ=>GNQA^|{#?kVfb`UeP1UH$4UNJ802BbI0I_ zA^`vZycBgREamc=aSIKRzisg=xqEs|J1)&{Wps60JYTq!3XhN~(-HD6z-(a=J-?na z;Q_rm!sfPs`L_7osBfVKRwY2%7S9(i_4l;>zo)%`-v^Kf00000fKOc30;IwS@MHF9 zH03Z`009sH0T2KI5C8!XAgcy7@aJi^z&rQ?$wSF;A2tV&00000NkvXXu0mjfuGeS^ literal 0 HcmV?d00001 diff --git a/dev-assets/doodads/warp-door/Makefile b/dev-assets/doodads/warp-door/Makefile index a4842e1..90d80b2 100644 --- a/dev-assets/doodads/warp-door/Makefile +++ b/dev-assets/doodads/warp-door/Makefile @@ -17,10 +17,10 @@ build: doodad install-script warp-door.js warp-door-orange.doodad for i in *.doodad; do\ - doodad edit-doodad --tag "category=doors" $${i};\ + doodad edit-doodad --tag "category=doors" --hitbox=34,76 $${i};\ done for i in warp-door-*.doodad; do\ doodad edit-doodad --tag "category=doors,gizmos" $${i};\ done - cp *.doodad ../../../assets/doodads/ \ No newline at end of file + cp *.doodad ../../../assets/doodads/ diff --git a/dev-assets/doodads/warp-door/warp-door.js b/dev-assets/doodads/warp-door/warp-door.js index 0cb6e1a..10b587f 100644 --- a/dev-assets/doodads/warp-door/warp-door.js +++ b/dev-assets/doodads/warp-door/warp-door.js @@ -1,7 +1,5 @@ // Warp Doors function main() { - Self.SetHitbox(0, 0, 34, 76); - // Are we a blue or orange door? Regular warp door will be 'none' var color = Self.GetTag("color"); var isStateDoor = color === 'blue' || color === 'orange'; @@ -23,6 +21,11 @@ function main() { Self.AddAnimation("close", animSpeed, ["orange-4", "orange-3", "orange-2", "orange-1"]); spriteDefault = "orange-1"; spriteDisabled = "orange-off"; + } else if (color === 'invisible') { + // Invisible Warp Door region. + Self.Hide(); + Self.AddAnimation("open", animSpeed, [0, 0]); + Self.AddAnimation("close", animSpeed, [0, 0]); } else { Self.AddAnimation("open", animSpeed, ["door-2", "door-3", "door-4"]); Self.AddAnimation("close", animSpeed, ["door-4", "door-3", "door-2", "door-1"]); @@ -48,6 +51,10 @@ function main() { }); } + // For player groundedness work-around + var playerLastY = []; // last sampling of Y values + var lastUsed = time.Now(); + // The player Uses the door. var flashedCooldown = false; // "Locked Door" flashed message. Events.OnUse(function(e) { @@ -74,6 +81,40 @@ function main() { return; } + // The player must be grounded or have no gravity to open the door. + if (!e.Actor.Grounded() && e.Actor.HasGravity()) { + // Work-around: if two Boxes are stacked atop each other the player can + // get stuck if he jumps on top. He may not be Grounded but isn't changing + // effective Y position and a warp door may work as a good way out. + var yValue = e.Actor.Position().Y; + + // Collect a sampling of last few Y values. If the player Y position + // is constant the last handful of frames, treat them as if they're + // grounded (or else they can't activate the warp door). + playerLastY.unshift(yValue); + if (playerLastY.length < 6) { + return; + } + + // We have enough history. + playerLastY.pop(); + + // Hasn't moved? + var isGrounded = true; + for (var i = 0; i < playerLastY.length; i++) { + if (yValue !== playerLastY[i]) { + isGrounded = false; + break; + } + } + + if (!isGrounded) { + return; + } + + // Player was effectively grounded! No change in Y position. + } + // Freeze the player. e.Actor.Freeze()