Browse Source

Add Anvil

master
Noah Petherbridge 3 years ago
parent
commit
781248606a
  1. 4
      README.md
  2. 5
      anvil/Makefile
  3. 7
      anvil/README.md
  4. 51
      anvil/anvil.js
  5. BIN
      anvil/anvil.png
  6. 5
      anvil/build.sh

4
README.md

@ -4,7 +4,7 @@ This repository includes some example doodads for Sketchy Maze.
You can learn from their scripts or use them as a base for your
own custom doodads.
![Warp Door](warp-door/door-1.png) ![Character](character/stand-right.png)
![Warp Door](warp-door/door-1.png) ![Character](character/stand-right.png) ![Anvil](anvil/anvil.png)
All of these doodads are built from PNG images using the
`doodad` program that comes with the game. Check your guidebook
@ -18,6 +18,8 @@ example for the doodad commands used.
built-in creatures.
* [**Warp Door**](warp-door/): create your own compatible Warp
Door that you can link to the built-in doors.
* [**Anvil**](anvil/): the harmless doodad that becomes dangerous
while falling.
To do:

5
anvil/Makefile

@ -0,0 +1,5 @@
ALL: build
.PHONY: build
build:
./build.sh

7
anvil/README.md

@ -0,0 +1,7 @@
# Example Anvil
![Example Anvil](anvil.png)
This is basically the **Anvil** from the game. It has no solid
collision, it is affected by gravity, and it is dangerous when
falling.

51
anvil/anvil.js

@ -0,0 +1,51 @@
// Anvil
var falling = false;
function main() {
// Note: doodad is not "solid" but hurts if it falls on you.
Self.SetHitbox(0, 0, 48, 25);
Self.SetMobile(true);
Self.SetGravity(true);
// Monitor our Y position to tell if we've been falling.
var lastPoint = Self.Position();
setInterval(function () {
var nowAt = Self.Position();
if (nowAt.Y > lastPoint.Y) {
falling = true;
} else {
falling = false;
}
lastPoint = nowAt;
}, 100);
Events.OnCollide(function (e) {
if (!e.Settled) {
return;
}
// Were we falling?
if (falling) {
if (e.InHitbox) {
if (e.Actor.IsPlayer()) {
// Fatal to the player.
Sound.Play("crumbly-break.wav");
FailLevel("Watch out for anvils!");
return;
}
else if (e.Actor.IsMobile()) {
// Destroy mobile doodads.
Sound.Play("crumbly-break.wav");
e.Actor.Destroy();
}
}
}
});
// When we receive power, we reset to our original position.
var origPoint = Self.Position();
Message.Subscribe("power", function (powered) {
Self.MoveTo(origPoint);
Self.SetVelocity(Vector(0, 0));
});
}

BIN
anvil/anvil.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

5
anvil/build.sh

@ -0,0 +1,5 @@
#!/bin/bash
doodad convert -t "Example Anvil" anvil.png example-anvil.doodad
doodad edit-doodad --tag "category=objects" example-anvil.doodad
doodad install-script anvil.js example-anvil.doodad
Loading…
Cancel
Save