@@ -43,12 +43,12 @@ private void init() {
43
43
name = "Player" ;
44
44
playerBoundary = new RectBoundedBox (positionX , positionY , GlobalConstants .PLAYER_WIDTH , GlobalConstants .PLAYER_HEIGHT );
45
45
46
- playerAnimations = new PlayerAnimations (this );
46
+ playerAnimations = new PlayerAnimations (this );
47
47
48
48
positionX = GlobalConstants .PLAYER_X ;
49
49
positionY = GlobalConstants .PLAYER_Y ;
50
50
51
- currentSprite = playerAnimations .getMoveUpSprite ();
51
+ currentSprite = playerAnimations .getPlayerIdleSprite ();
52
52
}
53
53
54
54
public void move (Direction direction ) {
@@ -83,34 +83,41 @@ public boolean isColliding(Entity b) {
83
83
84
84
@ Override
85
85
public void draw () {
86
- if (currentSprite != null ) {
86
+ if (currentSprite != null ) {
87
87
Renderer .playAnimation (currentSprite );
88
88
}
89
89
}
90
90
91
91
@ Override
92
92
public void move (int steps , Direction direction ) {
93
- switch (direction ) {
94
- case UP :
95
- positionY -= steps ;
96
- setCurrentSprite (playerAnimations .getMoveUpSprite ());
97
- currentDirection = Direction .UP ;
98
- break ;
99
- case DOWN :
100
- setCurrentSprite (playerAnimations .getMoveDownSprite ());
101
- currentDirection = Direction .DOWN ;
102
- positionY += steps ;
103
- break ;
104
- case LEFT :
105
- setCurrentSprite (playerAnimations .getMoveLeftSprite ());
106
- currentDirection = Direction .LEFT ;
107
- positionX -= steps ;
108
- break ;
109
- case RIGHT :
110
- setCurrentSprite (playerAnimations .getMoveRightSprite ());
111
- currentDirection = Direction .RIGHT ;
112
- positionX += steps ;
113
- break ;
93
+ if (steps == 0 ) {
94
+ setCurrentSprite (playerAnimations .getPlayerIdleSprite ());
95
+ return ;
96
+ } else {
97
+ switch (direction ) {
98
+ case UP :
99
+ positionY -= steps ;
100
+ setCurrentSprite (playerAnimations .getMoveUpSprite ());
101
+ currentDirection = Direction .UP ;
102
+ break ;
103
+ case DOWN :
104
+ setCurrentSprite (playerAnimations .getMoveDownSprite ());
105
+ currentDirection = Direction .DOWN ;
106
+ positionY += steps ;
107
+ break ;
108
+ case LEFT :
109
+ setCurrentSprite (playerAnimations .getMoveLeftSprite ());
110
+ currentDirection = Direction .LEFT ;
111
+ positionX -= steps ;
112
+ break ;
113
+ case RIGHT :
114
+ setCurrentSprite (playerAnimations .getMoveRightSprite ());
115
+ currentDirection = Direction .RIGHT ;
116
+ positionX += steps ;
117
+ break ;
118
+ default :
119
+ setCurrentSprite (playerAnimations .getPlayerIdleSprite ());
120
+ }
114
121
}
115
122
}
116
123
0 commit comments