Add Switches, Fire/Water Collision and Play Menu
* New doodads: Switches. * They come in four varieties: wall switch (background element, with "ON/OFF" text) and three side-profile switches for the floor, left or right walls. * On collision with the player, they flip their state from "OFF" to "ON" or vice versa. If the player walks away and then collides again, the switch flips again. * Can be used to open/close Electric Doors when turned on/off. Their default state is "off" * If a switch receives a power signal from another linked switch, it sets its own state to match. So, two "on/off" switches that are connected to a door AND to each other will both flip on/off when one of them flips. * Update the Level Collision logic to support Decoration, Fire and Water pixel collisions. * Previously, ALL pixels in the level were acting as though solid. * Non-solid pixels don't count for collision detection, but their attributes (fire and water) are collected and returned. * Updated the MenuScene to support loading a map file in Play Mode instead of Edit Mode. Updated the title screen menu to add a button for playing levels instead of editing them. * Wrote some documentation.
|
@ -24,6 +24,23 @@ buttons() {
|
||||||
cd ..
|
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
|
||||||
|
|
||||||
|
cp *.doodad ../../../assets/doodads/
|
||||||
|
cd ..
|
||||||
|
}
|
||||||
|
|
||||||
doors() {
|
doors() {
|
||||||
cd doors/
|
cd doors/
|
||||||
|
|
||||||
|
@ -104,6 +121,7 @@ objects() {
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons
|
buttons
|
||||||
|
switches
|
||||||
doors
|
doors
|
||||||
trapdoors
|
trapdoors
|
||||||
azulians
|
azulians
|
||||||
|
|
|
@ -23,8 +23,8 @@ function main() {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
animating = true;
|
animating = true;
|
||||||
|
opened = false;
|
||||||
Self.PlayAnimation("close", function() {
|
Self.PlayAnimation("close", function() {
|
||||||
opened = false;
|
|
||||||
animating = false;
|
animating = false;
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
BIN
dev-assets/doodads/switches/down-off.png
Normal file
After Width: | Height: | Size: 678 B |
BIN
dev-assets/doodads/switches/down-on.png
Normal file
After Width: | Height: | Size: 674 B |
BIN
dev-assets/doodads/switches/left-off.png
Normal file
After Width: | Height: | Size: 702 B |
BIN
dev-assets/doodads/switches/left-on.png
Normal file
After Width: | Height: | Size: 696 B |
BIN
dev-assets/doodads/switches/right-off.png
Normal file
After Width: | Height: | Size: 695 B |
BIN
dev-assets/doodads/switches/right-on.png
Normal file
After Width: | Height: | Size: 702 B |
BIN
dev-assets/doodads/switches/switch-off.png
Normal file
After Width: | Height: | Size: 687 B |
BIN
dev-assets/doodads/switches/switch-on.png
Normal file
After Width: | Height: | Size: 699 B |
38
dev-assets/doodads/switches/switch.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
function main() {
|
||||||
|
console.log("%s initialized!", Self.Doodad.Title);
|
||||||
|
|
||||||
|
// Switch has two frames:
|
||||||
|
// 0: Off
|
||||||
|
// 1: On
|
||||||
|
|
||||||
|
var state = false;
|
||||||
|
var collide = false;
|
||||||
|
|
||||||
|
Message.Subscribe("power", function(powered) {
|
||||||
|
state = powered;
|
||||||
|
showState(state);
|
||||||
|
});
|
||||||
|
|
||||||
|
Events.OnCollide(function(e) {
|
||||||
|
if (collide === false) {
|
||||||
|
state = !state;
|
||||||
|
Message.Publish("power", state);
|
||||||
|
showState(state);
|
||||||
|
|
||||||
|
collide = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Events.OnLeave(function(e) {
|
||||||
|
collide = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// showState shows the on/off frame based on the boolean powered state.
|
||||||
|
function showState(state) {
|
||||||
|
if (state) {
|
||||||
|
Self.ShowLayer(1);
|
||||||
|
} else {
|
||||||
|
Self.ShowLayer(0);
|
||||||
|
}
|
||||||
|
}
|