Skip to content

Instantly share code, notes, and snippets.

@e-tverdokhleb
Last active November 19, 2015 09:20
Show Gist options
  • Save e-tverdokhleb/c35d1be5d6e1275344e4 to your computer and use it in GitHub Desktop.
Save e-tverdokhleb/c35d1be5d6e1275344e4 to your computer and use it in GitHub Desktop.
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);
}
@liuiv15
Copy link

liuiv15 commented Nov 19, 2015

Та же ситуация.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment