2019-04-19 01:15:05 +00:00
|
|
|
function main() {
|
|
|
|
console.log("%s initialized!", Self.Doodad.Title);
|
|
|
|
|
2019-05-07 05:57:32 +00:00
|
|
|
Self.AddAnimation("open", 100, [0, 1, 2, 3]);
|
|
|
|
Self.AddAnimation("close", 100, [3, 2, 1, 0]);
|
2019-05-05 23:32:30 +00:00
|
|
|
var animating = false;
|
2019-05-07 05:57:32 +00:00
|
|
|
var opened = false;
|
2019-04-19 01:15:05 +00:00
|
|
|
|
2019-06-24 00:30:12 +00:00
|
|
|
Self.SetHitbox(16, 0, 32, 64);
|
|
|
|
|
|
|
|
Message.Subscribe("power", function(powered) {
|
|
|
|
console.log("%s got power=%+v", Self.Doodad.Title, powered);
|
|
|
|
|
|
|
|
if (powered) {
|
|
|
|
if (animating || opened) {
|
|
|
|
return;
|
|
|
|
}
|
2019-04-19 01:15:05 +00:00
|
|
|
|
2019-05-07 05:57:32 +00:00
|
|
|
animating = true;
|
|
|
|
Self.PlayAnimation("open", function() {
|
|
|
|
opened = true;
|
|
|
|
animating = false;
|
|
|
|
});
|
2019-06-24 00:30:12 +00:00
|
|
|
} else {
|
|
|
|
animating = true;
|
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.
2019-07-07 01:30:03 +00:00
|
|
|
opened = false;
|
2019-05-07 05:57:32 +00:00
|
|
|
Self.PlayAnimation("close", function() {
|
2019-06-24 00:30:12 +00:00
|
|
|
animating = false;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Events.OnCollide(function(e) {
|
|
|
|
if (e.InHitbox) {
|
|
|
|
if (!opened) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-07 05:57:32 +00:00
|
|
|
}
|
2019-06-24 00:30:12 +00:00
|
|
|
});
|
|
|
|
Events.OnLeave(function() {
|
|
|
|
// if (opened) {
|
|
|
|
// Self.PlayAnimation("close", function() {
|
|
|
|
// opened = false;
|
|
|
|
// });
|
|
|
|
// }
|
2019-05-07 05:57:32 +00:00
|
|
|
})
|
2019-04-19 01:15:05 +00:00
|
|
|
}
|