@@ -18,7 +18,7 @@ public class Play extends BasicGameState{
18
18
19
19
// shift map not the player
20
20
float shiftX = buckyPositionX +320 ;
21
- float shiftY = buckyPositionY +320 ;
21
+ float shiftY = buckyPositionY +160 ;
22
22
23
23
24
24
//constructor
@@ -29,10 +29,10 @@ public Play(int state){
29
29
public void init (GameContainer gc , StateBasedGame sbg ) throws SlickException {
30
30
worldMap = new Image ("res/world.png" );
31
31
//image array for animation
32
- Image [] walkUp = {new Image ("res/buckysBack.png" ),new Image ("res/bucksBack .png" ) };
33
- Image [] walkDown = {new Image ("res/buckysFront.png" ),new Image ("res/bucksFront .png" ) };
34
- Image [] walkLeft = {new Image ("res/buckysLeft.png" ),new Image ("res/bucksLeft .png" ) };
35
- Image [] walkRight = {new Image ("res/buckysRight.png" ),new Image ("res/bucksRight .png" ) };
32
+ Image [] walkUp = {new Image ("res/buckysBack.png" ),new Image ("res/buckysBack .png" ) };
33
+ Image [] walkDown = {new Image ("res/buckysFront.png" ),new Image ("res/buckysFront .png" ) };
34
+ Image [] walkLeft = {new Image ("res/buckysLeft.png" ),new Image ("res/buckysLeft .png" ) };
35
+ Image [] walkRight = {new Image ("res/buckysRight.png" ),new Image ("res/buckysRight .png" ) };
36
36
37
37
//Animation what images we want to use how long each image will last autoupdating
38
38
movingUp = new Animation (walkUp ,duration ,false );
@@ -62,6 +62,44 @@ public void render(GameContainer gc, StateBasedGame sbg,Graphics g) throws Slick
62
62
63
63
//updates the images on screen
64
64
public void update (GameContainer gc , StateBasedGame sbg ,int delta ) throws SlickException {
65
+
66
+ Input input = gc .getInput ();
67
+ //UP
68
+ if (input .isKeyDown (Input .KEY_UP )){
69
+ bucky =movingUp ;
70
+ buckyPositionY += delta * .1f ;
71
+ if (buckyPositionY >162 ){
72
+ buckyPositionY -= delta * .1f ;
73
+ }
74
+
75
+ }
76
+
77
+ //Down
78
+ if (input .isKeyDown (Input .KEY_DOWN )){
79
+ bucky =movingDown ;
80
+ buckyPositionY -= delta * .1f ;
81
+ if (buckyPositionY <-600 ){
82
+ buckyPositionY += delta * .1f ;
83
+ }
84
+ }
85
+
86
+ //Left
87
+ if (input .isKeyDown (Input .KEY_LEFT )){
88
+ bucky =movingLeft ;
89
+ buckyPositionX += delta * .1f ;
90
+ if (buckyPositionX >324 ){
91
+ buckyPositionX -= delta * .1f ;
92
+ }
93
+ }
94
+
95
+ //Right
96
+ if (input .isKeyDown (Input .KEY_RIGHT )){
97
+ bucky =movingRight ;
98
+ buckyPositionX -= delta * .1f ;
99
+ if (buckyPositionX <-840 ){
100
+ buckyPositionX += delta * .1f ;
101
+ }
102
+ }
65
103
66
104
}
67
105
0 commit comments