Built a basic movement test, can't test because it doesn't recognize my gamepads.
This commit is contained in:
parent
f56c84ef8e
commit
93f5727569
@ -317,6 +317,7 @@ public class BlueBaseFrames {
|
|||||||
engine.init();
|
engine.init();
|
||||||
|
|
||||||
String path = "textures/Sprite.png";
|
String path = "textures/Sprite.png";
|
||||||
|
String pathToBG = "textures/background_beach.png";
|
||||||
|
|
||||||
Frame f = generateStandFrame1();
|
Frame f = generateStandFrame1();
|
||||||
ObjectGl blue = new ObjectGl(0f, 60f, 80f, 5f, path, null);
|
ObjectGl blue = new ObjectGl(0f, 60f, 80f, 5f, path, null);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package gameplay.Characters.Blue;
|
package gameplay.Characters.Blue;
|
||||||
|
|
||||||
import gameplay.actions.Jump;
|
import gameplay.actions.*;
|
||||||
import gameplay.entities.Character;
|
import gameplay.entities.Character;
|
||||||
import gameplay.frames.Frame;
|
import gameplay.frames.Frame;
|
||||||
import gameplay.Characters.Blue.BlueBaseFrames;
|
import gameplay.Characters.Blue.BlueBaseFrames;
|
||||||
|
import gameplay.input.ButtonIG;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static gameplay.input.ButtonIG.*;
|
import static gameplay.input.ButtonIG.*;
|
||||||
|
|
||||||
@ -17,6 +20,39 @@ public class CharacterBlue {
|
|||||||
Frame[] fWalkF = BlueBaseFrames.blueFWalk();
|
Frame[] fWalkF = BlueBaseFrames.blueFWalk();
|
||||||
Frame[] bWalkF = BlueBaseFrames.blueBWalk();
|
Frame[] bWalkF = BlueBaseFrames.blueBWalk();
|
||||||
|
|
||||||
return new Character();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class Throw implements Action {
|
|||||||
* For example, a Moonsault Press would be something like
|
* For example, a Moonsault Press would be something like
|
||||||
* {{LEFT},{DOWN,LEFT},{DOWN},{DOWN,RIGHT},{RIGHT},{RIGHT,UP},{UP},{A}}
|
* {{LEFT},{DOWN,LEFT},{DOWN},{DOWN,RIGHT},{RIGHT},{RIGHT,UP},{UP},{A}}
|
||||||
*/
|
*/
|
||||||
private static ButtonIG[][] command;
|
private ButtonIG[][] command;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The different sections of the throw
|
* The different sections of the throw
|
||||||
@ -62,4 +62,10 @@ public class Throw implements Action {
|
|||||||
|
|
||||||
public Throw() {
|
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 {
|
public class Character extends Entity {
|
||||||
private static int maxHP;
|
private int maxHP;
|
||||||
private static int currentHP;
|
private int currentHP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All of the attacks, both special and normal, of the character
|
* 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 :
|
* 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}
|
* {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 Jump forwardJump;
|
||||||
private static Jump neutralJump;
|
private Jump neutralJump;
|
||||||
private static Jump backJump;
|
private Jump backJump;
|
||||||
|
|
||||||
private static Dash forwardDash;
|
private Dash forwardDash;
|
||||||
private static Dash backDash;
|
private Dash backDash;
|
||||||
|
|
||||||
private static Throw normalthrow;
|
private Throw normalthrow;
|
||||||
|
|
||||||
private static Status status;
|
private Status status;
|
||||||
|
|
||||||
private static Frame[] defaultStandingFrames;
|
private Frame[] defaultStandingFrames;
|
||||||
private static Frame[] defaultCrouchingFrames;
|
private Frame[] defaultCrouchingFrames;
|
||||||
private static Frame[] forwardWalkFrames;
|
private Frame[] forwardWalkFrames;
|
||||||
private static Frame[] backWalkFrames;
|
private Frame[] backWalkFrames;
|
||||||
private Frame hitInAirFrame; //the frame to display when hit in the air. Shouldmake the character rise
|
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 fallingframe; //the frame to display when falling from the air
|
||||||
private Frame[] knockedDownFrames;
|
private Frame[] knockedDownFrames;
|
||||||
@ -67,111 +67,137 @@ public class Character extends Entity {
|
|||||||
this.currentHP = this.maxHP;
|
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) {
|
public void setMaxHP(int HP) {
|
||||||
this.maxHP = HP;
|
this.maxHP = HP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMaxHP() { return this.maxHP;}
|
public int getMaxHP() { return this.maxHP;}
|
||||||
|
|
||||||
public static Attack[] getAttacks() {
|
public Attack[] getAttacks() {
|
||||||
return attacks;
|
return this.attacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAttacks(Attack[] attacks) {
|
public void setAttacks(Attack[] attacks) {
|
||||||
Character.attacks = attacks;
|
this.attacks = attacks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Jump getForwardJump() {
|
public Jump getForwardJump() {
|
||||||
return forwardJump;
|
return this.forwardJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setForwardJump(Jump forwardJump) {
|
public void setForwardJump(Jump forwardJump) {
|
||||||
Character.forwardJump = forwardJump;
|
this.forwardJump = forwardJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Jump getNeutralJump() {
|
public Jump getNeutralJump() {
|
||||||
return neutralJump;
|
return this.neutralJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setNeutralJump(Jump neutralJump) {
|
public void setNeutralJump(Jump neutralJump) {
|
||||||
Character.neutralJump = neutralJump;
|
this.neutralJump = neutralJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Jump getBackJump() {
|
public Jump getBackJump() {
|
||||||
return backJump;
|
return this.backJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBackJump(Jump backJump) {
|
public void setBackJump(Jump backJump) {
|
||||||
Character.backJump = backJump;
|
this.backJump = backJump;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dash getForwardDash() {
|
public Dash getForwardDash() {
|
||||||
return forwardDash;
|
return this.forwardDash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setForwardDash(Dash forwardDash) {
|
public void setForwardDash(Dash forwardDash) {
|
||||||
Character.forwardDash = forwardDash;
|
this.forwardDash = forwardDash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dash getBackDash() {
|
public Dash getBackDash() {
|
||||||
return backDash;
|
return this.backDash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBackDash(Dash backDash) {
|
public void setBackDash(Dash backDash) {
|
||||||
Character.backDash = backDash;
|
this.backDash = backDash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Throw getNormalthrow() {
|
public Throw getNormalthrow() {
|
||||||
return normalthrow;
|
return this.normalthrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setNormalthrow(Throw normalthrow) {
|
public void setNormalthrow(Throw normalthrow) {
|
||||||
Character.normalthrow = normalthrow;
|
this.normalthrow = normalthrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Status getStatus() {
|
public Status getStatus() {
|
||||||
return status;
|
return this.status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setStatus(Status status) {
|
public void setStatus(Status status) {
|
||||||
Character.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Frame[] getDefaultStandingFrames() {
|
public Frame[] getDefaultStandingFrames() {
|
||||||
return defaultStandingFrames;
|
return this.defaultStandingFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDefaultStandingFrames(Frame[] defaultStandingFrames) {
|
public void setDefaultStandingFrames(Frame[] defaultStandingFrames) {
|
||||||
Character.defaultStandingFrames = defaultStandingFrames;
|
this.defaultStandingFrames = defaultStandingFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Frame[] getDefaultCrouchingFrames() {
|
public Frame[] getDefaultCrouchingFrames() {
|
||||||
return defaultCrouchingFrames;
|
return this.defaultCrouchingFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDefaultCrouchingFrames(Frame[] defaultCrouchingFrames) {
|
public void setDefaultCrouchingFrames(Frame[] defaultCrouchingFrames) {
|
||||||
Character.defaultCrouchingFrames = defaultCrouchingFrames;
|
this.defaultCrouchingFrames = defaultCrouchingFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Frame[] getForwardWalkFrames() {
|
public Frame[] getForwardWalkFrames() {
|
||||||
return forwardWalkFrames;
|
return this.forwardWalkFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setForwardWalkFrames(Frame[] forwardWalkFrames) {
|
public void setForwardWalkFrames(Frame[] forwardWalkFrames) {
|
||||||
Character.forwardWalkFrames = forwardWalkFrames;
|
this.forwardWalkFrames = forwardWalkFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Frame[] getBackWalkFrames() {
|
public Frame[] getBackWalkFrames() {
|
||||||
return backWalkFrames;
|
return this.backWalkFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setBackWalkFrames(Frame[] backWalkFrames) {
|
public void setBackWalkFrames(Frame[] backWalkFrames) {
|
||||||
Character.backWalkFrames = backWalkFrames;
|
this.backWalkFrames = backWalkFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<attackPart> getNextAttackParts() {
|
public ArrayList<attackPart> getNextAttackParts() {
|
||||||
return nextAttackParts;
|
return this.nextAttackParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextAttackParts(ArrayList<attackPart> nextAttackParts) {
|
public void setNextAttackParts(ArrayList<attackPart> nextAttackParts) {
|
||||||
@ -194,7 +220,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<ThrowPart> getNextThrowParts() {
|
public ArrayList<ThrowPart> getNextThrowParts() {
|
||||||
return nextThrowParts;
|
return this.nextThrowParts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNextThrowParts(ArrayList<ThrowPart> nextAttackParts) {
|
public void setNextThrowParts(ArrayList<ThrowPart> nextAttackParts) {
|
||||||
@ -216,8 +242,8 @@ public class Character extends Entity {
|
|||||||
this.nextThrowParts.remove(0);
|
this.nextThrowParts.remove(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getCurrentHP() {
|
public int getCurrentHP() {
|
||||||
return currentHP;
|
return this.currentHP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentHP(int currentHP) {
|
public void setCurrentHP(int currentHP) {
|
||||||
@ -240,7 +266,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Frame getHitInAirFrame() {
|
public Frame getHitInAirFrame() {
|
||||||
return hitInAirFrame;
|
return this.hitInAirFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHitInAirFrame(Frame hitInAirFrame) {
|
public void setHitInAirFrame(Frame hitInAirFrame) {
|
||||||
@ -248,7 +274,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Frame getFallingframe() {
|
public Frame getFallingframe() {
|
||||||
return fallingframe;
|
return this.fallingframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFallingframe(Frame fallingframe) {
|
public void setFallingframe(Frame fallingframe) {
|
||||||
@ -256,7 +282,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Frame[] getKnockedDownFrames() {
|
public Frame[] getKnockedDownFrames() {
|
||||||
return knockedDownFrames;
|
return this.knockedDownFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKnockedDownFrames(Frame[] knockedDownFrames) {
|
public void setKnockedDownFrames(Frame[] knockedDownFrames) {
|
||||||
@ -264,7 +290,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Frame getStandGuardFrame() {
|
public Frame getStandGuardFrame() {
|
||||||
return standGuardFrame;
|
return this.standGuardFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStandGuardFrame(Frame standGuardFrame) {
|
public void setStandGuardFrame(Frame standGuardFrame) {
|
||||||
@ -272,7 +298,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Frame getCrouchGuardFrame() {
|
public Frame getCrouchGuardFrame() {
|
||||||
return crouchGuardFrame;
|
return this.crouchGuardFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCrouchGuardFrame(Frame crouchGuardFrame) {
|
public void setCrouchGuardFrame(Frame crouchGuardFrame) {
|
||||||
@ -280,7 +306,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Frame getStandHitFrame() {
|
public Frame getStandHitFrame() {
|
||||||
return standHitFrame;
|
return this.standHitFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStandHitFrame(Frame standHitFrame) {
|
public void setStandHitFrame(Frame standHitFrame) {
|
||||||
@ -288,7 +314,7 @@ public class Character extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Frame getCrouchHitFrame() {
|
public Frame getCrouchHitFrame() {
|
||||||
return crouchHitFrame;
|
return this.crouchHitFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCrouchHitFrame(Frame crouchHitFrame) {
|
public void setCrouchHitFrame(Frame crouchHitFrame) {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
package gameplay.match;
|
package gameplay.match;
|
||||||
|
|
||||||
|
import engine.Engine;
|
||||||
import engine.input.Button;
|
import engine.input.Button;
|
||||||
import engine.input.GamepadInput;
|
import engine.input.GamepadInput;
|
||||||
|
import engine.math.Vector3f;
|
||||||
|
import engine.object.ObjectGl;
|
||||||
|
import gameplay.Characters.Blue.CharacterBlue;
|
||||||
import gameplay.actions.Attack;
|
import gameplay.actions.Attack;
|
||||||
import gameplay.actions.attackPart;
|
import gameplay.actions.attackPart;
|
||||||
import gameplay.actions.Throw;
|
import gameplay.actions.Throw;
|
||||||
@ -36,42 +40,36 @@ public class match {
|
|||||||
/**
|
/**
|
||||||
* 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 = 250;
|
private static final int groundLevel = 200;
|
||||||
|
|
||||||
private int timer;
|
private static int timer;
|
||||||
private InputBuffer inputsP1, inputsP2;
|
private static InputBuffer inputsP1, inputsP2;
|
||||||
private int roundsWonP1, roundsWonP2;
|
private static int roundsWonP1, roundsWonP2;
|
||||||
private 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;
|
||||||
private static int frameCount;
|
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 gamepad1 = null;
|
||||||
private static GamepadInput gamepad2 = null;
|
private static GamepadInput gamepad2 = null;
|
||||||
|
|
||||||
/**
|
private static ObjectGl objP1,objP2;
|
||||||
* base constructor of the match class.
|
private static Engine engine;
|
||||||
* Initiates a new match with with two given characters
|
private static Frame f;
|
||||||
*/
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 void startNewRound() {
|
private static void startNewRound() {
|
||||||
this.timer = 99;
|
timer = 99;
|
||||||
this.inputsP1 = new InputBuffer(inputBufferSize);
|
inputsP1 = new InputBuffer(inputBufferSize);
|
||||||
this.inputsP2 = new InputBuffer(inputBufferSize);
|
inputsP2 = new InputBuffer(inputBufferSize);
|
||||||
this.p1.setPos(-500, groundLevel); //TODO : change to better values if needed
|
p1.setPos(-750, groundLevel); //TODO : change to better values if needed
|
||||||
this.p2.setPos(500, groundLevel); //TODO : change to better values if needed
|
p2.setPos(-750, groundLevel); //TODO : change to better values if needed
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,7 +77,7 @@ public class match {
|
|||||||
* Used for playing animations and such.
|
* Used for playing animations and such.
|
||||||
* TODO : Implement this once we know what to do.
|
* TODO : Implement this once we know what to do.
|
||||||
*/
|
*/
|
||||||
private void endRound() {
|
private static void endRound() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,7 +86,7 @@ public class match {
|
|||||||
* Used for playing animations and such.
|
* Used for playing animations and such.
|
||||||
* TODO : Implement this once we know what to do.
|
* TODO : Implement this once we know what to do.
|
||||||
*/
|
*/
|
||||||
private void endMatch() {
|
private static void endMatch() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +154,32 @@ public class match {
|
|||||||
} */
|
} */
|
||||||
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
boolean Joystick1Present = glfwJoystickPresent(GLFW_JOYSTICK_1);
|
||||||
boolean Joystick2Present = glfwJoystickPresent(GLFW_JOYSTICK_2);
|
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 ObjectGl(1f, 60f, 80f, 5f, path, null);
|
||||||
|
objP2 = new ObjectGl(2f, 60f, 80f, 5f, path, null);
|
||||||
|
engine.add_objectGl(objP1);
|
||||||
|
engine.add_objectGl(objP2);
|
||||||
|
|
||||||
|
f = p1.getCurrentframe();
|
||||||
|
objP1.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
|
||||||
|
objP1.translate(new Vector3f(-750,200,0));
|
||||||
|
f = p2.getCurrentframe();
|
||||||
|
objP2.setTextureWrap(f.getSprite()[0], f.getSprite()[1], f.getSprite()[2], f.getSprite()[3], ObjectGl.STICK_TOP);
|
||||||
|
objP2.translate(new Vector3f(750,200,0));
|
||||||
|
objP2.flipTextureWrapH();
|
||||||
|
|
||||||
if (Joystick1Present) {
|
if (Joystick1Present) {
|
||||||
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
gamepad1 = new GamepadInput(GLFW_JOYSTICK_1);
|
||||||
@ -166,10 +189,12 @@ public class match {
|
|||||||
gamepad2 = new GamepadInput(GLFW_JOYSTICK_2);
|
gamepad2 = new GamepadInput(GLFW_JOYSTICK_2);
|
||||||
gamepad2.inputRefresh();
|
gamepad2.inputRefresh();
|
||||||
}
|
}
|
||||||
|
ac(0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ac(int i) {
|
private static void ac(int i) {
|
||||||
|
System.out.println(i);
|
||||||
switch (i) {
|
switch (i) {
|
||||||
|
|
||||||
//initiate a round
|
//initiate a round
|
||||||
@ -182,6 +207,11 @@ public class match {
|
|||||||
|
|
||||||
//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();
|
||||||
|
oldPosXp2 = p2.getPosX();
|
||||||
|
oldPosYp1 = p1.getPosY();
|
||||||
|
oldPosYp2 = p2.getPosY();
|
||||||
|
|
||||||
if(p1.getCurrentHP() <= 0 && p2.getCurrentHP() <= 0) { ac(11);}
|
if(p1.getCurrentHP() <= 0 && p2.getCurrentHP() <= 0) { ac(11);}
|
||||||
else if(p1.getCurrentHP() <= 0) { ac(12);}
|
else if(p1.getCurrentHP() <= 0) { ac(12);}
|
||||||
else if(p2.getCurrentHP() <= 0) { ac(13);}
|
else if(p2.getCurrentHP() <= 0) { ac(13);}
|
||||||
@ -210,8 +240,8 @@ public class match {
|
|||||||
//read both players inputs
|
//read both players inputs
|
||||||
case 20:
|
case 20:
|
||||||
gamepad1.inputRefresh();
|
gamepad1.inputRefresh();
|
||||||
gamepad2.inputRefresh();
|
|
||||||
inputsP1.recordInputsFromGamepad(gamepad1, p1.getPosX() < p2.getPosX());
|
inputsP1.recordInputsFromGamepad(gamepad1, p1.getPosX() < p2.getPosX());
|
||||||
|
gamepad2.inputRefresh();
|
||||||
inputsP2.recordInputsFromGamepad(gamepad2, p2.getPosX() <= p1.getPosX());
|
inputsP2.recordInputsFromGamepad(gamepad2, p2.getPosX() <= p1.getPosX());
|
||||||
handleInputs(p1, inputsP1);
|
handleInputs(p1, inputsP1);
|
||||||
handleInputs(p2, inputsP2);
|
handleInputs(p2, inputsP2);
|
||||||
@ -238,18 +268,29 @@ public class match {
|
|||||||
nextFrame(p2,inputsP2);
|
nextFrame(p2,inputsP2);
|
||||||
updatePos(p1);
|
updatePos(p1);
|
||||||
updatePos(p2);
|
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();
|
boolean p1LooksRight = p1.getPosX() < p2.getPosX();
|
||||||
if(p1LooksRight) {
|
if(p1LooksRight) {
|
||||||
Frame f = new Frame();
|
Frame nf = new Frame();
|
||||||
f.clone(p2.getCurrentframe());
|
nf.clone(p2.getCurrentframe());
|
||||||
f.invertHitBoxes();
|
nf.invertHitBoxes();
|
||||||
p2.setCurrentFrame(f);
|
p2.setCurrentFrame(nf);
|
||||||
|
objP2.flipTextureWrapH();
|
||||||
} else {
|
} else {
|
||||||
Frame f = new Frame();
|
Frame nf = new Frame();
|
||||||
f.clone(p1.getCurrentframe());
|
nf.clone(p1.getCurrentframe());
|
||||||
f.invertHitBoxes();
|
nf.invertHitBoxes();
|
||||||
p1.setCurrentFrame(f);
|
p1.setCurrentFrame(nf);
|
||||||
|
objP1.flipTextureWrapH();
|
||||||
}
|
}
|
||||||
|
engine.update();
|
||||||
|
engine.render();
|
||||||
ac(23);
|
ac(23);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -472,7 +513,7 @@ public class match {
|
|||||||
* @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 void nextFrame(Character c, InputBuffer in) {
|
private static void nextFrame(Character c, InputBuffer in) {
|
||||||
if(!c.getFrames().getNextframe().equals(null)){
|
if(!c.getFrames().getNextframe().equals(null)){
|
||||||
c.goToNextFrames();
|
c.goToNextFrames();
|
||||||
} else {
|
} else {
|
||||||
@ -496,7 +537,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()));
|
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