|
|
|
@@ -31,6 +31,10 @@ public class match {
|
|
|
|
|
private int hpP1, hpP2;
|
|
|
|
|
private int roundsWonP1, roundsWonP2;
|
|
|
|
|
private Character p1, p2; //characters of player 1 and 2
|
|
|
|
|
|
|
|
|
|
private static long timeStamp1;
|
|
|
|
|
private static long timeStamp2;
|
|
|
|
|
private static int frameCount;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* base constructor of the match class.
|
|
|
|
@@ -48,6 +52,37 @@ public class match {
|
|
|
|
|
this.roundsWonP2 = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Starts a new round, by placing the timer back at base value, characters back at full hp and such.
|
|
|
|
|
*/
|
|
|
|
|
private void startNewRound() {
|
|
|
|
|
this.timer = 99;
|
|
|
|
|
this.inputsP1 = new InputBuffer(inputBufferSize);
|
|
|
|
|
this.inputsP2 = new InputBuffer(inputBufferSize);
|
|
|
|
|
this.hpP1 = p1.getMaxHP();
|
|
|
|
|
this.hpP2 = p2.getMaxHP();
|
|
|
|
|
this.p1.setPos(-500, 250); //TODO : change to better values if needed
|
|
|
|
|
this.p2.setPos(500, 250); //TODO : change to better values if needed
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Ends the round.
|
|
|
|
|
* Used for playing animations and such.
|
|
|
|
|
* TODO : Implement this once we know what to do.
|
|
|
|
|
*/
|
|
|
|
|
private void endRound() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Ends the match.
|
|
|
|
|
* Used for playing animations and such.
|
|
|
|
|
* TODO : Implement this once we know what to do.
|
|
|
|
|
*/
|
|
|
|
|
private void endMatch() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
/*
|
|
|
|
|
Engine engine = new Engine(800, 600, 3.0f / 4.0f);
|
|
|
|
@@ -110,30 +145,56 @@ public class match {
|
|
|
|
|
nextFrame = false;
|
|
|
|
|
if (engine.shouldClose()) engine.setRunning(false);
|
|
|
|
|
} */
|
|
|
|
|
long framestart = System.currentTimeMillis();
|
|
|
|
|
long frameend = System.currentTimeMillis();
|
|
|
|
|
int frame = 0;
|
|
|
|
|
boolean goToNextFrame = true;
|
|
|
|
|
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
|
|
|
|
GamepadInput gamepad1 = null;
|
|
|
|
|
match match = new match(new Character(),new Character());
|
|
|
|
|
|
|
|
|
|
match match = new match(new Character(),new Character()); //TOD0 : Change to not empty chars
|
|
|
|
|
|
|
|
|
|
if (Joystick1Present) {
|
|
|
|
|
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
|
|
|
|
gamepad1.inputRefresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(goToNextFrame) {
|
|
|
|
|
framestart = System.currentTimeMillis();
|
|
|
|
|
frame++;
|
|
|
|
|
gamepad1.inputRefresh();
|
|
|
|
|
match.inputsP1.recordInputsFromGamepad(gamepad1);
|
|
|
|
|
System.out.println("Frame " + frame + " " + match.inputsP1.getLatestInputs().toString());
|
|
|
|
|
frameend = System.currentTimeMillis();
|
|
|
|
|
while(frameend-framestart < (1000/60)) {
|
|
|
|
|
frameend = System.currentTimeMillis();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ac(int i) {
|
|
|
|
|
switch (i) {
|
|
|
|
|
|
|
|
|
|
//initiate a round
|
|
|
|
|
case 0 :
|
|
|
|
|
startNewRound();
|
|
|
|
|
timeStamp1 = System.currentTimeMillis();
|
|
|
|
|
frameCount = 0;
|
|
|
|
|
ac(10);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//checks if one or both of the chars are out of health
|
|
|
|
|
case 10:
|
|
|
|
|
if(this.hpP1 <= 0 && hpP2 <= 0) { ac(11);}
|
|
|
|
|
else if(this.hpP1 <= 0) { ac(12);}
|
|
|
|
|
else if(this.hpP2 <= 0) { ac(13);}
|
|
|
|
|
else { ac(20);}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//end round
|
|
|
|
|
case 11:
|
|
|
|
|
endRound();
|
|
|
|
|
if(roundsWonP1 >= 2||roundsWonP2 >= 2) { endMatch();} //TODO : will probably need to specify more
|
|
|
|
|
else{ac(0);}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//if p1 is at 0 health
|
|
|
|
|
case 12:
|
|
|
|
|
roundsWonP2++;
|
|
|
|
|
ac(11);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
//if p2 is at 0 health
|
|
|
|
|
case 13:
|
|
|
|
|
roundsWonP2++;
|
|
|
|
|
ac(11);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|