Implementation of gameplay loop, testing of afew things in match class.
This commit is contained in:
parent
621c2222c0
commit
37caf34e79
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@
|
|||||||
/.idea/
|
/.idea/
|
||||||
/.project
|
/.project
|
||||||
/jeu-de-combat.iml
|
/jeu-de-combat.iml
|
||||||
|
/pom.xml
|
||||||
|
2
pom.xml
2
pom.xml
@ -34,7 +34,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
|
|
||||||
<lwjgl.version>3.2.3</lwjgl.version>
|
<lwjgl.version>3.2.3</lwjgl.version>
|
||||||
<lwjgl.natives>natives-windows</lwjgl.natives>
|
<lwjgl.natives>natives-linux</lwjgl.natives>
|
||||||
<javafx.version>11</javafx.version>
|
<javafx.version>11</javafx.version>
|
||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -27,5 +27,5 @@ public class Character extends Entity {
|
|||||||
this.maxHP = HP;
|
this.maxHP = HP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHP() { return this.getMaxHP();}
|
public int getMaxHP() { return this.maxHP;}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,10 @@ public class match {
|
|||||||
private int roundsWonP1, roundsWonP2;
|
private int roundsWonP1, roundsWonP2;
|
||||||
private Character p1, p2; //characters of player 1 and 2
|
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.
|
* base constructor of the match class.
|
||||||
* Initiates a new match with with two given characters
|
* Initiates a new match with with two given characters
|
||||||
@ -48,6 +52,37 @@ public class match {
|
|||||||
this.roundsWonP2 = 0;
|
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 {
|
public static void main(String[] args) throws Exception {
|
||||||
/*
|
/*
|
||||||
Engine engine = new Engine(800, 600, 3.0f / 4.0f);
|
Engine engine = new Engine(800, 600, 3.0f / 4.0f);
|
||||||
@ -110,30 +145,56 @@ public class match {
|
|||||||
nextFrame = false;
|
nextFrame = false;
|
||||||
if (engine.shouldClose()) engine.setRunning(false);
|
if (engine.shouldClose()) engine.setRunning(false);
|
||||||
} */
|
} */
|
||||||
long framestart = System.currentTimeMillis();
|
|
||||||
long frameend = System.currentTimeMillis();
|
|
||||||
int frame = 0;
|
int frame = 0;
|
||||||
boolean goToNextFrame = true;
|
boolean goToNextFrame = true;
|
||||||
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
||||||
GamepadInput gamepad1 = null;
|
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) {
|
if (Joystick1Present) {
|
||||||
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
||||||
gamepad1.inputRefresh();
|
gamepad1.inputRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
while(goToNextFrame) {
|
}
|
||||||
framestart = System.currentTimeMillis();
|
|
||||||
frame++;
|
private void ac(int i) {
|
||||||
gamepad1.inputRefresh();
|
switch (i) {
|
||||||
match.inputsP1.recordInputsFromGamepad(gamepad1);
|
|
||||||
System.out.println("Frame " + frame + " " + match.inputsP1.getLatestInputs().toString());
|
//initiate a round
|
||||||
frameend = System.currentTimeMillis();
|
case 0 :
|
||||||
while(frameend-framestart < (1000/60)) {
|
startNewRound();
|
||||||
frameend = System.currentTimeMillis();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user