Last active
November 19, 2015 09:20
-
-
Save e-tverdokhleb/c35d1be5d6e1275344e4 to your computer and use it in GitHub Desktop.
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
void runTheGame() throws Exception { | |
move(2); | |
move(2); | |
move(2); | |
move(1); | |
move(4); | |
move(4); | |
move(3); | |
} | |
void move(int direction) throws InterruptedException { | |
System.out.println("ready to move..."); | |
if (direction == 1) { | |
if ((tankY - desk_step) < 0) { | |
System.out.println("there is no way to move!"); | |
} else { | |
tankY -= desk_step; | |
System.out.println("move 1 step UP"); | |
} | |
repaint(); | |
} | |
if (direction == 2) { | |
if ((tankY + desk_step) > BF_HEIGHT) { | |
System.out.println("there is no way to move!"); | |
} else { | |
tankY += desk_step; | |
System.out.println("move 1 step DOWN"); | |
} | |
repaint(); | |
} | |
if (direction == 3) { | |
if ((tankX - desk_step) < 0) { | |
System.out.println("there is no way to move!"); | |
} else { | |
tankX -= desk_step; | |
System.out.println("move 1 step LEFT"); | |
} | |
repaint(); | |
} | |
if (direction == 4) { | |
if ((tankX + desk_step) > BF_WIDTH) { | |
System.out.println("there is no way to move!"); | |
} else { | |
tankX += desk_step; | |
System.out.println("move 1 step RIGHT"); | |
} | |
repaint(); | |
} | |
Thread.sleep(tank_speed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Та же ситуация.