Advertisement
pastetumlum

bear

Jul 16th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. public class Bear {
  2. //toa do cua gau
  3.     private int tileX, tileY;
  4.  
  5.     public Bear() {
  6. //khoi tao toa do
  7.         tileX = 1;
  8.         tileY = 1;
  9.  
  10.     }
  11.  
  12.     public void move(Direction direction) {
  13.         int tx = 0;
  14.         int ty = 0;
  15.         switch (direction) {
  16.         case UP:
  17.             tx = 0;
  18.             ty = -1;
  19.             break;
  20.         case DOWN:
  21.             tx = 0;
  22.             ty = 1;
  23.             break;
  24.         case LEFT:
  25.             tx = -1;
  26.             ty = 0;
  27.             break;
  28.         case RIGHT:
  29.             tx = 1;
  30.             ty = 0;
  31.             break;
  32.         }
  33. //thay doi toa do dua vao huong di chuyen
  34.         tileX += tx;
  35.         tileY += ty;
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement