diff --git a/src/engine/TestEngine.java b/src/engine/TestEngine.java index 4a6502f..0992485 100644 --- a/src/engine/TestEngine.java +++ b/src/engine/TestEngine.java @@ -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(); } diff --git a/src/gameplay/Characters/Blue/BlueBaseFrames.java b/src/gameplay/Characters/Blue/BlueBaseFrames.java new file mode 100644 index 0000000..e4d9357 --- /dev/null +++ b/src/gameplay/Characters/Blue/BlueBaseFrames.java @@ -0,0 +1,176 @@ +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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(0.0,0.0,phb,new ArrayList(),pthb,new ArrayList(), + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(0.0,0.0,phb,new ArrayList(),pthb,new ArrayList(), + bStandPB1,true,true,true,true,true); + blueStandframe1.setSpriteWrap(112,0,112,120); + return blueStandframe1; + } + + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(0.0,0.0,phb,new ArrayList(),pthb,new ArrayList(), + bStandPB1,true,true,true,true,true); + blueStandframe1.setSpriteWrap(112,0,112,120); + return blueStandframe1; + } + + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(-10.0,0.0,phb,new ArrayList(),pthb,new ArrayList(), + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(10.0,0.0,phb,new ArrayList(),pthb,new ArrayList(), + bStandPB1,false,false,false,false,false); + blueStandframe1.setSpriteWrap(830,0,112,120); + return blueStandframe1; + } + + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(-10.0,10.0,phb,new ArrayList(),pthb,new ArrayList(), + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(10.0,10.0,phb,new ArrayList(),pthb,new ArrayList(), + bStandPB1,false,false,false,false,false); + blueStandframe1.setSpriteWrap(750,0,112,120); + return blueStandframe1; + } + + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(-10.0,-10.0,phb,new ArrayList(),pthb,new ArrayList(), + bStandPB1,false,false,false,false,false); + blueStandframe1.setSpriteWrap(750,0,112,120); + return blueStandframe1; + } + + 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 phb = new ArrayList(); + ArrayList pthb = new ArrayList(); + phb.add(bStandPHB1); + pthb.add(bStandPTHB1); + Frame blueStandframe1 = new Frame(10.0,-10.0,phb,new ArrayList(),pthb,new ArrayList(), + bStandPB1,false,false,false,false,false); + blueStandframe1.setSpriteWrap(750,0,112,120); + return blueStandframe1; + } + + 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"; + + 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(); + } + + } + } + +} diff --git a/src/gameplay/Characters/Blue/CharacterBlue.java b/src/gameplay/Characters/Blue/CharacterBlue.java new file mode 100644 index 0000000..df11ae9 --- /dev/null +++ b/src/gameplay/Characters/Blue/CharacterBlue.java @@ -0,0 +1,9 @@ +package gameplay.Characters.Blue; + +import gameplay.entities.Character; + +public class CharacterBlue { + public Character generateCharBlue(){ + return new Character(); + } +} diff --git a/src/gameplay/frames/Frame.java b/src/gameplay/frames/Frame.java index 6ab43a6..450ff8a 100644 --- a/src/gameplay/frames/Frame.java +++ b/src/gameplay/frames/Frame.java @@ -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[0]; } public Frame(Double move_y, Double move_x, ArrayList passHitBox, ArrayList 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; } } diff --git a/src/gameplay/hitboxes/Active_HitBox.java b/src/gameplay/hitboxes/Active_HitBox.java index 05c6a76..55bc382 100644 --- a/src/gameplay/hitboxes/Active_HitBox.java +++ b/src/gameplay/hitboxes/Active_HitBox.java @@ -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); + } } diff --git a/src/gameplay/hitboxes/Active_throw_Hitbox.java b/src/gameplay/hitboxes/Active_throw_Hitbox.java index 79f1828..bfdd80e 100644 --- a/src/gameplay/hitboxes/Active_throw_Hitbox.java +++ b/src/gameplay/hitboxes/Active_throw_Hitbox.java @@ -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); + } } diff --git a/src/gameplay/hitboxes/HitBox.java b/src/gameplay/hitboxes/HitBox.java index 9257648..54cf28f 100644 --- a/src/gameplay/hitboxes/HitBox.java +++ b/src/gameplay/hitboxes/HitBox.java @@ -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; } diff --git a/src/gameplay/hitboxes/Passive_HitBox.java b/src/gameplay/hitboxes/Passive_HitBox.java index 51e3674..bd3279d 100644 --- a/src/gameplay/hitboxes/Passive_HitBox.java +++ b/src/gameplay/hitboxes/Passive_HitBox.java @@ -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); + } } diff --git a/src/gameplay/hitboxes/Passive_throw_HitBox.java b/src/gameplay/hitboxes/Passive_throw_HitBox.java index 88a677c..2cb506e 100644 --- a/src/gameplay/hitboxes/Passive_throw_HitBox.java +++ b/src/gameplay/hitboxes/Passive_throw_HitBox.java @@ -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); + } } diff --git a/src/gameplay/hitboxes/Push_HitBox.java b/src/gameplay/hitboxes/Push_HitBox.java index c97b52b..3a678a7 100644 --- a/src/gameplay/hitboxes/Push_HitBox.java +++ b/src/gameplay/hitboxes/Push_HitBox.java @@ -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); + } }