diff --git a/dev-assets/doodads/azulian/Makefile b/dev-assets/doodads/azulian/Makefile new file mode 100644 index 0000000..20e7aa5 --- /dev/null +++ b/dev-assets/doodads/azulian/Makefile @@ -0,0 +1,18 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Blue Azulian" blu-front.png blu-back.png \ + blu-wr{1,2,3,4}.png blu-wl{1,2,3,4}.png azu-blu.doodad + doodad install-script azulian.js azu-blu.doodad + + doodad convert -t "Red Azulian" red-front.png red-back.png \ + red-wr{1,2,3,4}.png red-wl{1,2,3,4}.png azu-red.doodad + doodad install-script azulian-red.js azu-red.doodad + + # Tag the category for these doodads + for i in *.doodad; do\ + doodad edit-doodad --tag "category=creatures" $${i};\ + done + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/bird/Makefile b/dev-assets/doodads/bird/Makefile new file mode 100644 index 0000000..e70fedc --- /dev/null +++ b/dev-assets/doodads/bird/Makefile @@ -0,0 +1,14 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Bird (red)" left-1.png left-2.png right-1.png right-2.png \ + dive-left.png dive-right.png bird-red.doodad + doodad install-script bird.js bird-red.doodad + + # Tag the category for these doodads + for i in *.doodad; do\ + doodad edit-doodad --tag "category=creatures" $${i};\ + done + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/box/Makefile b/dev-assets/doodads/box/Makefile new file mode 100644 index 0000000..ddbb2a1 --- /dev/null +++ b/dev-assets/doodads/box/Makefile @@ -0,0 +1,13 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Box" box-1.png box-2.png \ + box-3.png box-4.png box.doodad + doodad install-script box.js box.doodad + + for i in *.doodad; do \ + doodad edit-doodad --tag "category=objects" $${i}; \ + done + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/box/box.js b/dev-assets/doodads/box/box.js index b68d0bc..1c97439 100644 --- a/dev-assets/doodads/box/box.js +++ b/dev-assets/doodads/box/box.js @@ -38,6 +38,16 @@ function main() { Self.SetVelocity(Vector(0, 0)); }); + // When we receive power, we reset to our original position. + var origPoint = Self.Position(); + Message.Subscribe("power", function (powered) { + console.error("Box received power! %+v", powered); + console.error("MoveTo: %+v", origPoint); + console.error("Keys: %+v", Object.keys(Self)); + Self.MoveTo(origPoint); + Self.SetVelocity(Vector(0, 0)); + }); + // Start animation on a loop. animate(); } diff --git a/dev-assets/doodads/boy/Makefile b/dev-assets/doodads/boy/Makefile new file mode 100644 index 0000000..39d98a8 --- /dev/null +++ b/dev-assets/doodads/boy/Makefile @@ -0,0 +1,13 @@ +ALL: build + +.PHONY: build +build: + 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 + + doodad edit-doodad --tag "category=creatures" boy.doodad + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/build.sh b/dev-assets/doodads/build.sh index 4e20064..f434a94 100755 --- a/dev-assets/doodads/build.sh +++ b/dev-assets/doodads/build.sh @@ -10,191 +10,65 @@ 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/ + make cd .. } buttons() { cd buttons/ - - doodad convert -t "Sticky Button" sticky1.png sticky2.png button-sticky.doodad - doodad install-script sticky.js button-sticky.doodad - - doodad convert -t "Button" button1.png button2.png button.doodad - doodad install-script button.js button.doodad - - doodad convert -t "Button Type B" typeB1.png typeB2.png button-typeB.doodad - doodad install-script button.js button-typeB.doodad - - # Tag the category for these doodads - for i in *.doodad; do doodad edit-doodad --tag "category=gizmos" $i; done - - cp button*.doodad ../../../assets/doodads/ + make cd .. } switches() { cd switches/ - - doodad convert -t "Switch" switch-off.png switch-on.png switch.doodad - doodad convert -t "Floor Switch" down-off.png down-on.png switch-down.doodad - doodad convert -t "Left Switch" left-off.png left-on.png switch-left.doodad - doodad convert -t "Right Switch" right-off.png right-on.png switch-right.doodad - - doodad install-script switch.js switch.doodad - doodad install-script switch.js switch-down.doodad - doodad install-script switch.js switch-left.doodad - doodad install-script switch.js switch-right.doodad - - # Tag the category for these doodads - for i in *.doodad; do doodad edit-doodad --tag "category=gizmos" $i; done - - cp *.doodad ../../../assets/doodads/ + make cd .. } doors() { cd doors/ - ./build.sh + make cd .. } trapdoors() { cd trapdoors/ - - doodad convert -t "Trapdoor" down{1,2,3,4}.png trapdoor-down.doodad - doodad convert -t "Trapdoor Left" left{1,2,3,4}.png trapdoor-left.doodad - doodad convert -t "Trapdoor Right" right{1,2,3,4}.png trapdoor-right.doodad - doodad convert -t "Trapdoor Up" up{1,2,3,4}.png trapdoor-up.doodad - doodad install-script trapdoor.js trapdoor-down.doodad - doodad install-script trapdoor.js trapdoor-left.doodad - doodad install-script trapdoor.js trapdoor-right.doodad - doodad install-script trapdoor.js trapdoor-up.doodad - - doodad edit-doodad -q --tag direction=down trapdoor-down.doodad - doodad edit-doodad -q --tag direction=left trapdoor-left.doodad - doodad edit-doodad -q --tag direction=right trapdoor-right.doodad - doodad edit-doodad -q --tag direction=up trapdoor-up.doodad - - # Tag the category for these doodads - for i in *.doodad; do doodad edit-doodad --tag "category=doors" $i; done - - cp trapdoor-*.doodad ../../../assets/doodads/ - + make cd .. } azulians() { cd azulian/ - - doodad convert -t "Blue Azulian" blu-front.png blu-back.png \ - blu-wr{1,2,3,4}.png blu-wl{1,2,3,4}.png azu-blu.doodad - doodad install-script azulian.js azu-blu.doodad - - doodad convert -t "Red Azulian" red-front.png red-back.png \ - red-wr{1,2,3,4}.png red-wl{1,2,3,4}.png azu-red.doodad - doodad install-script azulian-red.js azu-red.doodad - - # Tag the category for these doodads - for i in *.doodad; do doodad edit-doodad --tag "category=creatures" $i; done - - cp azu-*.doodad ../../../assets/doodads/ - + make cd .. } mobs() { cd bird/ - - doodad convert -t "Bird (red)" left-1.png left-2.png right-1.png right-2.png \ - dive-left.png dive-right.png bird-red.doodad - doodad install-script bird.js bird-red.doodad - - # Tag the category for these doodads - for i in *.doodad; do doodad edit-doodad --tag "category=creatures" $i; done - - cp *.doodad ../../../assets/doodads/ + make cd .. } objects() { cd objects/ + make + cd .. - doodad convert -t "Exit Flag" exit-flag.png exit-flag.doodad - doodad install-script exit-flag.js exit-flag.doodad - - doodad convert -t "Start Flag" start-flag.png start-flag.doodad - - for i in *.doodad; do doodad edit-doodad --tag "category=objects" $i; done - cp *.doodad ../../../assets/doodads/ - - cd ../crumbly-floor - - doodad convert -t "Crumbly Floor" floor.png shake1.png shake2.png \ - fall1.png fall2.png fall3.png fall4.png fallen.png \ - crumbly-floor.doodad - doodad install-script crumbly-floor.js crumbly-floor.doodad - for i in *.doodad; do doodad edit-doodad --tag "category=objects" $i; done - cp *.doodad ../../../assets/doodads/ - - cd ../box - - doodad convert -t "Box" box-1.png box-2.png box-3.png box-4.png box.doodad - doodad install-script box.js box.doodad - for i in *.doodad; do doodad edit-doodad --tag "category=objects" $i; done - cp *.doodad ../../../assets/doodads/ - + cd box/ + make cd .. } onoff() { cd on-off/ - - doodad convert -t "State Button" blue-button.png orange-button.png state-button.doodad - doodad install-script state-button.js state-button.doodad - - doodad convert -t "State Block (Blue)" blue-on.png blue-off.png state-block-blue.doodad - doodad install-script state-block-blue.js state-block-blue.doodad - - doodad convert -t "State Block (Orange)" orange-off.png orange-on.png state-block-orange.doodad - doodad install-script state-block-orange.js state-block-orange.doodad - - for i in *.doodad; do doodad edit-doodad --tag "category=gizmos" $i; done - - cp *.doodad ../../../assets/doodads/ - + make cd .. } warpdoor() { cd warp-door/ - - doodad convert -t "Warp Door" door-1.png door-2.png door-3.png door-4.png warp-door.doodad - doodad edit-doodad -q --tag color=none warp-door.doodad - doodad install-script warp-door.js warp-door.doodad - - doodad convert -t "Warp Door (Blue)" blue-1.png blue-2.png blue-3.png blue-4.png blue-off.png \ - warp-door-blue.doodad - doodad edit-doodad -q --tag color=blue warp-door-blue.doodad - doodad install-script warp-door.js warp-door-blue.doodad - - doodad convert -t "Warp Door (Orange)" orange-off.png orange-1.png orange-2.png orange-3.png orange-4.png \ - warp-door-orange.doodad - doodad edit-doodad -q --tag color=orange warp-door-orange.doodad - doodad install-script warp-door.js warp-door-orange.doodad - - for i in *.doodad; do doodad edit-doodad --tag "category=doors" $i; done - for i in warp-door-*.doodad; do doodad edit-doodad --tag "category=doors,gizmos" $i; done - - cp *.doodad ../../../assets/doodads/ - + make cd .. } diff --git a/dev-assets/doodads/buttons/Makefile b/dev-assets/doodads/buttons/Makefile new file mode 100644 index 0000000..bd82563 --- /dev/null +++ b/dev-assets/doodads/buttons/Makefile @@ -0,0 +1,19 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Sticky Button" sticky1.png sticky2.png button-sticky.doodad + doodad install-script sticky.js button-sticky.doodad + + doodad convert -t "Button" button1.png button2.png button.doodad + doodad install-script button.js button.doodad + + doodad convert -t "Button Type B" typeB1.png typeB2.png button-typeB.doodad + doodad install-script button.js button-typeB.doodad + + # Tag the category for these doodads + for i in *.doodad; do\ + doodad edit-doodad --tag "category=gizmos" $${i};\ + done + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/crumbly-floor/Makefile b/dev-assets/doodads/crumbly-floor/Makefile new file mode 100644 index 0000000..7fe4048 --- /dev/null +++ b/dev-assets/doodads/crumbly-floor/Makefile @@ -0,0 +1,12 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Crumbly Floor" floor.png shake1.png shake2.png \ + fall1.png fall2.png fall3.png fall4.png fallen.png \ + crumbly-floor.doodad + doodad install-script crumbly-floor.js crumbly-floor.doodad + for i in *.doodad; do\ + doodad edit-doodad --tag "category=objects" $${i};\ + done + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/doors/Makefile b/dev-assets/doodads/doors/Makefile new file mode 100644 index 0000000..2c685ea --- /dev/null +++ b/dev-assets/doodads/doors/Makefile @@ -0,0 +1,5 @@ +ALL: build + +.PHONY: build +build: + ./build.sh \ No newline at end of file diff --git a/dev-assets/doodads/doors/build.sh b/dev-assets/doodads/doors/build.sh index 5f327d3..7615a8d 100755 --- a/dev-assets/doodads/doors/build.sh +++ b/dev-assets/doodads/doors/build.sh @@ -49,4 +49,4 @@ doodad install-script electric-door.js door-electric.doodad for i in *.doodad; do doodad edit-doodad --tag "category=doors" $i; done doodad edit-doodad --tag "category=doors,gizmos" door-electric.doodad -cp door-*.doodad key-*.doodad small-*.doodad ../../../assets/doodads/ +cp *.doodad ../../../assets/doodads/ diff --git a/dev-assets/doodads/objects/Makefile b/dev-assets/doodads/objects/Makefile new file mode 100644 index 0000000..0573bc1 --- /dev/null +++ b/dev-assets/doodads/objects/Makefile @@ -0,0 +1,13 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Exit Flag" exit-flag.png exit-flag.doodad + doodad install-script exit-flag.js exit-flag.doodad + + doodad convert -t "Start Flag" start-flag.png start-flag.doodad + + for i in *.doodad; do\ + doodad edit-doodad --tag "category=objects" $${i};\ + done + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/on-off/Makefile b/dev-assets/doodads/on-off/Makefile new file mode 100644 index 0000000..32eae08 --- /dev/null +++ b/dev-assets/doodads/on-off/Makefile @@ -0,0 +1,18 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "State Button" blue-button.png orange-button.png state-button.doodad + doodad install-script state-button.js state-button.doodad + + doodad convert -t "State Block (Blue)" blue-on.png blue-off.png state-block-blue.doodad + doodad install-script state-block-blue.js state-block-blue.doodad + + doodad convert -t "State Block (Orange)" orange-off.png orange-on.png state-block-orange.doodad + doodad install-script state-block-orange.js state-block-orange.doodad + + for i in *.doodad; do\ + doodad edit-doodad --tag "category=gizmos" $${i};\ + done + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/switches/Makefile b/dev-assets/doodads/switches/Makefile new file mode 100644 index 0000000..b603c1f --- /dev/null +++ b/dev-assets/doodads/switches/Makefile @@ -0,0 +1,20 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Switch" switch-off.png switch-on.png switch.doodad + doodad convert -t "Floor Switch" down-off.png down-on.png switch-down.doodad + doodad convert -t "Left Switch" left-off.png left-on.png switch-left.doodad + doodad convert -t "Right Switch" right-off.png right-on.png switch-right.doodad + + doodad install-script switch.js switch.doodad + doodad install-script switch.js switch-down.doodad + doodad install-script switch.js switch-left.doodad + doodad install-script switch.js switch-right.doodad + + # Tag the category for these doodads + for i in *.doodad; do\ + doodad edit-doodad --tag "category=gizmos" $${i};\ + done + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/trapdoors/Makefile b/dev-assets/doodads/trapdoors/Makefile new file mode 100644 index 0000000..48a72b8 --- /dev/null +++ b/dev-assets/doodads/trapdoors/Makefile @@ -0,0 +1,32 @@ +ALL: build + +.PHONY: build +build: + # Build the four basic trapdoors. + doodad convert -t "Trapdoor" down{1,2,3,4}.png trapdoor-down.doodad + doodad convert -t "Trapdoor Left" left{1,2,3,4}.png trapdoor-left.doodad + doodad convert -t "Trapdoor Right" right{1,2,3,4}.png trapdoor-right.doodad + doodad convert -t "Trapdoor Up" up{1,2,3,4}.png trapdoor-up.doodad + doodad install-script trapdoor.js trapdoor-down.doodad + doodad install-script trapdoor.js trapdoor-left.doodad + doodad install-script trapdoor.js trapdoor-right.doodad + doodad install-script trapdoor.js trapdoor-up.doodad + + doodad edit-doodad -q --tag direction=down trapdoor-down.doodad + doodad edit-doodad -q --tag direction=left trapdoor-left.doodad + doodad edit-doodad -q --tag direction=right trapdoor-right.doodad + doodad edit-doodad -q --tag direction=up trapdoor-up.doodad + + # Tag the category for these doodads + ls -hal *.doodad + for i in *.doodad; do\ + echo $${i};\ + doodad edit-doodad -q --tag "category=doors" $${i};\ + done + + # Build the Electric Trapdoor. + doodad convert -t "Electric Trapdoor" electric{1,2,3,4}.png electric-trapdoor.doodad + doodad install-script electric-trapdoor.js electric-trapdoor.doodad + doodad edit-doodad -q --tag "category=doors,gizmos" electric-trapdoor.doodad + + cp *.doodad ../../../assets/doodads/ \ No newline at end of file diff --git a/dev-assets/doodads/trapdoors/electric-trapdoor.js b/dev-assets/doodads/trapdoors/electric-trapdoor.js new file mode 100644 index 0000000..2a33057 --- /dev/null +++ b/dev-assets/doodads/trapdoors/electric-trapdoor.js @@ -0,0 +1,60 @@ +// Electric Trapdoor + +var animationSpeed = 100, + spriteWidth = 114, + thickness = 7, + isOpen = false, + animating = false, + powerState = false; + +function main() { + Self.SetHitbox(0, 2, spriteWidth, thickness); + + Self.AddAnimation("open", animationSpeed, [0, 1, 2, 3]); + Self.AddAnimation("close", animationSpeed, [3, 2, 1, 0]); + + // Subscribe to Switches and other power sources. Note: if a + // switch toggles us, we ignore the immediately following + // power signal which will be coming from the same switch. + // The electric trapdoor always toggles when hit by a switch. + var ignoreNextPower = false; + Message.Subscribe("switch:toggle", function (powered) { + ignoreNextPower = true + setPoweredState(!powerState); + }); + Message.Subscribe("power", function (powered) { + if (ignoreNextPower) { + ignoreNextPower = false; + return; + } + setPoweredState(powered); + }); + + Events.OnCollide(function (e) { + if (e.InHitbox && !isOpen) { + return false; + } + }) +} + +function setPoweredState(powered) { + powerState = powered; + + if (powered) { + if (animating || isOpen) { + return; + } + + animating = true; + Self.PlayAnimation("open", function () { + isOpen = true; + animating = false; + }); + } else { + animating = true; + Self.PlayAnimation("close", function () { + isOpen = false; + animating = false; + }); + } +} diff --git a/dev-assets/doodads/trapdoors/electric1.png b/dev-assets/doodads/trapdoors/electric1.png new file mode 100644 index 0000000..bc9138f Binary files /dev/null and b/dev-assets/doodads/trapdoors/electric1.png differ diff --git a/dev-assets/doodads/trapdoors/electric2.png b/dev-assets/doodads/trapdoors/electric2.png new file mode 100644 index 0000000..139d9c8 Binary files /dev/null and b/dev-assets/doodads/trapdoors/electric2.png differ diff --git a/dev-assets/doodads/trapdoors/electric3.png b/dev-assets/doodads/trapdoors/electric3.png new file mode 100644 index 0000000..6b33049 Binary files /dev/null and b/dev-assets/doodads/trapdoors/electric3.png differ diff --git a/dev-assets/doodads/trapdoors/electric4.png b/dev-assets/doodads/trapdoors/electric4.png new file mode 100644 index 0000000..97b9bac Binary files /dev/null and b/dev-assets/doodads/trapdoors/electric4.png differ diff --git a/dev-assets/doodads/warp-door/Makefile b/dev-assets/doodads/warp-door/Makefile new file mode 100644 index 0000000..a4842e1 --- /dev/null +++ b/dev-assets/doodads/warp-door/Makefile @@ -0,0 +1,26 @@ +ALL: build + +.PHONY: build +build: + doodad convert -t "Warp Door" door-1.png door-2.png door-3.png door-4.png warp-door.doodad + doodad edit-doodad -q --tag color=none warp-door.doodad + doodad install-script warp-door.js warp-door.doodad + + doodad convert -t "Warp Door (Blue)" blue-1.png blue-2.png blue-3.png blue-4.png blue-off.png \ + warp-door-blue.doodad + doodad edit-doodad -q --tag color=blue warp-door-blue.doodad + doodad install-script warp-door.js warp-door-blue.doodad + + doodad convert -t "Warp Door (Orange)" orange-off.png orange-1.png orange-2.png orange-3.png orange-4.png \ + warp-door-orange.doodad + doodad edit-doodad -q --tag color=orange warp-door-orange.doodad + doodad install-script warp-door.js warp-door-orange.doodad + + for i in *.doodad; do\ + doodad edit-doodad --tag "category=doors" $${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