Blockly GamesPuzzleMazeBirdTurtleMovieMusicPond TutorPondGeneticsYou solved this level with 1 line of JavaScript:You solved this level with %1 lines of JavaScript:Are you ready for level %1?Are you ready for the next challenge?Title:Save and link to blocks.Run the program you wrote.Run ProgramStop the program and reset the level.ResetHelpOKCancelLogicLoopsMathTextListsColourVariablesFunctionsThere was a problem with the request.Share your blocks with this link:\n\n%1Sorry, '%1' doesn't correspond with any saved program.Could not load your saved file. Perhaps it was created with a different version of Blockly?Thank you for this program! If our staff of trained monkeys like it, they will publish it to the gallery within a couple of days.listtextOnce you start editing JavaScript, you can't go back to editing blocks. Is this OK?Blocks
Scan for enemies. Specify a direction (0-360). Returns the distance to the closest enemy in that direction. Returns Infinity if no enemy found.Fire the cannon. Specify a direction (0-360) and a range (0-70).Swim forward. Specify a direction (0-360).Stop swimming. Player will slow to a stop.Returns the player's current health (0 is dead, 100 is healthy).Returns the current speed of the player (0 is stopped, 100 is full speed).Returns the X coordinate of the player (0 is the left edge, 100 is the right edge).Returns the Y coordinate of the player (0 is the bottom edge, 100 is the top edge).
/* Slowly moves east and west. Does not fire. */
var west = false;
while (true) {
if (west) {
if (getX() > 25) {
swim(180, 25);
} else {
west = false;
swim(0, 0);
}
} else {
if (getX() < 75) {
swim(0, 25);
} else {
west = true;
swim(0, 0);
}
}
}
/* Moves south-west when hit. Does not fire. */
var d = damage();
while (true) {
if (d != damage()) {
swim(45, 100);
var t = 0;
for (var t = 0; t < 100; t++) {}
d = damage();
stop();
}
}
Congratulations!
Use the 'cannon' command to hit the target. The first parameter is the angle, the second parameter is the range. Find the right combination.