Add a slide buffer so it can be queued prior to landing.
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
72565d2b02
commit
537bc7c744
Binary file not shown.
@ -89,35 +89,7 @@ public class RabiClone{
|
|||||||
double updateMult = Math.min(1/60d,timePassed/1000000000d);
|
double updateMult = Math.min(1/60d,timePassed/1000000000d);
|
||||||
|
|
||||||
|
|
||||||
//System.out.println(CONTROLLERS.length);
|
handleGameControllers();
|
||||||
for (int i=0;i<CONTROLLERS.length;i++) {
|
|
||||||
if (CONTROLLERS[i].getType()==Controller.Type.KEYBOARD||CONTROLLERS[i].getType()==Controller.Type.MOUSE) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (CONTROLLERS[i].poll()) {
|
|
||||||
//System.out.println(CONTROLLERS[i].getPortType()+" // "+CONTROLLERS[i].getType());
|
|
||||||
Component[] components = CONTROLLERS[i].getComponents();
|
|
||||||
for (int j=0;j<components.length;j++) {
|
|
||||||
//Component c = components[j];
|
|
||||||
//System.out.println(c.getName()+","+c.getIdentifier()+": "+c.getPollData());
|
|
||||||
}
|
|
||||||
//System.out.println("--------");
|
|
||||||
} else {
|
|
||||||
Controller[] newArr = new Controller[CONTROLLERS.length-1];
|
|
||||||
for (int j=0;j<CONTROLLERS.length;j++) {
|
|
||||||
if (j!=i) {
|
|
||||||
newArr[(j>i?j-1:j)]=CONTROLLERS[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CONTROLLERS=newArr;
|
|
||||||
}
|
|
||||||
/*EventQueue queue = controller_list[i].getEventQueue();
|
|
||||||
|
|
||||||
while (queue.getNextEvent(event)) {
|
|
||||||
Component c = event.getComponent();
|
|
||||||
System.out.println(c.getName()+","+c.getIdentifier()+": "+c.getPollData());
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyBind.poll();
|
KeyBind.poll();
|
||||||
|
|
||||||
@ -155,6 +127,23 @@ public class RabiClone{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void handleGameControllers() {
|
||||||
|
for (int i=0;i<CONTROLLERS.length;i++) {
|
||||||
|
if (CONTROLLERS[i].getType()==Controller.Type.KEYBOARD||CONTROLLERS[i].getType()==Controller.Type.MOUSE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!CONTROLLERS[i].poll()) {
|
||||||
|
Controller[] newArr = new Controller[CONTROLLERS.length-1];
|
||||||
|
for (int j=0;j<CONTROLLERS.length;j++) {
|
||||||
|
if (j!=i) {
|
||||||
|
newArr[(j>i?j-1:j)]=CONTROLLERS[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CONTROLLERS=newArr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void ResetGame() {
|
private static void ResetGame() {
|
||||||
player=null;
|
player=null;
|
||||||
level_renderer=null;
|
level_renderer=null;
|
||||||
|
@ -111,13 +111,13 @@ public class KeyBind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void emitReleaseEvent(Action a) {
|
private static void emitReleaseEvent(Action a) {
|
||||||
System.out.println("Release for "+a);
|
//System.out.println("Release for "+a);
|
||||||
for (int i=0;i<RabiClone.OBJ.size();i++) {
|
for (int i=0;i<RabiClone.OBJ.size();i++) {
|
||||||
RabiClone.OBJ.get(i).KeyReleased(a);
|
RabiClone.OBJ.get(i).KeyReleased(a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void emitPressEvent(Action a) {
|
private static void emitPressEvent(Action a) {
|
||||||
System.out.println("Press for "+a);
|
//System.out.println("Press for "+a);
|
||||||
for (int i=0;i<RabiClone.OBJ.size();i++) {
|
for (int i=0;i<RabiClone.OBJ.size();i++) {
|
||||||
RabiClone.OBJ.get(i).KeyPressed(a);
|
RabiClone.OBJ.get(i).KeyPressed(a);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package sig.engine;
|
|||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public class String{
|
public class String{
|
||||||
private StringBuilder sb;
|
private StringBuilder sb;
|
||||||
private Point bounds = new Point(0,1);
|
private Point bounds = new Point(0,1);
|
||||||
|
@ -12,14 +12,14 @@ import sig.map.View;
|
|||||||
import sig.objects.actor.State;
|
import sig.objects.actor.State;
|
||||||
|
|
||||||
public class Player extends AnimatedObject{
|
public class Player extends AnimatedObject{
|
||||||
final double GRAVITY = 1300;
|
final static double GRAVITY = 1300;
|
||||||
final double NORMAL_FRICTION = 6400;
|
final static double NORMAL_FRICTION = 6400;
|
||||||
final double NORMAL_JUMP_VELOCITY = -300;
|
final static double NORMAL_JUMP_VELOCITY = -300;
|
||||||
final boolean LEFT = false;
|
final static boolean LEFT = false;
|
||||||
final boolean RIGHT = true;
|
final static boolean RIGHT = true;
|
||||||
final int jump_fall_AnimationWaitTime = 200;
|
final static int jump_fall_AnimationWaitTime = 200;
|
||||||
final int slide_AnimationWaitTime = 100;
|
final static int slide_AnimationWaitTime = 100;
|
||||||
final int slide_duration = 700;
|
final static int slide_duration = 700;
|
||||||
|
|
||||||
double y_acceleration = GRAVITY;
|
double y_acceleration = GRAVITY;
|
||||||
double y_acceleration_limit = 100;
|
double y_acceleration_limit = 100;
|
||||||
@ -56,6 +56,9 @@ public class Player extends AnimatedObject{
|
|||||||
long slide_time = -1;
|
long slide_time = -1;
|
||||||
int jumpHoldTime = 150;
|
int jumpHoldTime = 150;
|
||||||
|
|
||||||
|
final static int slideBufferTime = 200;
|
||||||
|
long slidePressed = -1;
|
||||||
|
|
||||||
public Player(Panel panel) {
|
public Player(Panel panel) {
|
||||||
super(Sprite.ERINA,5,panel);
|
super(Sprite.ERINA,5,panel);
|
||||||
setX(RabiClone.BASE_WIDTH/2-getAnimatedSpr().getWidth()/2);
|
setX(RabiClone.BASE_WIDTH/2-getAnimatedSpr().getWidth()/2);
|
||||||
@ -83,6 +86,11 @@ public class Player extends AnimatedObject{
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IDLE:
|
case IDLE:
|
||||||
|
if (System.currentTimeMillis()-slidePressed<=slideBufferTime) {
|
||||||
|
performSlide();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
jump_velocity = NORMAL_JUMP_VELOCITY;
|
jump_velocity = NORMAL_JUMP_VELOCITY;
|
||||||
horizontal_friction = NORMAL_FRICTION;
|
horizontal_friction = NORMAL_FRICTION;
|
||||||
jump_slide_fall_StartAnimationTimer=-1;
|
jump_slide_fall_StartAnimationTimer=-1;
|
||||||
@ -164,17 +172,14 @@ public class Player extends AnimatedObject{
|
|||||||
break;
|
break;
|
||||||
case IDLE:
|
case IDLE:
|
||||||
if(a==Action.SLIDE||a==Action.FALL){
|
if(a==Action.SLIDE||a==Action.FALL){
|
||||||
slide_time = System.currentTimeMillis();
|
performSlide();
|
||||||
if(facing_direction){
|
|
||||||
x_velocity=sliding_velocity;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
x_velocity=-sliding_velocity;
|
|
||||||
}
|
|
||||||
state=State.SLIDE;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FALLING:
|
case FALLING:
|
||||||
|
if (a==Action.SLIDE||a==Action.FALL) {
|
||||||
|
slidePressed=System.currentTimeMillis();
|
||||||
|
//System.out.println("Queue up slide.");
|
||||||
|
}
|
||||||
case JUMP:
|
case JUMP:
|
||||||
if(jumpCount>0 && spacebarReleased && (a==Action.JUMP)){
|
if(jumpCount>0 && spacebarReleased && (a==Action.JUMP)){
|
||||||
jumpCount=0;
|
jumpCount=0;
|
||||||
@ -215,6 +220,18 @@ public class Player extends AnimatedObject{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void performSlide() {
|
||||||
|
slide_time = System.currentTimeMillis();
|
||||||
|
if(facing_direction){
|
||||||
|
x_velocity=sliding_velocity;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
x_velocity=-sliding_velocity;
|
||||||
|
}
|
||||||
|
state=State.SLIDE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleCameraRoomMovement() {
|
private void handleCameraRoomMovement() {
|
||||||
int tileX = (int)(getX())/Tile.TILE_WIDTH;
|
int tileX = (int)(getX())/Tile.TILE_WIDTH;
|
||||||
int tileY = (int)(getY())/Tile.TILE_HEIGHT;
|
int tileY = (int)(getY())/Tile.TILE_HEIGHT;
|
||||||
@ -340,8 +357,8 @@ public class Player extends AnimatedObject{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (y_velocity==0) {
|
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+0.5)/Tile.TILE_HEIGHT);
|
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+0.5)/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)) {
|
if (!(checked_tile_bottom_right.getCollision()==CollisionType.BLOCK||checked_tile_bottom_left.getCollision()==CollisionType.BLOCK)) {
|
||||||
groundCollision=false;
|
groundCollision=false;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user