-
Notifications
You must be signed in to change notification settings - Fork 3
/
Position.java
64 lines (56 loc) · 1.21 KB
/
Position.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.danilchican.pacman;
/**
* Info about position
*
* @author Vlad Danilchik
*
*/
public class Position {
private int column = 1;
private int row = 1;
private int x;
private int y;
/**
* Set info about new position
*
* @param column
* @param row
* @see Position#Position(int, int)
*/
Position(int column, int row) {
this.column = column;
this.row = row;
this.y = Constants.MARGIN_TOP + this.row * Constants.BlockWidth;
this.x = Constants.MARGIN_LEFT_RIGHT + this.column * Constants.BlockHeight;
}
/**
* Set position of player
*
* @param player of the game
* @see Position#setPosition(Character)
*/
public void setPosition(Character player) {
player.setTranslateX(x);
player.setTranslateY(y);
}
/**
* Set position of enemy
*
* @param enemy of the game
* @see Position#setPosition(Enemy)
*/
public void setPosition(Enemy enemy) {
enemy.setTranslateX(x + 1);
enemy.setTranslateY(y + 1);
}
/**
* Set position of boot
*
* @param boot of the game
* @see Position#setPosition(Boot)
*/
public void setPosition(Boot boot) {
boot.setTranslateX(x + 1);
boot.setTranslateY(y + 1);
}
}