Changed jump max speed and jump behavior near screen bounds

This commit is contained in:
Kleme
2017-06-29 11:32:01 +02:00
parent 9c75add9d6
commit 1834878346
2 changed files with 13 additions and 13 deletions
+12 -12
View File
@@ -17,7 +17,7 @@ public class MarioAI {
private static final float RUN_SPEED = 1.5f; private static final float RUN_SPEED = 1.5f;
private static final float JUMP_SPEED_X = 0.25f; private static final float JUMP_SPEED_X = 0.25f;
private static final float GRAVITY = 0.25f; private static final float GRAVITY = 0.25f;
private static final float MAX_JUMP_SPEED_Y = 5f; private static final float MAX_JUMP_SPEED_Y = 10f;
//tiles //tiles
private static final int MARIO_STILL = 0; private static final int MARIO_STILL = 0;
@@ -196,16 +196,16 @@ public class MarioAI {
break; break;
} }
this.pos = Utils.add(this.pos, speed); if(this.state != State.LOOSING){
this.pos = Utils.add(this.pos, speed);
if(pos.x<=minx && this.left || pos.x+sizex>=maxx && !this.left){
this.turn = true; if(pos.x<=minx && this.left || pos.x+sizex>=maxx && !this.left){
this.left = !this.left; this.turn = true;
} this.left = !this.left;
}
int[] ybounds = Utils.getYBounds((int) pos.x);
int[] ybounds = Utils.getYBounds((int) pos.x);
if(this.state != State.JUMPING){
if(pos.y<ybounds[0]){ if(pos.y<ybounds[0]){
this.spdy = 0f; this.spdy = 0f;
this.maxspdy = rand.nextFloat()*speedf*MAX_JUMP_SPEED_Y; this.maxspdy = rand.nextFloat()*speedf*MAX_JUMP_SPEED_Y;
@@ -235,7 +235,7 @@ public class MarioAI {
case RUNNING: case RUNNING:
return this.time%150<75?MARIO_RUNNING_1:MARIO_RUNNING_2; return this.time%150<75?MARIO_RUNNING_1:MARIO_RUNNING_2;
case JUMPING: case JUMPING:
return this.spdy<=1f?MARIO_JUMPING:MARIO_FALLING; return this.spdy<=MAX_JUMP_SPEED_Y/10f?MARIO_JUMPING:MARIO_FALLING;
case STILL_LOOK_UP: case STILL_LOOK_UP:
return MARIO_LOOK_UP; return MARIO_LOOK_UP;
case STILL_WIN: case STILL_WIN:
+1 -1
View File
@@ -25,7 +25,7 @@ public class MarioWindow extends JWindow implements ActionListener {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final String VERSION = "1.5"; private static final String VERSION = "1.6";
private static final int REFRESH_MS = 20; private static final int REFRESH_MS = 20;
private static final int TILE_W = 20; private static final int TILE_W = 20;