small changes in match to reduce crashes
This commit is contained in:
parent
93f5727569
commit
63ac95865a
@ -44,7 +44,7 @@ public class Frame {
|
||||
this.moveCancellable = true;
|
||||
this.isDashCancellable = true;
|
||||
this.lastFrameOfHit = false;
|
||||
this.sprite = new int[0];
|
||||
this.sprite = new int[4];
|
||||
}
|
||||
|
||||
public Frame(Double move_y, Double move_x, ArrayList<Passive_HitBox> passHitBox, ArrayList<Active_HitBox> actHitBox,
|
||||
|
@ -49,7 +49,9 @@ public class nextFrameBuffer {
|
||||
}
|
||||
|
||||
public Frame getNextframe() {
|
||||
return this.next.current;
|
||||
try {
|
||||
return this.next.current;
|
||||
} catch(NullPointerException e) {return null;}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import engine.input.Button;
|
||||
import engine.input.GamepadInput;
|
||||
import engine.math.Vector3f;
|
||||
import engine.object.ObjectGl;
|
||||
import engine.object.Sprite;
|
||||
import gameplay.Characters.Blue.CharacterBlue;
|
||||
import gameplay.actions.Attack;
|
||||
import gameplay.actions.attackPart;
|
||||
@ -70,6 +71,8 @@ public class match {
|
||||
inputsP2 = new InputBuffer(inputBufferSize);
|
||||
p1.setPos(-750, groundLevel); //TODO : change to better values if needed
|
||||
p2.setPos(-750, groundLevel); //TODO : change to better values if needed
|
||||
objP1.translate(new Vector3f(p1.getPosX(),p1.getPosY(),0));
|
||||
objP1.translate(new Vector3f(p2.getPosX(),p2.getPosY(),0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -168,17 +171,17 @@ public class match {
|
||||
|
||||
p1 = CharacterBlue.generateCharBlue();
|
||||
p2 = CharacterBlue.generateCharBlue();
|
||||
objP1 = new ObjectGl(1f, 60f, 80f, 5f, path, null);
|
||||
objP2 = new ObjectGl(2f, 60f, 80f, 5f, path, null);
|
||||
objP1 = new Sprite(10f, 5f, path, null);
|
||||
objP2 = new Sprite(15f, 5f, path, null);
|
||||
objP2.setColor(new Vector3f(1.0f,0.0f,1.0f));
|
||||
engine.add_objectGl(objP1);
|
||||
engine.add_objectGl(objP2);
|
||||
|
||||
f = p1.getCurrentframe();
|
||||
objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
|
||||
objP1.translate(new Vector3f(-750,200,0));
|
||||
|
||||
f = p2.getCurrentframe();
|
||||
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
|
||||
objP2.translate(new Vector3f(750,200,0));
|
||||
objP2.flipTextureWrapH();
|
||||
|
||||
if (Joystick1Present) {
|
||||
@ -239,10 +242,12 @@ public class match {
|
||||
|
||||
//read both players inputs
|
||||
case 20:
|
||||
gamepad1.inputRefresh();
|
||||
inputsP1.recordInputsFromGamepad(gamepad1, p1.getPosX() < p2.getPosX());
|
||||
gamepad2.inputRefresh();
|
||||
inputsP2.recordInputsFromGamepad(gamepad2, p2.getPosX() <= p1.getPosX());
|
||||
if (glfwJoystickPresent(GLFW_JOYSTICK_1) && glfwJoystickPresent(GLFW_JOYSTICK_2)) {
|
||||
gamepad1.inputRefresh();
|
||||
inputsP1.recordInputsFromGamepad(gamepad1, p1.getPosX() < p2.getPosX());
|
||||
gamepad2.inputRefresh();
|
||||
inputsP2.recordInputsFromGamepad(gamepad2, p2.getPosX() <= p1.getPosX());
|
||||
}
|
||||
handleInputs(p1, inputsP1);
|
||||
handleInputs(p2, inputsP2);
|
||||
ac(21);
|
||||
@ -250,9 +255,13 @@ public class match {
|
||||
|
||||
//start of the handling of hitboxes
|
||||
case 21:
|
||||
handleThrows(p1,p2);
|
||||
handleHits(p1,p2,inputsP2);
|
||||
handleHits(p2,p1,inputsP1);
|
||||
try {
|
||||
handleThrows(p1, p2);
|
||||
} catch (IndexOutOfBoundsException e) {}
|
||||
try {
|
||||
handleHits(p1, p2, inputsP2);
|
||||
handleHits(p2, p1, inputsP1);
|
||||
}catch (IndexOutOfBoundsException e) {};
|
||||
ac(22);
|
||||
break;
|
||||
|
||||
@ -514,9 +523,10 @@ public class match {
|
||||
* @param in the input buffer corresponding to the character
|
||||
*/
|
||||
private static void nextFrame(Character c, InputBuffer in) {
|
||||
if(!c.getFrames().getNextframe().equals(null)){
|
||||
try {
|
||||
//if(!c.getFrames().getNextframe().equals(null)){
|
||||
c.goToNextFrames();
|
||||
} else {
|
||||
} catch (NullPointerException e) {
|
||||
switch(c.getStatus()) {
|
||||
case FALLING:case HITINAIR:
|
||||
if(c.getPosY() > groundLevel){
|
||||
|
Loading…
x
Reference in New Issue
Block a user