make_a_maze
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
make_a_maze [2019/08/17 11:12] – frchris | make_a_maze [2019/08/17 11:32] – frchris | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | Walls or obstacles are pared of the World class and can be placed in a NS or a EW direction, and have length. | + | Walls or obstacles are pared of the World class and can be placed in a NS or a EW direction, and have length. |
World.setSize(int numberOfStreets, | World.setSize(int numberOfStreets, | ||
====== 3 Ways to Make Walls ====== | ====== 3 Ways to Make Walls ====== | ||
- | - World.placeNSWall(), | + | - World.placeNSWall(), |
+ | public class Walls implements Directions { | ||
+ | public static void task() { | ||
+ | Robot karel = new Robot(1, 2, East, 0); | ||
+ | karel.move(); | ||
+ | karel.move(); | ||
+ | karel.pickBeeper(); | ||
+ | karel.move(); | ||
+ | karel.turnLeft(); | ||
+ | karel.move(); | ||
+ | karel.move(); | ||
+ | karel.putBeeper(); | ||
+ | karel.move(); | ||
+ | karel.turnOff(); | ||
+ | |||
+ | } | ||
+ | // Main entry point | ||
+ | public static void main(String[] args) { | ||
+ | World.setDelay(150); | ||
+ | World.setSize(8, | ||
+ | // | ||
+ | World.placeBeepers(1, | ||
+ | World.placeEWWall(3, | ||
+ | World.placeNSWall(1, | ||
+ | World.placeEWWall(6, | ||
+ | World.setVisible(); | ||
+ | task(); | ||
+ | } | ||
+ | }</ | ||
+ | - You can make a long string and send it all at once to the World. | ||
+ | String hurdles = " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | World.getWorld(hurdles); | ||
+ | World.setVisible(); | ||
+ | task(); | ||
+ | }</ | ||
+ | - You can place a text file with these string commands, give the file a name, and add it to your project and use the call <code java> World.readWorld(" |
make_a_maze.txt · Last modified: 2021/09/05 13:16 by frchris