windows size
This commit is contained in:
parent
cbec6fba9d
commit
3c63c8fffb
@ -23,31 +23,43 @@ import gameplay.entities.Character;
|
|||||||
import gameplay.input.Inputs;
|
import gameplay.input.Inputs;
|
||||||
import gameplay.input.ButtonIG;
|
import gameplay.input.ButtonIG;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.json.simple.JSONArray;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
import static org.lwjgl.glfw.GLFW.*;
|
import static org.lwjgl.glfw.GLFW.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class that describes the base structure of the match, with characters, timer and such
|
* Main class that describes the base structure of the match, with characters,
|
||||||
|
* timer and such
|
||||||
|
*
|
||||||
* @author Victor Azra
|
* @author Victor Azra
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class match {
|
public class match {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the number of inputs read for each character, a.k.a. for how many frames the inputs are saved in memory.
|
* the number of inputs read for each character, a.k.a. for how many frames the
|
||||||
|
* inputs are saved in memory.
|
||||||
*/
|
*/
|
||||||
private static final int inputBufferSize = 120;
|
private static final int inputBufferSize = 120;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the level of the "ground", used to determine if a character is in the air or not.
|
* the level of the "ground", used to determine if a character is in the air or
|
||||||
|
* not.
|
||||||
*/
|
*/
|
||||||
private static final int groundLevel = 180;
|
private static final int groundLevel = 180;
|
||||||
|
|
||||||
private static int timer;
|
private static int timer;
|
||||||
private static InputBuffer inputsP1, inputsP2;
|
private static InputBuffer inputsP1, inputsP2;
|
||||||
private static int roundsWonP1, roundsWonP2;
|
private static int roundsWonP1, roundsWonP2;
|
||||||
private static Character p1, p2; //characters of player 1 and 2
|
private static Character p1, p2; // characters of player 1 and 2
|
||||||
|
|
||||||
private static long timeStamp1;
|
private static long timeStamp1;
|
||||||
private static long timeStamp2;
|
private static long timeStamp2;
|
||||||
@ -63,44 +75,67 @@ public class match {
|
|||||||
private static UIElementText coordP1;
|
private static UIElementText coordP1;
|
||||||
private static UIElementText coordP2;
|
private static UIElementText coordP2;
|
||||||
|
|
||||||
private static ObjectGl objP1,objP2;
|
private static ObjectGl objP1, objP2;
|
||||||
private static Engine engine;
|
private static Engine engine;
|
||||||
private static Frame f;
|
private static Frame f;
|
||||||
private static int acCode = 0;
|
private static int acCode = 0;
|
||||||
|
private static int height, width;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new round, by placing the timer back at base value, characters back at full hp and such.
|
* Starts a new round, by placing the timer back at base value, characters back
|
||||||
|
* at full hp and such.
|
||||||
*/
|
*/
|
||||||
private static void startNewRound() {
|
private static void startNewRound() {
|
||||||
timer = 99;
|
timer = 99;
|
||||||
inputsP1 = new InputBuffer(inputBufferSize);
|
inputsP1 = new InputBuffer(inputBufferSize);
|
||||||
inputsP2 = new InputBuffer(inputBufferSize);
|
inputsP2 = new InputBuffer(inputBufferSize);
|
||||||
p1.setPos(-750, groundLevel); //TODO : change to better values if needed
|
p1.setPos(-750, groundLevel); // TODO : change to better values if needed
|
||||||
p2.setPos((int) (750 - objP2.getWidth() * objP2.getScalingFactor()), groundLevel); //TODO : change to better values if needed
|
p2.setPos((int) (750 - objP2.getWidth() * objP2.getScalingFactor()), groundLevel); // TODO : change to better
|
||||||
objP1.translate(new Vector3f(p1.getPosX(),p1.getPosY(),0));
|
// values if needed
|
||||||
objP2.translate(new Vector3f(p2.getPosX(),p2.getPosY(),0));
|
objP1.translate(new Vector3f(p1.getPosX(), p1.getPosY(), 0));
|
||||||
|
objP2.translate(new Vector3f(p2.getPosX(), p2.getPosY(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the round.
|
* Ends the round. Used for playing animations and such. TODO : Implement this
|
||||||
* Used for playing animations and such.
|
* once we know what to do.
|
||||||
* TODO : Implement this once we know what to do.
|
|
||||||
*/
|
*/
|
||||||
private static void endRound() {
|
private static void endRound() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ends the match.
|
* Ends the match. Used for playing animations and such. TODO : Implement this
|
||||||
* Used for playing animations and such.
|
* once we know what to do.
|
||||||
* TODO : Implement this once we know what to do.
|
|
||||||
*/
|
*/
|
||||||
private static void endMatch() {
|
private static void endMatch() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void parse() throws FileNotFoundException {
|
||||||
|
|
||||||
|
JSONParser jsonP = new JSONParser();
|
||||||
|
try {
|
||||||
|
JSONObject jsonO = (JSONObject) jsonP.parse(new FileReader("game.set"));
|
||||||
|
JSONArray game = (JSONArray) jsonO.get("game");
|
||||||
|
JSONObject settings = (JSONObject) game.get(0);
|
||||||
|
|
||||||
|
height = Integer.parseInt((String) settings.get("height"));
|
||||||
|
width = Integer.parseInt((String) settings.get("width"));
|
||||||
|
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
engine = new Engine(640, 480, new Vector3f(4.0f, 3.0f));
|
parse();
|
||||||
|
engine = new Engine(width, height, new Vector3f(4.0f, 3.0f));
|
||||||
engine.init();
|
engine.init();
|
||||||
|
|
||||||
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
||||||
@ -109,8 +144,8 @@ public class match {
|
|||||||
String path = "textures/Sprite.png";
|
String path = "textures/Sprite.png";
|
||||||
String pathToBG = "textures/background_beach.png";
|
String pathToBG = "textures/background_beach.png";
|
||||||
|
|
||||||
ObjectGl background = new ObjectGl(0f,1f,1f,10f, pathToBG, null);
|
ObjectGl background = new ObjectGl(0f, 1f, 1f, 10f, pathToBG, null);
|
||||||
background.setTextureWrap(0,0,621, 224);
|
background.setTextureWrap(0, 0, 621, 224);
|
||||||
background.translate(new Vector3f(-3011.0f, 1400.0f, 1.0f));
|
background.translate(new Vector3f(-3011.0f, 1400.0f, 1.0f));
|
||||||
engine.add_objectGl(background);
|
engine.add_objectGl(background);
|
||||||
|
|
||||||
@ -118,7 +153,7 @@ public class match {
|
|||||||
p2 = CharacterBlue.generateCharBlue();
|
p2 = CharacterBlue.generateCharBlue();
|
||||||
objP1 = new Sprite(10f, 5f, path, null);
|
objP1 = new Sprite(10f, 5f, path, null);
|
||||||
objP2 = new Sprite(15f, 5f, path, null);
|
objP2 = new Sprite(15f, 5f, path, null);
|
||||||
objP2.setColor(new Vector3f(1.0f,0.0f,1.0f));
|
objP2.setColor(new Vector3f(1.0f, 0.0f, 1.0f));
|
||||||
engine.add_objectGl(objP1);
|
engine.add_objectGl(objP1);
|
||||||
engine.add_objectGl(objP2);
|
engine.add_objectGl(objP2);
|
||||||
|
|
||||||
@ -129,76 +164,89 @@ public class match {
|
|||||||
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]);
|
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]);
|
||||||
objP2.flipTextureWrapH();
|
objP2.flipTextureWrapH();
|
||||||
|
|
||||||
if(Joystick1Present) {
|
if (Joystick1Present) {
|
||||||
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
||||||
gamepad1.inputRefresh();
|
gamepad1.inputRefresh();
|
||||||
System.out.println("P1 Controller: " + gamepad1.getGamepadName());
|
System.out.println("P1 Controller: " + gamepad1.getGamepadName());
|
||||||
}
|
}
|
||||||
if(Joystick2Present) {
|
if (Joystick2Present) {
|
||||||
gamepad2 = new GamepadInput(GLFW_JOYSTICK_2);
|
gamepad2 = new GamepadInput(GLFW_JOYSTICK_2);
|
||||||
gamepad2.inputRefresh();
|
gamepad2.inputRefresh();
|
||||||
System.out.println("P2 Controller: " + gamepad2.getGamepadName());
|
System.out.println("P2 Controller: " + gamepad2.getGamepadName());
|
||||||
}
|
}
|
||||||
|
|
||||||
// GUI setup
|
// GUI setup
|
||||||
coordP1 = new UIElementText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY(), 5f, 0f, 1f, 80f, engine);
|
coordP1 = new UIElementText(
|
||||||
|
"objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() + ":" + p1.getPosY(), 5f,
|
||||||
|
0f, 1f, 80f, engine);
|
||||||
engine.add_uiElement(coordP1);
|
engine.add_uiElement(coordP1);
|
||||||
coordP2 = new UIElementText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P1: " + p2.getPosX() +":" + p2.getPosY(), 5f, 0f, 0.9f, 80f, engine);
|
coordP2 = new UIElementText(
|
||||||
|
"objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P1: " + p2.getPosX() + ":" + p2.getPosY(), 5f,
|
||||||
|
0f, 0.9f, 80f, engine);
|
||||||
engine.add_uiElement(coordP2);
|
engine.add_uiElement(coordP2);
|
||||||
|
|
||||||
while(frameCount < 5940 && engine.getRunning()) {
|
while (frameCount < 5940 && engine.getRunning()) {
|
||||||
ac(acCode);
|
ac(acCode);
|
||||||
if(engine.shouldClose()) engine.setRunning(false);
|
if (engine.shouldClose())
|
||||||
|
engine.setRunning(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ac(int i) {
|
private static void ac(int i) {
|
||||||
// System.out.println(i);
|
// System.out.println(i);
|
||||||
switch (i) {
|
switch (i) {
|
||||||
|
|
||||||
//initiate a round
|
// initiate a round
|
||||||
case 0 :
|
case 0:
|
||||||
startNewRound();
|
startNewRound();
|
||||||
timeStamp1 = System.currentTimeMillis();
|
timeStamp1 = System.currentTimeMillis();
|
||||||
frameCount = 0;
|
frameCount = 0;
|
||||||
acCode = 10;
|
acCode = 10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//checks if one or both of the chars are out of health
|
// checks if one or both of the chars are out of health
|
||||||
case 10:
|
case 10:
|
||||||
oldPosXp1 = p1.getPosX();
|
oldPosXp1 = p1.getPosX();
|
||||||
oldPosXp2 = p2.getPosX();
|
oldPosXp2 = p2.getPosX();
|
||||||
oldPosYp1 = p1.getPosY();
|
oldPosYp1 = p1.getPosY();
|
||||||
oldPosYp2 = p2.getPosY();
|
oldPosYp2 = p2.getPosY();
|
||||||
|
|
||||||
if(p1.getCurrentHP() <= 0 && p2.getCurrentHP() <= 0) { acCode = 11;}
|
if (p1.getCurrentHP() <= 0 && p2.getCurrentHP() <= 0) {
|
||||||
else if(p1.getCurrentHP() <= 0) { acCode = 12;}
|
acCode = 11;
|
||||||
else if(p2.getCurrentHP() <= 0) { acCode = 13;}
|
} else if (p1.getCurrentHP() <= 0) {
|
||||||
else { acCode = 20;}
|
acCode = 12;
|
||||||
|
} else if (p2.getCurrentHP() <= 0) {
|
||||||
|
acCode = 13;
|
||||||
|
} else {
|
||||||
|
acCode = 20;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//end round
|
// end round
|
||||||
case 11:
|
case 11:
|
||||||
endRound();
|
endRound();
|
||||||
if(roundsWonP1 >= 2||roundsWonP2 >= 2) { endMatch();} //TODO : will probably need to specify more
|
if (roundsWonP1 >= 2 || roundsWonP2 >= 2) {
|
||||||
else{acCode = 0;}
|
endMatch();
|
||||||
|
} // TODO : will probably need to specify more
|
||||||
|
else {
|
||||||
|
acCode = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//if p1 is at 0 health
|
// if p1 is at 0 health
|
||||||
case 12:
|
case 12:
|
||||||
roundsWonP2++;
|
roundsWonP2++;
|
||||||
acCode = 11;
|
acCode = 11;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//if p2 is at 0 health
|
// if p2 is at 0 health
|
||||||
case 13:
|
case 13:
|
||||||
roundsWonP1++;
|
roundsWonP1++;
|
||||||
acCode = 11;
|
acCode = 11;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//read both players inputs
|
// read both players inputs
|
||||||
case 20:
|
case 20:
|
||||||
if (glfwJoystickPresent(GLFW_JOYSTICK_1)) {
|
if (glfwJoystickPresent(GLFW_JOYSTICK_1)) {
|
||||||
gamepad1.inputRefresh();
|
gamepad1.inputRefresh();
|
||||||
@ -215,43 +263,45 @@ public class match {
|
|||||||
acCode = 21;
|
acCode = 21;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//start of the handling of hitboxes
|
// start of the handling of hitboxes
|
||||||
case 21:
|
case 21:
|
||||||
try {
|
try {
|
||||||
handleThrows(p1, p2);
|
handleThrows(p1, p2);
|
||||||
} catch (IndexOutOfBoundsException e) {}
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
handleHits(p1, p2, inputsP2);
|
handleHits(p1, p2, inputsP2);
|
||||||
handleHits(p2, p1, inputsP1);
|
handleHits(p2, p1, inputsP1);
|
||||||
}catch (IndexOutOfBoundsException e) {};
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
}
|
||||||
|
;
|
||||||
acCode = 22;
|
acCode = 22;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Update of the current frame of each character
|
// Update of the current frame of each character
|
||||||
case 22:
|
case 22:
|
||||||
if(p1.getCurrentframe().islastFrameOfHit()) {
|
if (p1.getCurrentframe().islastFrameOfHit()) {
|
||||||
p1.removeFirstAttackPart();
|
p1.removeFirstAttackPart();
|
||||||
}
|
}
|
||||||
if(p2.getCurrentframe().islastFrameOfHit()) {
|
if (p2.getCurrentframe().islastFrameOfHit()) {
|
||||||
p2.removeFirstAttackPart();
|
p2.removeFirstAttackPart();
|
||||||
}
|
}
|
||||||
nextFrame(p1,inputsP1);
|
nextFrame(p1, inputsP1);
|
||||||
nextFrame(p2,inputsP2);
|
nextFrame(p2, inputsP2);
|
||||||
|
|
||||||
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
||||||
updatePos(p1,p1LooksRight);
|
updatePos(p1, p1LooksRight);
|
||||||
updatePos(p2,!p1LooksRight);
|
updatePos(p2, !p1LooksRight);
|
||||||
|
|
||||||
|
if (p1LooksRight) {
|
||||||
if(p1LooksRight) {
|
|
||||||
|
|
||||||
f = p1.getCurrentframe();
|
f = p1.getCurrentframe();
|
||||||
objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]);
|
objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]);
|
||||||
objP1.translate(new Vector3f(p1.getPosX()-oldPosXp1,p1.getPosY()-oldPosYp1,0));
|
objP1.translate(new Vector3f(p1.getPosX() - oldPosXp1, p1.getPosY() - oldPosYp1, 0));
|
||||||
|
|
||||||
f = p2.getCurrentframe();
|
f = p2.getCurrentframe();
|
||||||
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]);
|
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3]);
|
||||||
objP2.translate(new Vector3f(0-(p2.getPosX()-oldPosXp2),p2.getPosY()-oldPosYp2,0));
|
objP2.translate(new Vector3f(0 - (p2.getPosX() - oldPosXp2), p2.getPosY() - oldPosYp2, 0));
|
||||||
|
|
||||||
Frame nf = new Frame();
|
Frame nf = new Frame();
|
||||||
nf.clone(p2.getCurrentframe());
|
nf.clone(p2.getCurrentframe());
|
||||||
@ -259,16 +309,15 @@ public class match {
|
|||||||
p2.setCurrentFrame(nf);
|
p2.setCurrentFrame(nf);
|
||||||
objP2.flipTextureWrapH();
|
objP2.flipTextureWrapH();
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
Frame p1f = p1.getCurrentframe();
|
Frame p1f = p1.getCurrentframe();
|
||||||
objP1.setTextureWrap(p1f.getSprite()[0], p1f.getSprite()[1], p1f.getSprite()[2], p1f.getSprite()[3]);
|
objP1.setTextureWrap(p1f.getSprite()[0], p1f.getSprite()[1], p1f.getSprite()[2], p1f.getSprite()[3]);
|
||||||
objP1.translate(new Vector3f(p1.getPosX()-oldPosXp1,p1.getPosY()-oldPosYp1,0));
|
objP1.translate(new Vector3f(p1.getPosX() - oldPosXp1, p1.getPosY() - oldPosYp1, 0));
|
||||||
|
|
||||||
Frame p2f = p2.getCurrentframe();
|
Frame p2f = p2.getCurrentframe();
|
||||||
objP2.setTextureWrap(p2f.getSprite()[0], p2f.getSprite()[1], p2f.getSprite()[2], p2f.getSprite()[3]);
|
objP2.setTextureWrap(p2f.getSprite()[0], p2f.getSprite()[1], p2f.getSprite()[2], p2f.getSprite()[3]);
|
||||||
objP2.translate(new Vector3f(p2.getPosX()-oldPosXp2,p2.getPosY()-oldPosYp2,0));
|
objP2.translate(new Vector3f(p2.getPosX() - oldPosXp2, p2.getPosY() - oldPosYp2, 0));
|
||||||
|
|
||||||
Frame nf = new Frame();
|
Frame nf = new Frame();
|
||||||
nf.clone(p1.getCurrentframe());
|
nf.clone(p1.getCurrentframe());
|
||||||
@ -281,46 +330,52 @@ public class match {
|
|||||||
acCode = 23;
|
acCode = 23;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//Waits the end of 1/60th of a second since start of frame then loops back to start
|
// Waits the end of 1/60th of a second since start of frame then loops back to
|
||||||
|
// start
|
||||||
case 23:
|
case 23:
|
||||||
// GUI update here
|
// GUI update here
|
||||||
coordP1.setText("objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() +":" + p1.getPosY());
|
coordP1.setText(
|
||||||
coordP2.setText("objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P2: " + p2.getPosX() +":" + p2.getPosY());
|
"objP1: " + objP1.getXPos() + ":" + objP1.getYPos() + " P1: " + p1.getPosX() + ":" + p1.getPosY());
|
||||||
|
coordP2.setText(
|
||||||
|
"objP2: " + objP2.getXPos() + ":" + objP2.getYPos() + " P2: " + p2.getPosX() + ":" + p2.getPosY());
|
||||||
timeStamp2 = System.currentTimeMillis();
|
timeStamp2 = System.currentTimeMillis();
|
||||||
while(timeStamp2-timeStamp1<(1000/60)) {
|
while (timeStamp2 - timeStamp1 < (1000 / 60)) {
|
||||||
timeStamp2 = System.currentTimeMillis();
|
timeStamp2 = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
frameCount++;
|
frameCount++;
|
||||||
timeStamp1 = System.currentTimeMillis();
|
timeStamp1 = System.currentTimeMillis();
|
||||||
acCode=10;
|
acCode = 10;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will handle the inputs recorder and have the character do a corresponding action if possible
|
* Will handle the inputs recorder and have the character do a corresponding
|
||||||
* Order of priority is Throw > Special > Normal > Jump > Dash > Crouch > Move > do nothing
|
* action if possible Order of priority is Throw > Special > Normal > Jump >
|
||||||
|
* Dash > Crouch > Move > do nothing
|
||||||
|
*
|
||||||
* @param c
|
* @param c
|
||||||
* @param input
|
* @param input
|
||||||
*/
|
*/
|
||||||
private static void handleInputs(Character c, InputBuffer input) {
|
private static void handleInputs(Character c, InputBuffer input) {
|
||||||
Inputs latestIn = input.getLatestInputs();
|
Inputs latestIn = input.getLatestInputs();
|
||||||
boolean actionSet = false;
|
boolean actionSet = false;
|
||||||
if(latestIn.containsButtonTab(c.getNormalthrow().getCommand()[0]) && c.getCurrentframe().isNormalCancellable()) {
|
if (latestIn.containsButtonTab(c.getNormalthrow().getCommand()[0])
|
||||||
|
&& c.getCurrentframe().isNormalCancellable()) {
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
c.addNextFramesList(c.getNormalthrow().getFrame());
|
c.addNextFramesList(c.getNormalthrow().getFrame());
|
||||||
actionSet = true;
|
actionSet = true;
|
||||||
} else {
|
} else {
|
||||||
int atkCount = 0;
|
int atkCount = 0;
|
||||||
//do an attack if possible
|
// do an attack if possible
|
||||||
while(atkCount < c.getAttacks().length && !actionSet) {
|
while (atkCount < c.getAttacks().length && !actionSet) {
|
||||||
Attack atk = c.getAttacks()[atkCount];
|
Attack atk = c.getAttacks()[atkCount];
|
||||||
Boolean attackIsPossible = input.commandRecognized(atk.getCommand())
|
Boolean attackIsPossible = input.commandRecognized(atk.getCommand())
|
||||||
&& atk.getRequiredStatus().equals(c.getStatus())
|
&& atk.getRequiredStatus().equals(c.getStatus())
|
||||||
&& ((atk.isSpecial() && c.getCurrentframe().isSpecialCancellable())
|
&& ((atk.isSpecial() && c.getCurrentframe().isSpecialCancellable())
|
||||||
|| (!atk.isSpecial() && c.getCurrentframe().isNormalCancellable()));
|
|| (!atk.isSpecial() && c.getCurrentframe().isNormalCancellable()));
|
||||||
if(attackIsPossible) {
|
if (attackIsPossible) {
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
c.addNextFramesList(atk.getFrame());
|
c.addNextFramesList(atk.getFrame());
|
||||||
c.setAttackPartsArray(atk.getParts());
|
c.setAttackPartsArray(atk.getParts());
|
||||||
@ -328,7 +383,7 @@ public class match {
|
|||||||
}
|
}
|
||||||
atkCount++;
|
atkCount++;
|
||||||
}
|
}
|
||||||
if(c.getCurrentframe().isJumpCancellable() && !actionSet) {
|
if (c.getCurrentframe().isJumpCancellable() && !actionSet) {
|
||||||
if (input.commandRecognized(c.getForwardJump().getCommand())) {
|
if (input.commandRecognized(c.getForwardJump().getCommand())) {
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
c.addNextFramesList(c.getForwardJump().getFrame());
|
c.addNextFramesList(c.getForwardJump().getFrame());
|
||||||
@ -346,7 +401,7 @@ public class match {
|
|||||||
c.setStatus(Status.JUMPING);
|
c.setStatus(Status.JUMPING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c.getCurrentframe().isDashCancellable() && !actionSet) {
|
if (c.getCurrentframe().isDashCancellable() && !actionSet) {
|
||||||
if (input.commandRecognized(c.getForwardDash().getCommand())) {
|
if (input.commandRecognized(c.getForwardDash().getCommand())) {
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
c.addNextFramesList(c.getForwardDash().getFrame());
|
c.addNextFramesList(c.getForwardDash().getFrame());
|
||||||
@ -357,14 +412,15 @@ public class match {
|
|||||||
actionSet = true;
|
actionSet = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(c.getCurrentframe().isMoveCancellable() && !actionSet) {
|
if (c.getCurrentframe().isMoveCancellable() && !actionSet) {
|
||||||
if(input.getLatestInputs().containsInput(ButtonIG.DOWN)) {
|
if (input.getLatestInputs().containsInput(ButtonIG.DOWN)) {
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
c.addNextFrames(c.getDefaultCrouchingFrames());
|
c.addNextFrames(c.getDefaultCrouchingFrames());
|
||||||
} else if(input.getLatestInputs().containsInput(ButtonIG.BACK)) {
|
} else if (input.getLatestInputs().containsInput(ButtonIG.BACK)) {
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
c.addNextFrames(c.getBackWalkFrames());
|
c.addNextFrames(c.getBackWalkFrames());
|
||||||
} if(input.getLatestInputs().containsInput(ButtonIG.FORWARD)) {
|
}
|
||||||
|
if (input.getLatestInputs().containsInput(ButtonIG.FORWARD)) {
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
c.addNextFrames(c.getForwardWalkFrames());
|
c.addNextFrames(c.getForwardWalkFrames());
|
||||||
}
|
}
|
||||||
@ -372,28 +428,30 @@ public class match {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void handleThrows(Character p1, Character p2) {
|
private static void handleThrows(Character p1, Character p2) {
|
||||||
ArrayList<Active_throw_Hitbox> activeP1 = new ArrayList<Active_throw_Hitbox>(p1.getCurrentframe().getActThrowHitBox());
|
ArrayList<Active_throw_Hitbox> activeP1 = new ArrayList<Active_throw_Hitbox>(
|
||||||
ArrayList<Passive_throw_HitBox> passiveP2 = new ArrayList<Passive_throw_HitBox>(p2.getCurrentframe().getPassThrowHitBox());
|
p1.getCurrentframe().getActThrowHitBox());
|
||||||
|
ArrayList<Passive_throw_HitBox> passiveP2 = new ArrayList<Passive_throw_HitBox>(
|
||||||
|
p2.getCurrentframe().getPassThrowHitBox());
|
||||||
ArrayList<ThrowPart> tP = new ArrayList<ThrowPart>(p1.getNextThrowParts());
|
ArrayList<ThrowPart> tP = new ArrayList<ThrowPart>(p1.getNextThrowParts());
|
||||||
ThrowPart hit = new ThrowPart(tP.get(0).getFrames());
|
ThrowPart hit = new ThrowPart(tP.get(0).getFrames());
|
||||||
hit.clone(tP.get(0));
|
hit.clone(tP.get(0));
|
||||||
for(Active_throw_Hitbox atH : activeP1) {
|
for (Active_throw_Hitbox atH : activeP1) {
|
||||||
for(Passive_throw_HitBox ptH : passiveP2) {
|
for (Passive_throw_HitBox ptH : passiveP2) {
|
||||||
if(!hit.hasHit()){
|
if (!hit.hasHit()) {
|
||||||
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
||||||
boolean touchH = (p1LooksRight && (atH.getPosX()+p1.getPosX()+ atH.getSize_x() > ptH.getPosX()+p2.getPosX()+ptH.getSize_x())
|
boolean touchH = (p1LooksRight && (atH.getPosX() + p1.getPosX() + atH.getSize_x() > ptH.getPosX()
|
||||||
&& (atH.getPosX() < ptH.getPosX()))
|
+ p2.getPosX() + ptH.getSize_x()) && (atH.getPosX() < ptH.getPosX()))
|
||||||
|| (!p1LooksRight && (atH.getPosX()+p1.getPosX()+ atH.getSize_x() < ptH.getPosX()+p2.getPosX()+ptH.getSize_x())
|
|| (!p1LooksRight && (atH.getPosX() + p1.getPosX() + atH.getSize_x() < ptH.getPosX()
|
||||||
&& (atH.getPosX() > ptH.getPosX()));
|
+ p2.getPosX() + ptH.getSize_x()) && (atH.getPosX() > ptH.getPosX()));
|
||||||
|
|
||||||
boolean touchV = (atH.getPosY() - atH.getSize_y() < ptH.getPosY()) && (atH.getPosY() > ptH.getPosY() - ptH.getSize_y());
|
boolean touchV = (atH.getPosY() - atH.getSize_y() < ptH.getPosY())
|
||||||
if(touchH && touchV) {
|
&& (atH.getPosY() > ptH.getPosY() - ptH.getSize_y());
|
||||||
|
if (touchH && touchV) {
|
||||||
hit.setHasHit(true);
|
hit.setHasHit(true);
|
||||||
tP.set(0,hit);
|
tP.set(0, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -403,6 +461,7 @@ public class match {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* handles the if the first character hits the second one
|
* handles the if the first character hits the second one
|
||||||
|
*
|
||||||
* @param p1 the character whose hits to handle
|
* @param p1 the character whose hits to handle
|
||||||
* @param p2 the character who is or isn't hit
|
* @param p2 the character who is or isn't hit
|
||||||
* @param inputsP2 the inputs of the player 2, used to see if they're guarding
|
* @param inputsP2 the inputs of the player 2, used to see if they're guarding
|
||||||
@ -413,20 +472,21 @@ public class match {
|
|||||||
ArrayList<attackPart> aP = new ArrayList<attackPart>(p1.getNextAttackParts());
|
ArrayList<attackPart> aP = new ArrayList<attackPart>(p1.getNextAttackParts());
|
||||||
attackPart hit = new attackPart(aP.get(0).getFrames());
|
attackPart hit = new attackPart(aP.get(0).getFrames());
|
||||||
hit.clone(aP.get(0));
|
hit.clone(aP.get(0));
|
||||||
for(Active_HitBox aH : activeP1) {
|
for (Active_HitBox aH : activeP1) {
|
||||||
for(Passive_HitBox pH : passiveP2) {
|
for (Passive_HitBox pH : passiveP2) {
|
||||||
if(!hit.hasHit()){
|
if (!hit.hasHit()) {
|
||||||
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
||||||
boolean touchH = (p1LooksRight && (aH.getPosX()+p1.getPosX()+ aH.getSize_x() > pH.getPosX()+p2.getPosX()+pH.getSize_x())
|
boolean touchH = (p1LooksRight && (aH.getPosX() + p1.getPosX() + aH.getSize_x() > pH.getPosX()
|
||||||
&& (aH.getPosX() < pH.getPosX()))
|
+ p2.getPosX() + pH.getSize_x()) && (aH.getPosX() < pH.getPosX()))
|
||||||
|| (!p1LooksRight && (aH.getPosX()+p1.getPosX()+ aH.getSize_x() < pH.getPosX()+p2.getPosX()+pH.getSize_x())
|
|| (!p1LooksRight && (aH.getPosX() + p1.getPosX() + aH.getSize_x() < pH.getPosX()
|
||||||
&& (aH.getPosX() > pH.getPosX()));
|
+ p2.getPosX() + pH.getSize_x()) && (aH.getPosX() > pH.getPosX()));
|
||||||
|
|
||||||
boolean touchV = (aH.getPosY() - aH.getSize_y() < pH.getPosY()) && (aH.getPosY() > pH.getPosY() - pH.getSize_y());
|
boolean touchV = (aH.getPosY() - aH.getSize_y() < pH.getPosY())
|
||||||
if(touchH && touchV) {
|
&& (aH.getPosY() > pH.getPosY() - pH.getSize_y());
|
||||||
getHit(p2,hit,inputsP2.getLatestInputs());
|
if (touchH && touchV) {
|
||||||
|
getHit(p2, hit, inputsP2.getLatestInputs());
|
||||||
hit.setHasHit(true);
|
hit.setHasHit(true);
|
||||||
aP.set(0,hit);
|
aP.set(0, hit);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -436,32 +496,35 @@ public class match {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles a character getting hit by an attack part.
|
* Handles a character getting hit by an attack part.
|
||||||
|
*
|
||||||
* @param c the character that's getting hit
|
* @param c the character that's getting hit
|
||||||
* @param aP the attackPart hitting the character
|
* @param aP the attackPart hitting the character
|
||||||
* @param inputs the current inputs of c
|
* @param inputs the current inputs of c
|
||||||
*/
|
*/
|
||||||
private static void getHit(Character c, attackPart aP, Inputs inputs) {
|
private static void getHit(Character c, attackPart aP, Inputs inputs) {
|
||||||
boolean getsHit = (c.getStatus() == Status.JUMPING) || (c.getStatus() == Status.HITINAIR) || (c.getStatus() == Status.FALLING)
|
boolean getsHit = (c.getStatus() == Status.JUMPING) || (c.getStatus() == Status.HITINAIR)
|
||||||
|| inputs.containsInput(ButtonIG.BACK)
|
|| (c.getStatus() == Status.FALLING) || inputs.containsInput(ButtonIG.BACK)
|
||||||
|| (aP.isLow() && !inputs.containsInput(ButtonIG.DOWN))
|
|| (aP.isLow() && !inputs.containsInput(ButtonIG.DOWN))
|
||||||
|| (aP.isOverHead() && inputs.containsInput(ButtonIG.DOWN));
|
|| (aP.isOverHead() && inputs.containsInput(ButtonIG.DOWN));
|
||||||
Frame[] nextFrames;
|
Frame[] nextFrames;
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
if(getsHit) {
|
if (getsHit) {
|
||||||
switch (c.getStatus()) {
|
switch (c.getStatus()) {
|
||||||
case JUMPING: case HITINAIR: case FALLING :
|
case JUMPING:
|
||||||
|
case HITINAIR:
|
||||||
|
case FALLING:
|
||||||
|
|
||||||
nextFrames = new Frame[20];
|
nextFrames = new Frame[20];
|
||||||
for(int i = 0; i < nextFrames.length; i++) {
|
for (int i = 0; i < nextFrames.length; i++) {
|
||||||
nextFrames[i] = c.getHitInAirFrame();
|
nextFrames[i] = c.getHitInAirFrame();
|
||||||
}
|
}
|
||||||
c.addNextFrames(nextFrames);
|
c.addNextFrames(nextFrames);
|
||||||
c.reduceHP(aP.getDamage());
|
c.reduceHP(aP.getDamage());
|
||||||
c.setStatus(Status.HITINAIR);
|
c.setStatus(Status.HITINAIR);
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
c.clearNextFrames();
|
c.clearNextFrames();
|
||||||
if(!aP.knocksDown()) {
|
if (!aP.knocksDown()) {
|
||||||
nextFrames = new Frame[aP.getHitstun()];
|
nextFrames = new Frame[aP.getHitstun()];
|
||||||
if (inputs.containsInput(ButtonIG.DOWN)) {
|
if (inputs.containsInput(ButtonIG.DOWN)) {
|
||||||
for (int i = 0; i < nextFrames.length; i++) {
|
for (int i = 0; i < nextFrames.length; i++) {
|
||||||
@ -484,12 +547,12 @@ public class match {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nextFrames = new Frame[aP.getBlockstun()];
|
nextFrames = new Frame[aP.getBlockstun()];
|
||||||
if(inputs.containsInput(ButtonIG.DOWN)) {
|
if (inputs.containsInput(ButtonIG.DOWN)) {
|
||||||
for(int i = 0; i < nextFrames.length; i++) {
|
for (int i = 0; i < nextFrames.length; i++) {
|
||||||
nextFrames[i] = c.getCrouchGuardFrame();
|
nextFrames[i] = c.getCrouchGuardFrame();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for(int i = 0; i < nextFrames.length; i++) {
|
for (int i = 0; i < nextFrames.length; i++) {
|
||||||
nextFrames[i] = c.getStandGuardFrame();
|
nextFrames[i] = c.getStandGuardFrame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -500,38 +563,47 @@ public class match {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the character to its next logical frame
|
* Sets the character to its next logical frame
|
||||||
|
*
|
||||||
* @param c the character
|
* @param c the character
|
||||||
* @param in the input buffer corresponding to the character
|
* @param in the input buffer corresponding to the character
|
||||||
*/
|
*/
|
||||||
private static void nextFrame(Character c, InputBuffer in) {
|
private static void nextFrame(Character c, InputBuffer in) {
|
||||||
try {
|
try {
|
||||||
//if(!c.getFrames().getNextframe().equals(null)){
|
// if(!c.getFrames().getNextframe().equals(null)){
|
||||||
c.goToNextFrames();
|
c.goToNextFrames();
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
switch(c.getStatus()) {
|
switch (c.getStatus()) {
|
||||||
case FALLING:case HITINAIR:
|
case FALLING:
|
||||||
if(c.getPosY() > groundLevel){
|
case HITINAIR:
|
||||||
|
if (c.getPosY() > groundLevel) {
|
||||||
c.setStatus(Status.FALLING);
|
c.setStatus(Status.FALLING);
|
||||||
c.setCurrentFrame(c.getFallingframe());
|
c.setCurrentFrame(c.getFallingframe());
|
||||||
} else {
|
} else {
|
||||||
c.setPos(c.getPosX(),groundLevel);
|
c.setPos(c.getPosX(), groundLevel);
|
||||||
c.setStatus(Status.KNOCKEDDOWN);
|
c.setStatus(Status.KNOCKEDDOWN);
|
||||||
c.addNextFrames(c.getKnockedDownFrames());
|
c.addNextFrames(c.getKnockedDownFrames());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
c.setStatus(Status.NORMAL);
|
c.setStatus(Status.NORMAL);
|
||||||
if(in.getLatestInputs().containsInput(ButtonIG.DOWN)) {
|
if (in.getLatestInputs().containsInput(ButtonIG.DOWN)) {
|
||||||
c.addNextFrames(c.getDefaultCrouchingFrames());
|
c.addNextFrames(c.getDefaultCrouchingFrames());
|
||||||
} else {c.addNextFrames(c.getDefaultStandingFrames());}
|
} else {
|
||||||
|
c.addNextFrames(c.getDefaultStandingFrames());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updatePos(Character c, boolean looksRight) {
|
private static void updatePos(Character c, boolean looksRight) {
|
||||||
if(looksRight) {c.setPos((int)(c.getPosX()+c.getCurrentframe().getMove_x()),(int)(c.getPosY()+c.getCurrentframe().getMove_y()));}
|
if (looksRight) {
|
||||||
else {c.setPos((int)(c.getPosX()-c.getCurrentframe().getMove_x()),(int)(c.getPosY()+c.getCurrentframe().getMove_y()));}
|
c.setPos((int) (c.getPosX() + c.getCurrentframe().getMove_x()),
|
||||||
|
(int) (c.getPosY() + c.getCurrentframe().getMove_y()));
|
||||||
|
} else {
|
||||||
|
c.setPos((int) (c.getPosX() - c.getCurrentframe().getMove_x()),
|
||||||
|
(int) (c.getPosY() + c.getCurrentframe().getMove_y()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user