Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Bear {
- //toa do cua gau
- private int tileX, tileY;
- public Bear() {
- //khoi tao toa do
- tileX = 1;
- tileY = 1;
- }
- public void move(Direction direction) {
- int tx = 0;
- int ty = 0;
- switch (direction) {
- case UP:
- tx = 0;
- ty = -1;
- break;
- case DOWN:
- tx = 0;
- ty = 1;
- break;
- case LEFT:
- tx = -1;
- ty = 0;
- break;
- case RIGHT:
- tx = 1;
- ty = 0;
- break;
- }
- //thay doi toa do dua vao huong di chuyen
- tileX += tx;
- tileY += ty;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement