-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.java
More file actions
49 lines (48 loc) · 1.19 KB
/
Camera.java
File metadata and controls
49 lines (48 loc) · 1.19 KB
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
package JavaRacer;
public class Camera {
int worldX, worldY;
int screenMidX, screenMidY;
KeyHandler keyHandle;
GameWindow gameWindow;
int speed = 10;
public Camera(GameWindow gw, KeyHandler kh, int worldX, int worldY){
this.gameWindow = gw;
this.keyHandle = kh;
this.worldX = worldX;
this.worldY = worldY;
this.screenMidX = gw.WIDTH/2;
this.screenMidY = gw.HEIGHT/2;
}
public void update(){
if (keyHandle.aPressed){
this.worldX -=speed;
}
else if(keyHandle.dPressed){
this.worldX += speed;
}
else if(keyHandle.wPressed){
this.worldY -=speed;
}
else if(keyHandle.sPressed){
this.worldY += speed;
}
}
public int getWorldX(){
return this.worldX;
}
public void setWorldX(int worldX){
this.worldX = worldX;
}
public int getWorldY(){
return this.worldY;
}
public void setWorldY(int worldY){
this.worldY = worldY;
}
public int getScreenMidX(){
return this.screenMidX;
}
public int getScreenMidY(){
return this.screenMidY;
}
}