Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a7cc1f58ca
1
game.set
Normal file
1
game.set
Normal file
@ -0,0 +1 @@
|
||||
{"game":[{"character2":"ken","character1":"ryu","fullscreen":"true","stage":"default","width":"1920","rounds":"5","height":"1080"}]}
|
2
pom.xml
2
pom.xml
@ -34,7 +34,7 @@
|
||||
<properties>
|
||||
|
||||
<lwjgl.version>3.2.3</lwjgl.version>
|
||||
<lwjgl.natives>natives-windows</lwjgl.natives>
|
||||
<lwjgl.natives>natives-linux</lwjgl.natives>
|
||||
<javafx.version>11</javafx.version>
|
||||
|
||||
</properties>
|
||||
|
@ -1,165 +1,112 @@
|
||||
package configuration;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Config {
|
||||
|
||||
// tester a la main (okay normalement mais ajouter des test)
|
||||
public static void main(String[] args) {
|
||||
int[] tempfortest = { 0, 2, 1, 1 }; // {arene/nb_joueur/perso1/perso2} 0=alatoire
|
||||
config(tempfortest);
|
||||
}
|
||||
|
||||
// les variable a configurer
|
||||
// sel1 pour savoir si on a deja selectionner le joueur 1
|
||||
|
||||
public static String arene, perso1, perso2;
|
||||
public static int nb_joueur;
|
||||
private static boolean sel1 = false;
|
||||
|
||||
/*
|
||||
* fonction config qui prend en entre un tableau d'entier chaque case
|
||||
* correspondant a une variable, et ne retourne rien mais modifie la valeur des
|
||||
* variables par des fonctions annexes
|
||||
*/
|
||||
|
||||
private static void config(int[] tab) {
|
||||
int i = 0;
|
||||
while (i < tab.length) {
|
||||
|
||||
switch (i) {
|
||||
case 0:
|
||||
SelArene(tab[i]);
|
||||
i++;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
NbJoueur(tab[i]);
|
||||
i++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
SelPerso(tab[i]);
|
||||
i++;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
SelPerso(tab[i]);
|
||||
i++;
|
||||
break;
|
||||
/*
|
||||
* case 4: ?
|
||||
*/
|
||||
|
||||
default:
|
||||
System.out.println("ERROR OUT OF BOUNDS CONFIG ARRAY");
|
||||
i = tab.length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.println(arene + " " + nb_joueur + " " + perso1 + " " + perso2 + " " + sel1);
|
||||
}
|
||||
|
||||
/*
|
||||
* fonction SelArene prend un entier en parametre et permet de choisir l'arene
|
||||
* du jeu
|
||||
*/
|
||||
|
||||
private static void SelArene(int s) {
|
||||
switch (s) {
|
||||
case 0:
|
||||
SelArene(random(1, 2));
|
||||
break;
|
||||
case 1:
|
||||
arene = "arene1.png";
|
||||
break;
|
||||
|
||||
case 2:
|
||||
arene = "arene2.png";
|
||||
break;
|
||||
|
||||
default:
|
||||
System.out.println("ERROR ARENE INEXISTANTE");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* fonction NbJoueur prend un entier en parametre et permet de determiner si un
|
||||
* bot sera necessaire
|
||||
*/
|
||||
|
||||
private static void NbJoueur(int s) {
|
||||
switch (s) {
|
||||
case 1:
|
||||
nb_joueur = 1;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
nb_joueur = 2;
|
||||
break;
|
||||
default:
|
||||
System.out.println("ERROR NUMBER OF PLAYER");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* fonction SelArene prend un entier en parametre et permet de choisir le
|
||||
* personnage en fonction du joueur
|
||||
*/
|
||||
|
||||
private static void SelPerso(int s) {
|
||||
if (sel1 == false) {
|
||||
switch (s) {
|
||||
case 0:
|
||||
SelPerso(random(1, 2));
|
||||
break;
|
||||
case 1:
|
||||
perso1 = "perso1.png";
|
||||
sel1 = true;
|
||||
break;
|
||||
case 2:
|
||||
perso1 = "perso2.png";
|
||||
sel1 = true;
|
||||
break;
|
||||
default:
|
||||
System.out.println("ERROR PERSO INEXISTANT");
|
||||
}
|
||||
} else if (sel1 == true) {
|
||||
|
||||
switch (s) {
|
||||
case 0:
|
||||
SelPerso(random(1, 2));
|
||||
break;
|
||||
|
||||
case 1:
|
||||
perso2 = "perso1.png";
|
||||
sel1 = false;
|
||||
if (perso1 == perso2) {
|
||||
perso2 = "perso1_swapcolor.png";
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
perso2 = "perso2.png";
|
||||
sel1 = false;
|
||||
if (perso1 == perso2) {
|
||||
perso2 = "perso2_swapcolor.png";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
System.out.println("ERROR PERSO INEXISTANT");
|
||||
}
|
||||
} else {
|
||||
System.out.println("ERROR SELECTION PLAYER");
|
||||
}
|
||||
}
|
||||
|
||||
// fonction nombre aleatoire entre deux borne
|
||||
private static int random(int min, int max) {
|
||||
Random random = new Random();
|
||||
int value = random.nextInt(max - 1 + min) + min;
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
package configuration;
|
||||
|
||||
import java.io.*;
|
||||
import org.json.simple.*;
|
||||
import org.json.simple.parser.*;
|
||||
|
||||
public class Config {
|
||||
|
||||
public int width, height, rounds;
|
||||
public boolean fullscreen;
|
||||
public String stage;
|
||||
public String p1, p2;
|
||||
|
||||
public Config() throws FileNotFoundException {
|
||||
parse();
|
||||
}
|
||||
|
||||
public void parse() throws FileNotFoundException {
|
||||
|
||||
// initialize the parser
|
||||
JSONParser jsonP = new JSONParser();
|
||||
try {
|
||||
// read the json document
|
||||
JSONObject jsonO = (JSONObject) jsonP.parse(new FileReader("game.set"));
|
||||
|
||||
// to print all values
|
||||
// System.out.println(jsonO.values());
|
||||
|
||||
// isolate the "test" part and print it
|
||||
// String test = (String) jsonO.get("test");
|
||||
// System.out.println("ceci est un test :" + test);
|
||||
|
||||
|
||||
JSONArray game = (JSONArray) jsonO.get("game");
|
||||
JSONObject settings = (JSONObject) game.get(0);
|
||||
|
||||
// print a case of this element
|
||||
stage = (String) settings.get("stage");
|
||||
|
||||
// nb players selection
|
||||
/* JSONArray nb_players = (JSONArray) jsonO.get("nb_players");
|
||||
System.out.println("nb_player : " + nb_players.get(1)); */
|
||||
|
||||
// character selection
|
||||
p1 = (String) settings.get("character1");
|
||||
p2 = (String) settings.get("character2");
|
||||
|
||||
height = Integer.parseInt((String) settings.get("height")); // String to int
|
||||
width = Integer.parseInt((String) settings.get("width"));
|
||||
|
||||
// fullscreen
|
||||
String fs = (String) settings.get("fullscreen");
|
||||
if (fs.equals("true")) {
|
||||
fullscreen = true;
|
||||
} else fullscreen = false;
|
||||
|
||||
// rounds
|
||||
String temprounds = (String) settings.get("rounds");
|
||||
switch (temprounds) {
|
||||
case "1": rounds = 1;
|
||||
case "3": rounds = 3;
|
||||
case "5": rounds = 5;
|
||||
default: rounds = 1;
|
||||
}
|
||||
|
||||
// button selection
|
||||
/* JSONArray allButton = (JSONArray) jsonO.get("button");
|
||||
System.out.println(allButton);
|
||||
|
||||
String up = (String) allButton.get(0);
|
||||
System.out.println("button for up is : " + up); */
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void write(int width, int height, int rounds, boolean fullscreen, String character1, String character2, String stage) throws Exception {
|
||||
|
||||
JSONObject metafile = new JSONObject();
|
||||
JSONArray array = new JSONArray();
|
||||
|
||||
JSONObject set = new JSONObject();
|
||||
set.put("width", Integer.toString(width));
|
||||
set.put("height", Integer.toString(height));
|
||||
set.put("rounds", Integer.toString(rounds));
|
||||
set.put("fullscreen", Boolean.toString(fullscreen));
|
||||
set.put("character1", character1);
|
||||
set.put("character2", character2);
|
||||
set.put("stage", stage);
|
||||
|
||||
array.add(set);
|
||||
|
||||
metafile.put("game", array);
|
||||
|
||||
try (FileWriter file = new FileWriter("game.set", false)) {
|
||||
file.write(metafile.toJSONString());
|
||||
file.close();
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,75 +0,0 @@
|
||||
package configuration;
|
||||
|
||||
import java.io.*;
|
||||
import org.json.simple.*;
|
||||
import org.json.simple.parser.*;
|
||||
|
||||
public class JsonToJava {
|
||||
|
||||
public static void main(String args[]) {
|
||||
|
||||
JsonRecover();
|
||||
|
||||
}
|
||||
|
||||
private static void JsonRecover() {
|
||||
// initialize the parser
|
||||
JSONParser jsonP = new JSONParser();
|
||||
try {
|
||||
// read the json document
|
||||
JSONObject jsonO = (JSONObject) jsonP.parse(new FileReader("src/configuration/config.json"));
|
||||
|
||||
// to print all values
|
||||
// System.out.println(jsonO.values());
|
||||
|
||||
// isolate the "test" part and print it
|
||||
// String test = (String) jsonO.get("test");
|
||||
// System.out.println("ceci est un test :" + test);
|
||||
|
||||
// arena selection
|
||||
// select an element on the list
|
||||
JSONArray arena = (JSONArray) jsonO.get("arena");
|
||||
// print a case of this element
|
||||
System.out.println("arena : " + arena.get(1));
|
||||
|
||||
// nb players selection
|
||||
JSONArray nb_players = (JSONArray) jsonO.get("nb_players");
|
||||
System.out.println("nb_player : " + nb_players.get(1));
|
||||
|
||||
// character selection
|
||||
JSONArray character1 = (JSONArray) jsonO.get("character1");
|
||||
System.out.println("players 1 : " + character1.get(1));
|
||||
|
||||
JSONArray character2 = (JSONArray) jsonO.get("character2");
|
||||
System.out.println("players 2 : " + character2.get(1));
|
||||
|
||||
// resolution
|
||||
JSONArray resolution = (JSONArray) jsonO.get("resolution");
|
||||
// resolution string " width x heigth"
|
||||
JSONObject reso = (JSONObject) resolution.get(1);
|
||||
|
||||
String heightStr = (String) reso.get("height");
|
||||
int height = Integer.parseInt(heightStr); // String to int
|
||||
|
||||
String widthStr = (String) reso.get("width");
|
||||
int width = Integer.parseInt(widthStr);
|
||||
|
||||
System.out.println("heigth : " + height + " width : " + width);
|
||||
|
||||
// button selection
|
||||
JSONArray allButton = (JSONArray) jsonO.get("button");
|
||||
System.out.println(allButton);
|
||||
|
||||
String up = (String) allButton.get(0);
|
||||
System.out.println("button for up is : " + up);
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
{
|
||||
"arena": [
|
||||
"random",
|
||||
"arena1.png",
|
||||
"arena2.png"
|
||||
],
|
||||
"nb_players": [
|
||||
"1",
|
||||
"2"
|
||||
],
|
||||
"character1": [
|
||||
"random",
|
||||
"character1.png",
|
||||
"character2.png"
|
||||
],
|
||||
"character2": [
|
||||
"random",
|
||||
"character1.png",
|
||||
"character1_swapcolor.png",
|
||||
"character2.png",
|
||||
"character2_swapcolor.png"
|
||||
],
|
||||
"resolution": [
|
||||
{
|
||||
"width": "800",
|
||||
"height": "600"
|
||||
},
|
||||
{
|
||||
"width": "1280",
|
||||
"height": "1024"
|
||||
},
|
||||
{
|
||||
"width": "1680",
|
||||
"height": "1050"
|
||||
},
|
||||
{
|
||||
"width": "1920",
|
||||
"height": "1080"
|
||||
},
|
||||
{
|
||||
"persoWidth": "800",
|
||||
"persoHeight": "600"
|
||||
}
|
||||
],
|
||||
"button": [
|
||||
"UP",
|
||||
"DOWN",
|
||||
"RIGTH",
|
||||
"LEFT",
|
||||
"A",
|
||||
"B",
|
||||
"X",
|
||||
"Y"
|
||||
]
|
||||
}
|
@ -19,7 +19,7 @@ public class TestEngine {
|
||||
/*
|
||||
OpenAl TEST
|
||||
*/
|
||||
SoundManager soundManager = new SoundManager();
|
||||
/*SoundManager soundManager = new SoundManager();
|
||||
soundManager.init();
|
||||
|
||||
SoundListener soundListener = new SoundListener();
|
||||
@ -31,7 +31,7 @@ public class TestEngine {
|
||||
soundSource.setBuffer(jumpSoundBuffer.getBufferId());
|
||||
|
||||
soundManager.addSoundSource("jump", soundSource);
|
||||
// soundManager.playSoundSource("jump");
|
||||
// soundManager.playSoundSource("jump");*/
|
||||
|
||||
/*
|
||||
Engine Init
|
||||
@ -163,7 +163,7 @@ public class TestEngine {
|
||||
if (engine.shouldClose()) engine.setRunning(false);
|
||||
}
|
||||
|
||||
soundManager.cleanup();
|
||||
//soundManager.cleanup();
|
||||
|
||||
}
|
||||
|
||||
|
352
src/gameplay/Characters/Blue/BlueBaseFrames.java
Normal file
352
src/gameplay/Characters/Blue/BlueBaseFrames.java
Normal file
@ -0,0 +1,352 @@
|
||||
package gameplay.Characters.Blue;
|
||||
|
||||
import engine.Engine;
|
||||
import engine.math.Vector3f;
|
||||
import engine.object.Hitbox;
|
||||
import engine.object.ObjectGl;
|
||||
import gameplay.frames.Frame;
|
||||
import gameplay.hitboxes.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class BlueBaseFrames {
|
||||
|
||||
private static Frame generateStandFrame1(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,0.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(0,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame generateStandFrame2(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,75,300);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,0.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(112,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
protected static Frame[] blueStandFrames() {
|
||||
Frame[] sf = {generateStandFrame1(),generateStandFrame2()};
|
||||
return sf;
|
||||
}
|
||||
|
||||
private static Frame generateCrouchFrame1(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,0.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(112,120,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
protected static Frame[] blueCrouchFrames() {
|
||||
Frame[] cF = {generateCrouchFrame1()};
|
||||
return cF;
|
||||
}
|
||||
|
||||
private static Frame generateNeutralJumpFrame1(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(-10.0,0.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,false,false,false,false,false);
|
||||
blueStandframe1.setSpriteWrap(830,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame generateNeutralJumpFrame2(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(10.0,0.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,false,false,false,false,false);
|
||||
blueStandframe1.setSpriteWrap(830,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
protected static Frame[] blueNeutralJump() {
|
||||
Frame[] jF = new Frame[40];
|
||||
for(int i = 0; i < jF.length/2; i++) {
|
||||
jF[i] = generateNeutralJumpFrame1();
|
||||
}
|
||||
for(int i = jF.length/2; i < jF.length; i++) {
|
||||
jF[i] = generateNeutralJumpFrame2();
|
||||
}
|
||||
return jF;
|
||||
}
|
||||
|
||||
private static Frame GenerateForwardJumpFrame1(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(-10.0,10.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,false,false,false,false,false);
|
||||
blueStandframe1.setSpriteWrap(750,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame GenerateForwardJumpFrame2(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(10.0,10.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,false,false,false,false,false);
|
||||
blueStandframe1.setSpriteWrap(750,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
protected static Frame[] blueForwardJump() {
|
||||
Frame[] jF = new Frame[40];
|
||||
for(int i = 0; i < jF.length/2; i++) {
|
||||
jF[i] = GenerateForwardJumpFrame1();
|
||||
}
|
||||
for(int i = jF.length/2; i < jF.length; i++) {
|
||||
jF[i] = GenerateForwardJumpFrame2();
|
||||
}
|
||||
return jF;
|
||||
}
|
||||
|
||||
private static Frame BackJumpFrame1(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(-10.0,-10.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,false,false,false,false,false);
|
||||
blueStandframe1.setSpriteWrap(750,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
protected static Frame[] blueBackJump() {
|
||||
Frame[] jF = new Frame[40];
|
||||
for(int i = 0; i < jF.length/2; i++) {
|
||||
jF[i] = BackJumpFrame1();
|
||||
}
|
||||
for(int i = jF.length/2; i < jF.length; i++) {
|
||||
jF[i] = BackJumpFrame2();
|
||||
}
|
||||
return jF;
|
||||
}
|
||||
|
||||
private static Frame BackJumpFrame2(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(10.0,-10.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,false,false,false,false,false);
|
||||
blueStandframe1.setSpriteWrap(750,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame walkForwardFrame1(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(220,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame walkForwardFrame2(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(330,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame walkForwardFrame3(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(420,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame walkForwardFrame4(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(500,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
protected static Frame[] blueFWalk() {
|
||||
Frame[] f = new Frame[4];
|
||||
f[0] = walkForwardFrame1();
|
||||
f[1] = walkForwardFrame2();
|
||||
f[2] = walkForwardFrame3();
|
||||
f[3] = walkForwardFrame4();
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
private static Frame walkBackFrame4(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,-8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(220,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame walkBackFrame3(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,-8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(330,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame walkBackFrame2(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,-8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(420,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
private static Frame walkBackFrame1(){
|
||||
Passive_HitBox bStandPHB1 = new Passive_HitBox(70,70,150,500);
|
||||
Passive_throw_HitBox bStandPTHB1 = new Passive_throw_HitBox(70,400,150,100);
|
||||
Push_HitBox bStandPB1 = new Push_HitBox(70,70,150,500);
|
||||
ArrayList<Passive_HitBox> phb = new ArrayList<Passive_HitBox>();
|
||||
ArrayList<Passive_throw_HitBox> pthb = new ArrayList<Passive_throw_HitBox>();
|
||||
phb.add(bStandPHB1);
|
||||
pthb.add(bStandPTHB1);
|
||||
Frame blueStandframe1 = new Frame(0.0,-8.0,phb,new ArrayList<Active_HitBox>(),pthb,new ArrayList<Active_throw_Hitbox>(),
|
||||
bStandPB1,true,true,true,true,true);
|
||||
blueStandframe1.setSpriteWrap(500,0,112,120);
|
||||
return blueStandframe1;
|
||||
}
|
||||
|
||||
protected static Frame[] blueBWalk() {
|
||||
Frame[] f = new Frame[4];
|
||||
f[0] = walkBackFrame1();
|
||||
f[1] = walkBackFrame2();
|
||||
f[2] = walkBackFrame3();
|
||||
f[3] = walkBackFrame4();
|
||||
return f;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
Engine engine = new Engine(640, 480, new Vector3f(4.0f, 3.0f));
|
||||
engine.init();
|
||||
|
||||
String path = "textures/Sprite.png";
|
||||
String pathToBG = "textures/background_beach.png";
|
||||
|
||||
Frame f = generateStandFrame1();
|
||||
ObjectGl blue = new ObjectGl(0f, 60f, 80f, 5f, path, null);
|
||||
blue.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
|
||||
blue.translate(new Vector3f(-750,200,0));
|
||||
int posX = -750;
|
||||
int posY = 200;
|
||||
engine.add_objectGl(blue);
|
||||
int counter = 0;
|
||||
long ts1, ts2;
|
||||
float posZ = 11;
|
||||
while(counter < 1000) {
|
||||
ts1 = System.currentTimeMillis();
|
||||
posZ = 11;
|
||||
engine.update();
|
||||
engine.render();
|
||||
counter++;
|
||||
for(Passive_HitBox h: f.getPassHitBox()){
|
||||
Hitbox hh = new Hitbox(posZ,h.getSize_x(),h.getSize_y(),5f,new Vector3f(1,0,0));
|
||||
engine.add_objectGl(hh);
|
||||
hh.translate(new Vector3f(-750+h.getPosY(),200+h.getPosY()));
|
||||
}
|
||||
blue.translate(new Vector3f(0,0,0));
|
||||
ts2 = System.currentTimeMillis();
|
||||
while(ts2-ts1 < 1000/20) {
|
||||
ts2 = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
58
src/gameplay/Characters/Blue/CharacterBlue.java
Normal file
58
src/gameplay/Characters/Blue/CharacterBlue.java
Normal file
@ -0,0 +1,58 @@
|
||||
package gameplay.Characters.Blue;
|
||||
|
||||
import gameplay.actions.*;
|
||||
import gameplay.entities.Character;
|
||||
import gameplay.frames.Frame;
|
||||
import gameplay.Characters.Blue.BlueBaseFrames;
|
||||
import gameplay.input.ButtonIG;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static gameplay.input.ButtonIG.*;
|
||||
|
||||
public class CharacterBlue {
|
||||
public static Character generateCharBlue(){
|
||||
Frame[] standF = BlueBaseFrames.blueStandFrames();
|
||||
Frame[] crouchF = BlueBaseFrames.blueCrouchFrames();
|
||||
Frame[] nJumpF = BlueBaseFrames.blueNeutralJump();
|
||||
Frame[] fJumpF = BlueBaseFrames.blueForwardJump();
|
||||
Frame[] bJumpF = BlueBaseFrames.blueBackJump();
|
||||
Frame[] fWalkF = BlueBaseFrames.blueFWalk();
|
||||
Frame[] bWalkF = BlueBaseFrames.blueBWalk();
|
||||
|
||||
ButtonIG[][] fjcmd = {{UP,FORWARD}};
|
||||
ButtonIG[][] bjcmd = {{UP,BACK}};
|
||||
ButtonIG[][] njcmd = {{UP}};
|
||||
|
||||
|
||||
Jump fJ = new Jump(fjcmd,fJumpF);
|
||||
Jump nJ = new Jump(njcmd,nJumpF);
|
||||
Jump bJ = new Jump(bjcmd,bJumpF);
|
||||
|
||||
/*
|
||||
* Temporary values to change later
|
||||
*/
|
||||
Frame[] fDashF = new Frame[0];
|
||||
Frame[] bDashF = new Frame[0];
|
||||
|
||||
ThrowPart[] tp = new ThrowPart[0];
|
||||
|
||||
ButtonIG[][] throwCMD = {{BACK,FORWARD,UP,DOWN},{BACK,FORWARD,UP,DOWN},{BACK,FORWARD,UP,DOWN}};
|
||||
ButtonIG[][] fdashCMD = {{BACK,FORWARD,UP,DOWN},{BACK,FORWARD,UP,DOWN},{BACK,FORWARD,UP,DOWN}};
|
||||
ButtonIG[][] bdashCMD = {{BACK,FORWARD,UP,DOWN},{BACK,FORWARD,UP,DOWN},{BACK,FORWARD,UP,DOWN}};
|
||||
|
||||
Throw th = new Throw(false,throwCMD,tp);
|
||||
Dash fDash = new Dash(fdashCMD,fDashF);
|
||||
Dash bDash =new Dash(bdashCMD,bDashF);
|
||||
|
||||
Frame[] fallingFs = new Frame[0];
|
||||
|
||||
Frame f = new Frame();
|
||||
|
||||
Attack[] atks = new Attack[0];
|
||||
|
||||
Character c = new Character(0,0,standF[0],1000,atks,fJ,nJ,bJ,fDash,bDash,th,standF,crouchF,fWalkF,bWalkF,f,f,fallingFs,f,f,f,f);
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
@ -10,24 +10,31 @@ public class Attack implements Action {
|
||||
/**
|
||||
* Defines if the attack is a special one (E.G. a fireball) or a normal one (a punch)
|
||||
*/
|
||||
private static boolean isSpecial;
|
||||
private boolean isSpecial;
|
||||
|
||||
private Status requiredStatus;
|
||||
|
||||
private static Status requiredStatus;
|
||||
|
||||
|
||||
/**
|
||||
* The suite of Inputs to have the move come out.
|
||||
* For example, a classic fireball would be something like
|
||||
* {{DOWN},{DOWN,RIGHT},{RIGHT},{A}}
|
||||
*/
|
||||
private static ButtonIG[][] command;
|
||||
private ButtonIG[][] command;
|
||||
|
||||
|
||||
/**
|
||||
* The different sections of the attack
|
||||
*/
|
||||
private attackPart[] parts;
|
||||
|
||||
|
||||
public Attack(boolean isSpecial, Status requiredStatus, ButtonIG[][] command, attackPart[] parts) {
|
||||
this.isSpecial = isSpecial;
|
||||
this.requiredStatus = requiredStatus;
|
||||
this.command = command;
|
||||
this.parts = parts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Frame> getFrame() {
|
||||
ArrayList<Frame> res = new ArrayList<Frame>();
|
||||
@ -47,21 +54,21 @@ public class Attack implements Action {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static boolean isIsSpecial() {
|
||||
return isSpecial;
|
||||
public boolean isIsSpecial() {
|
||||
return this.isSpecial;
|
||||
}
|
||||
|
||||
public static void setIsSpecial(boolean isSpecial) {
|
||||
Attack.isSpecial = isSpecial;
|
||||
public void setIsSpecial(boolean isSpecial) {
|
||||
this.isSpecial = isSpecial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ButtonIG[][] getCommand() {
|
||||
return command;
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public static void setCommand(ButtonIG[][] command) {
|
||||
Attack.command = command;
|
||||
public void setCommand(ButtonIG[][] command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public attackPart[] getParts() {
|
||||
@ -72,13 +79,15 @@ public class Attack implements Action {
|
||||
this.parts = parts;
|
||||
}
|
||||
|
||||
public static Status getRequiredStatus() {
|
||||
return requiredStatus;
|
||||
public Status getRequiredStatus() {
|
||||
return this.requiredStatus;
|
||||
}
|
||||
|
||||
public static void setRequiredStatus(Status requiredStatus) {
|
||||
Attack.requiredStatus = requiredStatus;
|
||||
public void setRequiredStatus(Status requiredStatus) {
|
||||
this.requiredStatus = requiredStatus;
|
||||
}
|
||||
|
||||
public boolean isSpecial() {return this.isSpecial();}
|
||||
|
||||
|
||||
}
|
||||
|
@ -11,11 +11,11 @@ public class Dash implements Action {
|
||||
* For example, a Front Dash would be something like
|
||||
* {{FORWARD},{FORWARD}}
|
||||
*/
|
||||
private static ButtonIG[][] command;
|
||||
private ButtonIG[][] command;
|
||||
|
||||
private Frame[] frames;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<Frame> getFrame() {
|
||||
ArrayList<Frame> res = new ArrayList<Frame>();
|
||||
@ -27,7 +27,11 @@ public class Dash implements Action {
|
||||
|
||||
@Override
|
||||
public ButtonIG[][] getCommand() {
|
||||
return command;
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public Dash(ButtonIG[][] command, Frame[] frames) {
|
||||
this.command = command;
|
||||
this.frames = frames;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class Jump implements Action {
|
||||
* For example, a Front Jump would be something like
|
||||
* {{UP,RIGHT}}
|
||||
*/
|
||||
private static ButtonIG[][] command;
|
||||
private ButtonIG[][] command;
|
||||
|
||||
private Frame[] frames;
|
||||
|
||||
@ -27,7 +27,11 @@ public class Jump implements Action {
|
||||
|
||||
@Override
|
||||
public ButtonIG[][] getCommand() {
|
||||
return command;
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public Jump(ButtonIG[][] command, Frame[] frames) {
|
||||
this.command = command;
|
||||
this.frames = frames;
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,14 @@ public class Throw implements Action {
|
||||
/**
|
||||
* Defines if the throw is a special one (E.G. a Moonsault Press ) or a normal one
|
||||
*/
|
||||
private static boolean isSpecial;
|
||||
private boolean isSpecial;
|
||||
|
||||
/**
|
||||
* The suite of Inputs to have the move come out.
|
||||
* For example, a Moonsault Press would be something like
|
||||
* {{LEFT},{DOWN,LEFT},{DOWN},{DOWN,RIGHT},{RIGHT},{RIGHT,UP},{UP},{A}}
|
||||
*/
|
||||
private static ButtonIG[][] command;
|
||||
private ButtonIG[][] command;
|
||||
|
||||
/**
|
||||
* The different sections of the throw
|
||||
@ -52,7 +52,20 @@ public class Throw implements Action {
|
||||
|
||||
@Override
|
||||
public ButtonIG[][] getCommand() {
|
||||
return command;
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public Throw(boolean isSpecial, ThrowPart[] parts) {
|
||||
this.isSpecial = isSpecial;
|
||||
this.parts = parts;
|
||||
}
|
||||
|
||||
public Throw() {
|
||||
}
|
||||
|
||||
public Throw(boolean isSpecial, ButtonIG[][] command, ThrowPart[] parts) {
|
||||
this.isSpecial = isSpecial;
|
||||
this.command = command;
|
||||
this.parts = parts;
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ import java.util.ArrayList;
|
||||
*
|
||||
*/
|
||||
public class Character extends Entity {
|
||||
private static int maxHP;
|
||||
private static int currentHP;
|
||||
private int maxHP;
|
||||
private int currentHP;
|
||||
|
||||
/**
|
||||
* All of the attacks, both special and normal, of the character
|
||||
@ -22,23 +22,23 @@ public class Character extends Entity {
|
||||
* For example, you should have something like :
|
||||
* {Rising Punch, FireBall, Jump D/C/B/A, Crouch D/C/B/A, Stand D/C/B/A}
|
||||
*/
|
||||
private static Attack[] attacks;
|
||||
private Attack[] attacks;
|
||||
|
||||
private static Jump forwardJump;
|
||||
private static Jump neutralJump;
|
||||
private static Jump backJump;
|
||||
private Jump forwardJump;
|
||||
private Jump neutralJump;
|
||||
private Jump backJump;
|
||||
|
||||
private static Dash forwardDash;
|
||||
private static Dash backDash;
|
||||
private Dash forwardDash;
|
||||
private Dash backDash;
|
||||
|
||||
private static Throw normalthrow;
|
||||
private Throw normalthrow;
|
||||
|
||||
private static Status status;
|
||||
private Status status;
|
||||
|
||||
private static Frame[] defaultStandingFrames;
|
||||
private static Frame[] defaultCrouchingFrames;
|
||||
private static Frame[] forwardWalkFrames;
|
||||
private static Frame[] backWalkFrames;
|
||||
private Frame[] defaultStandingFrames;
|
||||
private Frame[] defaultCrouchingFrames;
|
||||
private Frame[] forwardWalkFrames;
|
||||
private Frame[] backWalkFrames;
|
||||
private Frame hitInAirFrame; //the frame to display when hit in the air. Shouldmake the character rise
|
||||
private Frame fallingframe; //the frame to display when falling from the air
|
||||
private Frame[] knockedDownFrames;
|
||||
@ -67,111 +67,137 @@ public class Character extends Entity {
|
||||
this.currentHP = this.maxHP;
|
||||
}
|
||||
|
||||
|
||||
public Character(int posx, int posy, Frame f, int maxHP, Attack[] attacks, Jump forwardJump, Jump neutralJump, Jump backJump, Dash forwardDash, Dash backDash, Throw normalthrow, Frame[] defaultStandingFrames, Frame[] defaultCrouchingFrames, Frame[] forwardWalkFrames, Frame[] backWalkFrames, Frame hitInAirFrame, Frame fallingframe, Frame[] knockedDownFrames, Frame standGuardFrame, Frame crouchGuardFrame, Frame standHitFrame, Frame crouchHitFrame) {
|
||||
super(posx, posy, f);
|
||||
this.maxHP = maxHP;
|
||||
this.attacks = attacks;
|
||||
this.forwardJump = forwardJump;
|
||||
this.neutralJump = neutralJump;
|
||||
this.backJump = backJump;
|
||||
this.forwardDash = forwardDash;
|
||||
this.backDash = backDash;
|
||||
this.normalthrow = normalthrow;
|
||||
this.defaultStandingFrames = defaultStandingFrames;
|
||||
this.defaultCrouchingFrames = defaultCrouchingFrames;
|
||||
this.forwardWalkFrames = forwardWalkFrames;
|
||||
this.backWalkFrames = backWalkFrames;
|
||||
this.hitInAirFrame = hitInAirFrame;
|
||||
this.fallingframe = fallingframe;
|
||||
this.knockedDownFrames = knockedDownFrames;
|
||||
this.standGuardFrame = standGuardFrame;
|
||||
this.crouchGuardFrame = crouchGuardFrame;
|
||||
this.standHitFrame = standHitFrame;
|
||||
this.crouchHitFrame = crouchHitFrame;
|
||||
this.nextAttackParts = new ArrayList<attackPart>();
|
||||
this.nextThrowParts = new ArrayList<ThrowPart>();
|
||||
this.currentHP = maxHP;
|
||||
this.status = Status.NORMAL;
|
||||
}
|
||||
|
||||
public void setMaxHP(int HP) {
|
||||
this.maxHP = HP;
|
||||
}
|
||||
|
||||
public int getMaxHP() { return this.maxHP;}
|
||||
|
||||
public static Attack[] getAttacks() {
|
||||
return attacks;
|
||||
public Attack[] getAttacks() {
|
||||
return this.attacks;
|
||||
}
|
||||
|
||||
public static void setAttacks(Attack[] attacks) {
|
||||
Character.attacks = attacks;
|
||||
public void setAttacks(Attack[] attacks) {
|
||||
this.attacks = attacks;
|
||||
}
|
||||
|
||||
public static Jump getForwardJump() {
|
||||
return forwardJump;
|
||||
public Jump getForwardJump() {
|
||||
return this.forwardJump;
|
||||
}
|
||||
|
||||
public static void setForwardJump(Jump forwardJump) {
|
||||
Character.forwardJump = forwardJump;
|
||||
public void setForwardJump(Jump forwardJump) {
|
||||
this.forwardJump = forwardJump;
|
||||
}
|
||||
|
||||
public static Jump getNeutralJump() {
|
||||
return neutralJump;
|
||||
public Jump getNeutralJump() {
|
||||
return this.neutralJump;
|
||||
}
|
||||
|
||||
public static void setNeutralJump(Jump neutralJump) {
|
||||
Character.neutralJump = neutralJump;
|
||||
public void setNeutralJump(Jump neutralJump) {
|
||||
this.neutralJump = neutralJump;
|
||||
}
|
||||
|
||||
public static Jump getBackJump() {
|
||||
return backJump;
|
||||
public Jump getBackJump() {
|
||||
return this.backJump;
|
||||
}
|
||||
|
||||
public static void setBackJump(Jump backJump) {
|
||||
Character.backJump = backJump;
|
||||
public void setBackJump(Jump backJump) {
|
||||
this.backJump = backJump;
|
||||
}
|
||||
|
||||
public static Dash getForwardDash() {
|
||||
return forwardDash;
|
||||
public Dash getForwardDash() {
|
||||
return this.forwardDash;
|
||||
}
|
||||
|
||||
public static void setForwardDash(Dash forwardDash) {
|
||||
Character.forwardDash = forwardDash;
|
||||
public void setForwardDash(Dash forwardDash) {
|
||||
this.forwardDash = forwardDash;
|
||||
}
|
||||
|
||||
public static Dash getBackDash() {
|
||||
return backDash;
|
||||
public Dash getBackDash() {
|
||||
return this.backDash;
|
||||
}
|
||||
|
||||
public static void setBackDash(Dash backDash) {
|
||||
Character.backDash = backDash;
|
||||
public void setBackDash(Dash backDash) {
|
||||
this.backDash = backDash;
|
||||
}
|
||||
|
||||
public static Throw getNormalthrow() {
|
||||
return normalthrow;
|
||||
public Throw getNormalthrow() {
|
||||
return this.normalthrow;
|
||||
}
|
||||
|
||||
public static void setNormalthrow(Throw normalthrow) {
|
||||
Character.normalthrow = normalthrow;
|
||||
public void setNormalthrow(Throw normalthrow) {
|
||||
this.normalthrow = normalthrow;
|
||||
}
|
||||
|
||||
public static Status getStatus() {
|
||||
return status;
|
||||
public Status getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
public static void setStatus(Status status) {
|
||||
Character.status = status;
|
||||
public void setStatus(Status status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public static Frame[] getDefaultStandingFrames() {
|
||||
return defaultStandingFrames;
|
||||
public Frame[] getDefaultStandingFrames() {
|
||||
return this.defaultStandingFrames;
|
||||
}
|
||||
|
||||
public static void setDefaultStandingFrames(Frame[] defaultStandingFrames) {
|
||||
Character.defaultStandingFrames = defaultStandingFrames;
|
||||
public void setDefaultStandingFrames(Frame[] defaultStandingFrames) {
|
||||
this.defaultStandingFrames = defaultStandingFrames;
|
||||
}
|
||||
|
||||
public static Frame[] getDefaultCrouchingFrames() {
|
||||
return defaultCrouchingFrames;
|
||||
public Frame[] getDefaultCrouchingFrames() {
|
||||
return this.defaultCrouchingFrames;
|
||||
}
|
||||
|
||||
public static void setDefaultCrouchingFrames(Frame[] defaultCrouchingFrames) {
|
||||
Character.defaultCrouchingFrames = defaultCrouchingFrames;
|
||||
public void setDefaultCrouchingFrames(Frame[] defaultCrouchingFrames) {
|
||||
this.defaultCrouchingFrames = defaultCrouchingFrames;
|
||||
}
|
||||
|
||||
public static Frame[] getForwardWalkFrames() {
|
||||
return forwardWalkFrames;
|
||||
public Frame[] getForwardWalkFrames() {
|
||||
return this.forwardWalkFrames;
|
||||
}
|
||||
|
||||
public static void setForwardWalkFrames(Frame[] forwardWalkFrames) {
|
||||
Character.forwardWalkFrames = forwardWalkFrames;
|
||||
public void setForwardWalkFrames(Frame[] forwardWalkFrames) {
|
||||
this.forwardWalkFrames = forwardWalkFrames;
|
||||
}
|
||||
|
||||
public static Frame[] getBackWalkFrames() {
|
||||
return backWalkFrames;
|
||||
public Frame[] getBackWalkFrames() {
|
||||
return this.backWalkFrames;
|
||||
}
|
||||
|
||||
public static void setBackWalkFrames(Frame[] backWalkFrames) {
|
||||
Character.backWalkFrames = backWalkFrames;
|
||||
public void setBackWalkFrames(Frame[] backWalkFrames) {
|
||||
this.backWalkFrames = backWalkFrames;
|
||||
}
|
||||
|
||||
public ArrayList<attackPart> getNextAttackParts() {
|
||||
return nextAttackParts;
|
||||
return this.nextAttackParts;
|
||||
}
|
||||
|
||||
public void setNextAttackParts(ArrayList<attackPart> nextAttackParts) {
|
||||
@ -194,7 +220,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public ArrayList<ThrowPart> getNextThrowParts() {
|
||||
return nextThrowParts;
|
||||
return this.nextThrowParts;
|
||||
}
|
||||
|
||||
public void setNextThrowParts(ArrayList<ThrowPart> nextAttackParts) {
|
||||
@ -216,8 +242,8 @@ public class Character extends Entity {
|
||||
this.nextThrowParts.remove(0);
|
||||
}
|
||||
|
||||
public static int getCurrentHP() {
|
||||
return currentHP;
|
||||
public int getCurrentHP() {
|
||||
return this.currentHP;
|
||||
}
|
||||
|
||||
public void setCurrentHP(int currentHP) {
|
||||
@ -240,7 +266,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public Frame getHitInAirFrame() {
|
||||
return hitInAirFrame;
|
||||
return this.hitInAirFrame;
|
||||
}
|
||||
|
||||
public void setHitInAirFrame(Frame hitInAirFrame) {
|
||||
@ -248,7 +274,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public Frame getFallingframe() {
|
||||
return fallingframe;
|
||||
return this.fallingframe;
|
||||
}
|
||||
|
||||
public void setFallingframe(Frame fallingframe) {
|
||||
@ -256,7 +282,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public Frame[] getKnockedDownFrames() {
|
||||
return knockedDownFrames;
|
||||
return this.knockedDownFrames;
|
||||
}
|
||||
|
||||
public void setKnockedDownFrames(Frame[] knockedDownFrames) {
|
||||
@ -264,7 +290,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public Frame getStandGuardFrame() {
|
||||
return standGuardFrame;
|
||||
return this.standGuardFrame;
|
||||
}
|
||||
|
||||
public void setStandGuardFrame(Frame standGuardFrame) {
|
||||
@ -272,7 +298,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public Frame getCrouchGuardFrame() {
|
||||
return crouchGuardFrame;
|
||||
return this.crouchGuardFrame;
|
||||
}
|
||||
|
||||
public void setCrouchGuardFrame(Frame crouchGuardFrame) {
|
||||
@ -280,7 +306,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public Frame getStandHitFrame() {
|
||||
return standHitFrame;
|
||||
return this.standHitFrame;
|
||||
}
|
||||
|
||||
public void setStandHitFrame(Frame standHitFrame) {
|
||||
@ -288,7 +314,7 @@ public class Character extends Entity {
|
||||
}
|
||||
|
||||
public Frame getCrouchHitFrame() {
|
||||
return crouchHitFrame;
|
||||
return this.crouchHitFrame;
|
||||
}
|
||||
|
||||
public void setCrouchHitFrame(Frame crouchHitFrame) {
|
||||
|
@ -2,6 +2,7 @@ package gameplay.frames;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import engine.graphics.Texture;
|
||||
import gameplay.hitboxes.*;
|
||||
|
||||
/**
|
||||
@ -24,6 +25,10 @@ public class Frame {
|
||||
private boolean moveCancellable;
|
||||
private boolean isDashCancellable;
|
||||
private boolean lastFrameOfHit;
|
||||
/**
|
||||
* an int of 4 that determines the texture wrap for the frame
|
||||
*/
|
||||
private int[] sprite;
|
||||
|
||||
public Frame() {
|
||||
this.setMove_y(0.0);
|
||||
@ -39,6 +44,7 @@ public class Frame {
|
||||
this.moveCancellable = true;
|
||||
this.isDashCancellable = true;
|
||||
this.lastFrameOfHit = false;
|
||||
this.sprite = new int[4];
|
||||
}
|
||||
|
||||
public Frame(Double move_y, Double move_x, ArrayList<Passive_HitBox> passHitBox, ArrayList<Active_HitBox> actHitBox,
|
||||
@ -58,6 +64,7 @@ public class Frame {
|
||||
this.moveCancellable = moveCancellable;
|
||||
this.isDashCancellable = isDashCancellable;
|
||||
this.lastFrameOfHit = false;
|
||||
this.sprite = new int[4];
|
||||
}
|
||||
|
||||
/*
|
||||
@ -179,6 +186,25 @@ public class Frame {
|
||||
this.jumpCancellable = f.jumpCancellable;
|
||||
this.moveCancellable = f.isMoveCancellable();
|
||||
this.isDashCancellable = f.isDashCancellable;
|
||||
this.lastFrameOfHit = islastFrameOfHit();
|
||||
this.lastFrameOfHit = f.islastFrameOfHit();
|
||||
this.setSpriteWrap(f.sprite[0], f.sprite[1], f.sprite[2], f.sprite[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the coordinates on the spritesheet for the texture for that frame
|
||||
* @param x coordinate of the lef tside
|
||||
* @param y coordonate of the top
|
||||
* @param sizeH horizontal size of the sprite
|
||||
* @param sizeV horizontal size of the sprite
|
||||
*/
|
||||
public void setSpriteWrap(int x, int y, int sizeH, int sizeV) {
|
||||
this.sprite[0] = x;
|
||||
this.sprite[1] = y;
|
||||
this.sprite[2] = sizeH;
|
||||
this.sprite[3] = sizeV;
|
||||
}
|
||||
|
||||
public int[] getSprite() {
|
||||
return sprite;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,9 @@ public class nextFrameBuffer {
|
||||
}
|
||||
|
||||
public Frame getNextframe() {
|
||||
return this.next.current;
|
||||
try {
|
||||
return this.next.current;
|
||||
} catch(NullPointerException e) {return null;}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,10 @@
|
||||
package gameplay.hitboxes;
|
||||
|
||||
public class Active_HitBox extends HitBox {
|
||||
|
||||
public Active_HitBox() {
|
||||
super();
|
||||
}
|
||||
public Active_HitBox(float posX, float posY, float sizeX, float sizeY) {
|
||||
super(posX, posY, sizeX, sizeY);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package gameplay.hitboxes;
|
||||
|
||||
public class Active_throw_Hitbox extends HitBox {
|
||||
|
||||
public Active_throw_Hitbox() {
|
||||
super();
|
||||
}
|
||||
public Active_throw_Hitbox(float posX, float posY, float sizeX, float sizeY) {
|
||||
super(posX, posY, sizeX, sizeY);
|
||||
}
|
||||
}
|
||||
|
@ -2,23 +2,31 @@ package gameplay.hitboxes;
|
||||
|
||||
public class HitBox {
|
||||
|
||||
private double position_x;
|
||||
private double position_y;
|
||||
private double size_x;
|
||||
private double size_y;
|
||||
private float position_x;
|
||||
private float position_y;
|
||||
private float size_x;
|
||||
private float size_y;
|
||||
|
||||
public HitBox() {
|
||||
this.position_x = 0.0;
|
||||
this.position_y = 0.0;
|
||||
this.size_x = 0.0;
|
||||
this.size_y = 0.0;
|
||||
this.position_x = 0.0f;
|
||||
this.position_y = 0.0f;
|
||||
this.size_x = 0.0f;
|
||||
this.size_y = 0.0f;
|
||||
}
|
||||
|
||||
|
||||
public HitBox(float posX, float posY, float sizeX, float sizeY) {
|
||||
this.position_x = posX;
|
||||
this.position_y = posY;
|
||||
this.size_x = sizeX;
|
||||
this.size_y = sizeY;
|
||||
}
|
||||
|
||||
public void setPosition_x(Double position_x){
|
||||
public void setPosition_x(float position_x){
|
||||
this.position_x = position_x;
|
||||
}
|
||||
|
||||
public void setPosition_y(Double position_y){
|
||||
public void setPosition_y(float position_y){
|
||||
this.position_y = position_y;
|
||||
}
|
||||
|
||||
@ -30,10 +38,10 @@ public class HitBox {
|
||||
public Boolean hit(HitBox hb) {
|
||||
Boolean horiz = false;
|
||||
Boolean ver = false;
|
||||
Double horizontal1 = this.position_x + this.size_x;
|
||||
Double vertical1 = this.position_y + this.size_y;
|
||||
Double horizontal2 = hb.position_x + hb.size_x;
|
||||
Double vertical2 = hb.position_y + hb.size_y;
|
||||
float horizontal1 = this.position_x + this.size_x;
|
||||
float vertical1 = this.position_y + this.size_y;
|
||||
float horizontal2 = hb.position_x + hb.size_x;
|
||||
float vertical2 = hb.position_y + hb.size_y;
|
||||
|
||||
|
||||
/*
|
||||
@ -66,27 +74,27 @@ public class HitBox {
|
||||
return horiz && ver;
|
||||
}
|
||||
|
||||
public Double getPosX() {
|
||||
public float getPosX() {
|
||||
return position_x;
|
||||
}
|
||||
|
||||
public Double getPosY() {
|
||||
public float getPosY() {
|
||||
return position_y;
|
||||
}
|
||||
|
||||
public Double getSize_x() {
|
||||
public float getSize_x() {
|
||||
return size_x;
|
||||
}
|
||||
|
||||
public void setSize_x(Double size_x) {
|
||||
public void setSize_x(float size_x) {
|
||||
this.size_x = size_x;
|
||||
}
|
||||
|
||||
public Double getSize_y() {
|
||||
public float getSize_y() {
|
||||
return size_y;
|
||||
}
|
||||
|
||||
public void setSize_y(Double size_y) {
|
||||
public void setSize_y(float size_y) {
|
||||
this.size_y = size_y;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
package gameplay.hitboxes;
|
||||
|
||||
public class Passive_HitBox extends HitBox {
|
||||
|
||||
public Passive_HitBox() {
|
||||
super();
|
||||
}
|
||||
public Passive_HitBox(float posX, float posY, float sizeX, float sizeY) {
|
||||
super(posX, posY, sizeX, sizeY);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,10 @@
|
||||
package gameplay.hitboxes;
|
||||
|
||||
public class Passive_throw_HitBox extends HitBox {
|
||||
|
||||
public Passive_throw_HitBox() {
|
||||
super();
|
||||
}
|
||||
public Passive_throw_HitBox(float posX, float posY, float sizeX, float sizeY) {
|
||||
super(posX, posY, sizeX, sizeY);
|
||||
}
|
||||
}
|
||||
|
@ -5,4 +5,7 @@ public class Push_HitBox extends HitBox {
|
||||
public Push_HitBox() {
|
||||
super();
|
||||
}
|
||||
public Push_HitBox(float posX, float posY, float sizeX, float sizeY) {
|
||||
super(posX, posY, sizeX, sizeY);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package gameplay.match;
|
||||
|
||||
import engine.Engine;
|
||||
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;
|
||||
import gameplay.actions.Throw;
|
||||
@ -36,42 +41,38 @@ public class match {
|
||||
/**
|
||||
* the level of the "ground", used to determine if a character is in the air or not.
|
||||
*/
|
||||
private static final int groundLevel = 250;
|
||||
private static final int groundLevel = 200;
|
||||
|
||||
private int timer;
|
||||
private InputBuffer inputsP1, inputsP2;
|
||||
private int roundsWonP1, roundsWonP2;
|
||||
private Character p1, p2; //characters of player 1 and 2
|
||||
private static int timer;
|
||||
private static InputBuffer inputsP1, inputsP2;
|
||||
private static int roundsWonP1, roundsWonP2;
|
||||
private static Character p1, p2; //characters of player 1 and 2
|
||||
|
||||
private static long timeStamp1;
|
||||
private static long timeStamp2;
|
||||
private static int frameCount;
|
||||
private static int oldPosXp1;
|
||||
private static int oldPosXp2;
|
||||
private static int oldPosYp1;
|
||||
private static int oldPosYp2;
|
||||
private static GamepadInput gamepad1 = null;
|
||||
private static GamepadInput gamepad2 = null;
|
||||
|
||||
/**
|
||||
* base constructor of the match class.
|
||||
* Initiates a new match with with two given characters
|
||||
*/
|
||||
public match(Character p1, Character p2) {
|
||||
this.timer = 99;
|
||||
this.inputsP1 = new InputBuffer(inputBufferSize);
|
||||
this.inputsP2 = new InputBuffer(inputBufferSize);
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
this.roundsWonP1 = 0;
|
||||
this.roundsWonP2 = 0;
|
||||
}
|
||||
|
||||
private static ObjectGl objP1,objP2;
|
||||
private static Engine engine;
|
||||
private static Frame f;
|
||||
|
||||
/**
|
||||
* 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.p1.setPos(-500, groundLevel); //TODO : change to better values if needed
|
||||
this.p2.setPos(500, groundLevel); //TODO : change to better values if needed
|
||||
private static void startNewRound() {
|
||||
timer = 99;
|
||||
inputsP1 = new InputBuffer(inputBufferSize);
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +80,7 @@ public class match {
|
||||
* Used for playing animations and such.
|
||||
* TODO : Implement this once we know what to do.
|
||||
*/
|
||||
private void endRound() {
|
||||
private static void endRound() {
|
||||
|
||||
}
|
||||
|
||||
@ -88,7 +89,7 @@ public class match {
|
||||
* Used for playing animations and such.
|
||||
* TODO : Implement this once we know what to do.
|
||||
*/
|
||||
private void endMatch() {
|
||||
private static void endMatch() {
|
||||
|
||||
}
|
||||
|
||||
@ -156,7 +157,32 @@ public class match {
|
||||
} */
|
||||
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
||||
boolean Joystick2Present = glfwJoystickPresent(GLFW_JOYSTICK_2);
|
||||
match match = new match(new Character(),new Character()); //TODO : Change to not empty chars
|
||||
|
||||
engine = new Engine(640, 480, new Vector3f(4.0f, 3.0f));
|
||||
engine.init();
|
||||
|
||||
String path = "textures/Sprite.png";
|
||||
String pathToBG = "textures/background_beach.png";
|
||||
|
||||
ObjectGl background = new ObjectGl(0f,1f,1f,10f, pathToBG, null);
|
||||
background.setTextureWrap(0,0,621, 224, ObjectGl.DEFAULT);
|
||||
background.translate(new Vector3f(-3011.0f, 1400.0f, 1.0f));
|
||||
engine.add_objectGl(background);
|
||||
|
||||
p1 = CharacterBlue.generateCharBlue();
|
||||
p2 = CharacterBlue.generateCharBlue();
|
||||
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);
|
||||
|
||||
f = p2.getCurrentframe();
|
||||
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
|
||||
objP2.flipTextureWrapH();
|
||||
|
||||
if (Joystick1Present) {
|
||||
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
||||
@ -166,10 +192,12 @@ public class match {
|
||||
gamepad2 = new GamepadInput(GLFW_JOYSTICK_2);
|
||||
gamepad2.inputRefresh();
|
||||
}
|
||||
ac(0);
|
||||
|
||||
}
|
||||
|
||||
private void ac(int i) {
|
||||
private static void ac(int i) {
|
||||
System.out.println(i);
|
||||
switch (i) {
|
||||
|
||||
//initiate a round
|
||||
@ -182,6 +210,11 @@ public class match {
|
||||
|
||||
//checks if one or both of the chars are out of health
|
||||
case 10:
|
||||
oldPosXp1 = p1.getPosX();
|
||||
oldPosXp2 = p2.getPosX();
|
||||
oldPosYp1 = p1.getPosY();
|
||||
oldPosYp2 = p2.getPosY();
|
||||
|
||||
if(p1.getCurrentHP() <= 0 && p2.getCurrentHP() <= 0) { ac(11);}
|
||||
else if(p1.getCurrentHP() <= 0) { ac(12);}
|
||||
else if(p2.getCurrentHP() <= 0) { ac(13);}
|
||||
@ -209,10 +242,12 @@ public class match {
|
||||
|
||||
//read both players inputs
|
||||
case 20:
|
||||
gamepad1.inputRefresh();
|
||||
gamepad2.inputRefresh();
|
||||
inputsP1.recordInputsFromGamepad(gamepad1, p1.getPosX() < p2.getPosX());
|
||||
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);
|
||||
@ -220,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;
|
||||
|
||||
@ -238,18 +277,29 @@ public class match {
|
||||
nextFrame(p2,inputsP2);
|
||||
updatePos(p1);
|
||||
updatePos(p2);
|
||||
f = p1.getCurrentframe();
|
||||
objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
|
||||
objP1.translate(new Vector3f(p1.getPosX()-oldPosXp1,p1.getPosY()-oldPosYp1,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(p2.getPosX()-oldPosXp2,p2.getPosY()-oldPosYp2,0));
|
||||
|
||||
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
||||
if(p1LooksRight) {
|
||||
Frame f = new Frame();
|
||||
f.clone(p2.getCurrentframe());
|
||||
f.invertHitBoxes();
|
||||
p2.setCurrentFrame(f);
|
||||
Frame nf = new Frame();
|
||||
nf.clone(p2.getCurrentframe());
|
||||
nf.invertHitBoxes();
|
||||
p2.setCurrentFrame(nf);
|
||||
objP2.flipTextureWrapH();
|
||||
} else {
|
||||
Frame f = new Frame();
|
||||
f.clone(p1.getCurrentframe());
|
||||
f.invertHitBoxes();
|
||||
p1.setCurrentFrame(f);
|
||||
Frame nf = new Frame();
|
||||
nf.clone(p1.getCurrentframe());
|
||||
nf.invertHitBoxes();
|
||||
p1.setCurrentFrame(nf);
|
||||
objP1.flipTextureWrapH();
|
||||
}
|
||||
engine.update();
|
||||
engine.render();
|
||||
ac(23);
|
||||
break;
|
||||
|
||||
@ -472,10 +522,11 @@ public class match {
|
||||
* @param c the character
|
||||
* @param in the input buffer corresponding to the character
|
||||
*/
|
||||
private void nextFrame(Character c, InputBuffer in) {
|
||||
if(!c.getFrames().getNextframe().equals(null)){
|
||||
private static void nextFrame(Character c, InputBuffer in) {
|
||||
try {
|
||||
//if(!c.getFrames().getNextframe().equals(null)){
|
||||
c.goToNextFrames();
|
||||
} else {
|
||||
} catch (NullPointerException e) {
|
||||
switch(c.getStatus()) {
|
||||
case FALLING:case HITINAIR:
|
||||
if(c.getPosY() > groundLevel){
|
||||
@ -496,7 +547,7 @@ public class match {
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePos(Character c) {
|
||||
private static void updatePos(Character c) {
|
||||
c.setPos((int)(c.getPosX()+c.getCurrentframe().getMove_x()),(int)(c.getPosY()+c.getCurrentframe().getMove_y()));
|
||||
}
|
||||
|
||||
|
@ -9,20 +9,23 @@
|
||||
|
||||
package launcher;
|
||||
|
||||
import engine.TestEngine;
|
||||
import gameplay.match.*;
|
||||
import javafx.application.Application;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ChoiceBox;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import javafx.fxml.*;
|
||||
|
||||
import engine.Engine;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Launcher extends Application {
|
||||
|
||||
public static Launcher pointer;
|
||||
private static Settings setter;
|
||||
private HashMap<String, Object> arraysettings;
|
||||
|
||||
public Launcher() {
|
||||
pointer = this;
|
||||
@ -32,6 +35,7 @@ public class Launcher extends Application {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
arraysettings = new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -43,6 +47,17 @@ public class Launcher extends Application {
|
||||
|
||||
Scene main = new Scene(root);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ChoiceBox<String> cb = (ChoiceBox<String>) main.lookup("#resolution");
|
||||
|
||||
ObservableList<String> availableres = FXCollections.observableArrayList("640x480", "800x600", "1024x768", "1280x720", "1366x768", "1600x900", "1920x1080");
|
||||
cb.setItems(availableres);
|
||||
if (!availableres.contains(setter.getResolution())) {
|
||||
cb.setValue("640x480");
|
||||
} else {
|
||||
cb.setValue(setter.getResolution());
|
||||
}
|
||||
|
||||
primaryStage.initStyle(StageStyle.UNDECORATED);
|
||||
primaryStage.setTitle("Boulevard Combattant");
|
||||
primaryStage.setScene(main);
|
||||
@ -53,7 +68,7 @@ public class Launcher extends Application {
|
||||
public static void runGame() {
|
||||
try {
|
||||
setter.setSettings();
|
||||
TestEngine.main(null);
|
||||
match.main(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
@ -80,4 +95,8 @@ public class Launcher extends Application {
|
||||
getHostServices().showDocument("https://gitlab.istic.univ-rennes1.fr/fautin/jeu-de-combat");
|
||||
}
|
||||
|
||||
public HashMap<String, Object> getArraysettings() {
|
||||
return arraysettings;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,162 +3,41 @@ package launcher;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import configuration.*;
|
||||
|
||||
public class Settings {
|
||||
|
||||
private class Player {
|
||||
|
||||
private int controller_id;
|
||||
private String character;
|
||||
private int color;
|
||||
|
||||
public Player(int cid, String ch, int col) {
|
||||
controller_id = cid;
|
||||
character = ch;
|
||||
color = col;
|
||||
}
|
||||
|
||||
protected int getController_id() {
|
||||
return controller_id;
|
||||
}
|
||||
protected void setController_id(int controller_id) {
|
||||
this.controller_id = controller_id;
|
||||
}
|
||||
protected String getCharacter() {
|
||||
return character;
|
||||
}
|
||||
protected void setCharacter(String character) {
|
||||
this.character = character;
|
||||
}
|
||||
protected int getColor() {
|
||||
return color;
|
||||
}
|
||||
protected void setColor(int color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
}
|
||||
private Config config;
|
||||
|
||||
private FileInputStream f_is;
|
||||
private int width, height, r_x, r_y, rounds;
|
||||
private boolean fullscreen;
|
||||
private String stage;
|
||||
private Player p1, p2;
|
||||
|
||||
public Settings() throws Exception {
|
||||
public Settings() {
|
||||
try {
|
||||
f_is = new FileInputStream("game.set");
|
||||
} catch (FileNotFoundException e) {
|
||||
File f = new File("game.set");
|
||||
f.createNewFile();
|
||||
} finally {
|
||||
f_is = new FileInputStream("game.set");
|
||||
config = new Config();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
parseSettings();
|
||||
} finally {
|
||||
setDefaultSettings();
|
||||
}
|
||||
}
|
||||
|
||||
private void parseSettings() throws Exception {
|
||||
//TODO: parseSettings() (Needs settings syntax fixed)
|
||||
}
|
||||
|
||||
public void setSettings() throws Exception {
|
||||
//TODO: parseSettings() (Needs settings syntax fixed)
|
||||
HashMap<String, Object> set = Launcher.pointer.getArraysettings();
|
||||
try {
|
||||
int width = (Integer) set.get("width");
|
||||
int height = (Integer) set.get("height");
|
||||
int rounds = (Integer) set.get("rounds");
|
||||
boolean fullscreen = (Boolean) set.get("fullscreen");
|
||||
String character1 = (String) set.get("character1");
|
||||
String character2 = (String) set.get("character2");
|
||||
String stage = (String) set.get("stage");
|
||||
config.write(width, height, rounds, fullscreen, character1, character2, stage);
|
||||
} catch (Exception e) {
|
||||
config.write(800, 600, 3, false, "default", "default", "default");
|
||||
System.out.println("Incorrect config file");
|
||||
}
|
||||
}
|
||||
|
||||
private void setDefaultSettings() {
|
||||
width = 800;
|
||||
height = 600;
|
||||
r_x = 4;
|
||||
r_y = 3;
|
||||
rounds = 3;
|
||||
fullscreen = false;
|
||||
p1 = new Player(0, "base", 0);
|
||||
p2 = new Player(0, "base", 0);
|
||||
public String getResolution() {
|
||||
return "" + Integer.toString(config.width) + "x" + Integer.toString(config.height);
|
||||
}
|
||||
|
||||
protected FileInputStream getF_is() {
|
||||
return f_is;
|
||||
}
|
||||
|
||||
protected int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
protected int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
protected int getR_x() {
|
||||
return r_x;
|
||||
}
|
||||
|
||||
protected int getR_y() {
|
||||
return r_y;
|
||||
}
|
||||
|
||||
protected int getRounds() {
|
||||
return rounds;
|
||||
}
|
||||
|
||||
protected boolean isFullscreen() {
|
||||
return fullscreen;
|
||||
}
|
||||
|
||||
protected String getStage() {
|
||||
return stage;
|
||||
}
|
||||
|
||||
protected Player getP1() {
|
||||
return p1;
|
||||
}
|
||||
|
||||
protected Player getP2() {
|
||||
return p2;
|
||||
}
|
||||
|
||||
protected void setF_is(FileInputStream f_is) {
|
||||
this.f_is = f_is;
|
||||
}
|
||||
|
||||
protected void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
protected void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
protected void setR_x(int r_x) {
|
||||
this.r_x = r_x;
|
||||
}
|
||||
|
||||
protected void setR_y(int r_y) {
|
||||
this.r_y = r_y;
|
||||
}
|
||||
|
||||
protected void setRounds(int rounds) {
|
||||
this.rounds = rounds;
|
||||
}
|
||||
|
||||
protected void setFullscreen(boolean fullscreen) {
|
||||
this.fullscreen = fullscreen;
|
||||
}
|
||||
|
||||
protected void setStage(String stage) {
|
||||
this.stage = stage;
|
||||
}
|
||||
|
||||
protected void setP1(Player p1) {
|
||||
this.p1 = p1;
|
||||
}
|
||||
|
||||
protected void setP2(Player p2) {
|
||||
this.p2 = p2;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,8 +35,8 @@
|
||||
<children>
|
||||
<Button text="Play" fx:id="btn_launch" onAction="#launch"
|
||||
prefWidth="110" prefHeight="15"/>
|
||||
<Button text="Settings" fx:id="btn_settings" onAction="#settings"
|
||||
prefWidth="110" prefHeight="15"/>
|
||||
<Label text="Resolution"/>
|
||||
<ChoiceBox fx:id="resolution"/>
|
||||
<Button text="Quit" fx:id="btn_quit" onAction="#quit"
|
||||
prefWidth="110" prefHeight="15"/>
|
||||
</children>
|
||||
|
@ -52,4 +52,9 @@ Text, Label {
|
||||
/* Link to project */
|
||||
Hyperlink:visited {
|
||||
-fx-text-fill: #0095c8;
|
||||
}
|
||||
|
||||
.contr_box {
|
||||
-fx-fill: #000000 !important;
|
||||
-fx-text-fill: #000000 !important;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user