3 ms·
For the truly lazy, this was my approach: map.overrideKey('up', function() { if (map.countObjects('boss') > 0) { for (var x = 0; x < ma
by ryanjshaw 13y ago
For the truly lazy, this was my approach:
map.overrideKey('up', function() {
if (map.countObjects('boss') > 0) {
for (var x = 0; x < map.getWidth(); x++) {
map.placeObject(x, map.getHeight()-5, 'missile');
}
} else {
map.overrideKey('up', null);
}
});
- antimagic 13y agoNice. Lacks drama though, where's the dash through the rain of bullets to recover the missile launcher? :D
- pygy_ 13y agoI monkey-patched Math.random() to launch horizontal missiles at the top of the screen and always return 1. :-)
- TheSoftwareGuy 13y agoInteresting, probably much simpler than my approach:(I have added a few comments to give a brief explanation: //Math.random = function(){ return false;}; /* my first Idea was to try and redefine Math.random to always return <0.3, but for some reason even though this did effect the dropping of bullets, it didn't stop them completely (if someone could explain this I would really appreciate it*/ map.defineObject('MagicBlock', { 'type' : 'static', 'symbol' : '$', 'color' : 'magenta', 'impassable' : function() { return map.countObjects('boss') >0;} }); //place a row of MagicBlock's aboove the player's starting position for(var i =0; i < map.getWidth(); i++) map.placeObject(i, map.getHeight()-5, 'MagicBlock'); map.defineObject('missile', { 'type' : 'dynamic', 'symbol' : '^', 'interval' : 100, 'projectile': true, 'behavior' : function(me) { me.move('up');}, 'color' : 'lime' }); player = map.getPlayer(); function volley(){ for(var i = 0; i < map.getWidth(); i++) map.placeObject(i, map.getHeight()-6, 'missile'); map.placeObject(i, map.getHeight()-7, 'missile'); } map.getPlayer().setPhoneCallback(function(){ volley(); });