forked from AlexNisnevich/untrusted
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4be201
commit 109755f
Showing
11 changed files
with
49 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,22 @@ | ||
#BEGIN_PROPERTIES# | ||
{ | ||
"commandsIntroduced": | ||
["object.type", "object.behavior", "object.findNearest", | ||
"object.getX", "object.getY", "object.canMove", "object.move"] | ||
|
||
} | ||
#END_PROPERTIES# | ||
/* | ||
* ambush.js | ||
|
||
/******************** | ||
* crispsContest.js * | ||
******************** | ||
* | ||
* [This one's still in progress.] | ||
* Do you remember, dear Professor, a certain introductary class you taught long ago? | ||
* Perhaps some 'reeducation' is apropos. | ||
*/ | ||
|
||
function startLevel(map) { | ||
function moveToward(obj, type) { | ||
var target = obj.findNearest(type); | ||
var leftDist = obj.getX() - target.x; | ||
var upDist = obj.getY() - target.y; | ||
|
||
var direction; | ||
if (upDist > 0 && upDist >= leftDist) { | ||
direction = 'up'; | ||
} else if (upDist < 0 && upDist < leftDist) { | ||
direction = 'down'; | ||
} else if (leftDist > 0 && leftDist >= upDist) { | ||
direction = 'left'; | ||
} else { | ||
direction = 'right'; | ||
} | ||
|
||
if (obj.canMove(direction)) { | ||
obj.move(direction); | ||
} | ||
} | ||
|
||
map.placePlayer(2, 2); | ||
map.placePlayer(1, 1); | ||
map.placeObject(map.getWidth()-7, map.getHeight()-5, 'exit'); | ||
} | ||
|
||
map.defineObject('attackDrone', { | ||
'type': 'dynamic', | ||
'symbol': 'd', | ||
'color': 'red', | ||
'onCollision': function (player) { | ||
player.killedBy('an attack drone'); | ||
}, | ||
'behavior': function (me) { | ||
#BEGIN_EDITABLE# | ||
moveToward(me, 'player'); | ||
#END_EDITABLE# | ||
} | ||
}); | ||
|
||
map.defineObject('defenseDrone', { | ||
'type': 'dynamic', | ||
'symbol': 'd', | ||
'color': 'green', | ||
'onCollision': function (player) { | ||
player.killedBy('a defense drone'); | ||
}, | ||
'behavior': function (me) { | ||
#BEGIN_EDITABLE# | ||
|
||
#END_EDITABLE# | ||
} | ||
}); | ||
|
||
for (var x = 0; x <= 20; x++) { | ||
map.placeObject(x, 20 - x, 'attackDrone'); | ||
} | ||
|
||
for (var x = 30; x < 50; x++) { | ||
map.placeObject(x, 55 - x, 'defenseDrone'); | ||
} | ||
|
||
map.placeObject(map.getWidth()-2, map.getHeight()-2, 'exit'); | ||
} | ||
|
||
function validateLevel(map) { | ||
validateExactlyXManyObjects(map, 1, 'exit'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters