Slopes now kind of work but not really

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
unknown 2 years ago
parent 561c51da19
commit 4edcc62e99
  1. BIN
      bin/sig/map/Tile.class
  2. BIN
      bin/sig/objects/Player$1.class
  3. BIN
      bin/sig/objects/Player.class
  4. BIN
      maps/world1.map
  5. 12
      src/sig/map/Tile.java
  6. 38
      src/sig/objects/Player.java

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -7,12 +7,12 @@ public enum Tile {
PLATFORM_LEDGE(2,0,CollisionType.BLOCK),
INVISIBLE_WALL(0,0,true,CollisionType.BLOCK),
HIGHLIGHTED_TILE(3,0,CollisionType.BLOCK),
SMALL_SLOPE_LEFT(0,1,CollisionType.BLOCK),
SMALL_SLOPE_RIGHT(1,1,CollisionType.BLOCK),
BIG_SLOPE_LEFT1(2,1,CollisionType.BLOCK),
BIG_SLOPE_LEFT2(3,1,CollisionType.BLOCK),
BIG_SLOPE_RIGHT1(0,2,CollisionType.BLOCK),
BIG_SLOPE_RIGHT2(1,2,CollisionType.BLOCK),
SMALL_SLOPE_LEFT(0,1,CollisionType.SLOPE),
SMALL_SLOPE_RIGHT(1,1,CollisionType.SLOPE),
BIG_SLOPE_LEFT1(2,1,CollisionType.SLOPE),
BIG_SLOPE_LEFT2(3,1,CollisionType.SLOPE),
BIG_SLOPE_RIGHT1(0,2,CollisionType.SLOPE),
BIG_SLOPE_RIGHT2(1,2,CollisionType.SLOPE),
;
final public static int TILE_WIDTH=32;

@ -169,6 +169,7 @@ public class Player extends AnimatedObject{
if (KeyHeld(Action.JUMP)&&RabiClone.TIME-spacebarPressed<jumpHoldTime) {
y_velocity=jump_velocity;
}
System.out.println(state);
}
@ -384,9 +385,16 @@ public class Player extends AnimatedObject{
if (y_velocity==0) {
Tile checked_tile_bottom_right = RabiClone.CURRENT_MAP.getTile((int)(getX()+getAnimatedSpr().getWidth()/2-4)/Tile.TILE_WIDTH, (int)(getY()+getAnimatedSpr().getHeight()/2+1)/Tile.TILE_HEIGHT);
Tile checked_tile_bottom_left = RabiClone.CURRENT_MAP.getTile((int)(getX()-getAnimatedSpr().getWidth()/2+4)/Tile.TILE_WIDTH, (int)(getY()+getAnimatedSpr().getHeight()/2+1)/Tile.TILE_HEIGHT);
if (!(checked_tile_bottom_right.getCollision()==CollisionType.BLOCK||checked_tile_bottom_left.getCollision()==CollisionType.BLOCK)) {
Tile checked_tile_bottom_center = RabiClone.CURRENT_MAP.getTile((int)(getX())/Tile.TILE_WIDTH, (int)(getY()+getAnimatedSpr().getHeight()/2)/Tile.TILE_HEIGHT);
if (!(checked_tile_bottom_right.getCollision()==CollisionType.BLOCK
||checked_tile_bottom_left.getCollision()==CollisionType.BLOCK
||checked_tile_bottom_center.getCollision()==CollisionType.SLOPE)) {
groundCollision=false;
} else {
if(checked_tile_bottom_center.getCollision()==CollisionType.SLOPE){
setY(-(getX()%Tile.TILE_WIDTH)+(int)(getY()+getAnimatedSpr().getHeight()/2)/Tile.TILE_HEIGHT*Tile.TILE_HEIGHT+(getAnimatedSpr().getHeight()/2-4));
}
groundCollision=true;
jumpCount=maxJumpCount;
}
@ -398,14 +406,18 @@ public class Player extends AnimatedObject{
double check_distance_y = (displacement_y/4)*(i+1);
Tile checked_tile_bottom_right = RabiClone.CURRENT_MAP.getTile((int)(getX()+getAnimatedSpr().getWidth()/2-4)/Tile.TILE_WIDTH, (int)(getY()+getAnimatedSpr().getHeight()/2+check_distance_y)/Tile.TILE_HEIGHT);
Tile checked_tile_bottom_left = RabiClone.CURRENT_MAP.getTile((int)(getX()-getAnimatedSpr().getWidth()/2+4)/Tile.TILE_WIDTH, (int)(getY()+getAnimatedSpr().getHeight()/2+check_distance_y)/Tile.TILE_HEIGHT);
Tile checked_tile_bottom_center = RabiClone.CURRENT_MAP.getTile((int)(getX())/Tile.TILE_WIDTH, (int)(getY()+getAnimatedSpr().getHeight()/2)/Tile.TILE_HEIGHT);
if(checked_tile_bottom_center.getCollision()==CollisionType.SLOPE
&& getY()+check_distance_y>(-(getX()%Tile.TILE_WIDTH)+(int)(getY()+getAnimatedSpr().getHeight()/2)/Tile.TILE_HEIGHT*Tile.TILE_HEIGHT+(getAnimatedSpr().getHeight()/2-4)))
{
setY(-(getX()%Tile.TILE_WIDTH)+(int)(getY()+getAnimatedSpr().getHeight()/2)/Tile.TILE_HEIGHT*Tile.TILE_HEIGHT+(getAnimatedSpr().getHeight()/2-4));
collisionOccured = groundCollision(check_distance_y);
System.out.println(checked_tile_bottom_center);
break;
}
//System.out.println((int)getX()/Tile.TILE_WIDTH);
if(checked_tile_bottom_right.getCollision()==CollisionType.BLOCK||checked_tile_bottom_left.getCollision()==CollisionType.BLOCK){
setY((getY()-check_distance_y));
y_acceleration = 0;
y_velocity = 0;
groundCollision=true;
collisionOccured=true;
state = State.IDLE;
collisionOccured = groundCollision(check_distance_y);
break;
}
}
@ -432,6 +444,18 @@ public class Player extends AnimatedObject{
}
private boolean groundCollision(double check_distance_y) {
boolean collisionOccured;
setY((getY()-check_distance_y));
y_acceleration = 0;
y_velocity = 0;
groundCollision=true;
collisionOccured=true;
state = State.IDLE;
return collisionOccured;
}
private void handleKeyboardMovement(double updateMult, int movement, double friction, double drag) {
if (movement!=0&&Math.abs(x_velocity)<WALKING_SPEED_LIMIT) {
x_acceleration=drag*(movement);

Loading…
Cancel
Save