diff --git a/Display.class b/Display.class index cbb1f93..b73cf06 100644 Binary files a/Display.class and b/Display.class differ diff --git a/Display.java b/Display.java index 80a742e..eae74cb 100644 --- a/Display.java +++ b/Display.java @@ -1,6 +1,7 @@ import javax.swing.*; import java.awt.*; import java.awt.event.*; +import java.awt.geom.AffineTransform; import java.awt.Image; import java.io.File; import java.io.IOException; @@ -60,7 +61,6 @@ public int[] attackHitBox(Fighter f1) i[1] = (int)(b.getPos()[1]+ f1.getPos()[1]); i[2] = b.getSize()[0]; i[3] = b.getSize()[1]; - return i; } @@ -92,7 +92,10 @@ else if(mode == 1) g.fillRect((int)dFs[0].getPos()[0],(int)dFs[0].getPos()[1],dFs[0].getSize(),dFs[0].getSize()); - if(dFs[0].getAttacking() == 1){ + if (dFs[0].getBlocking()) { + g.setColor(Color.white); + g.fillRect((int)dFs[0].getPos()[0]+10, (int)dFs[0].getPos()[1]+10, 30, 30); + } else if(dFs[0].getAttacking() == 1){ g.setColor(Color.red); //g.setColor(Color.green); @@ -105,7 +108,10 @@ else if(mode == 1) g.setColor(Color.cyan); g.fillRect((int)dFs[1].getPos()[0],(int)dFs[1].getPos()[1],dFs[1].getSize(),dFs[1].getSize()); - if(dFs[1].getAttacking() == 1){ + if (dFs[1].getBlocking()) { + g.setColor(Color.white); + g.fillRect((int)dFs[1].getPos()[0]+10, (int)dFs[1].getPos()[1]+10, 30, 30); + } else if(dFs[1].getAttacking() == 1){ g.setColor(Color.cyan); //g.setColor(Color.green); @@ -117,22 +123,40 @@ else if(mode == 1) }else if(mode == 2) { - - g.setColor(Color.magenta); - g.setFont(new Font("serif", Font.BOLD, 100)); - g.drawString("Game done",240,100); + g.setFont(new Font("Agency FB", Font.BOLD, 30)); + g.setColor(Color.white); + g.drawString("Developed By Joseph Rother & Akshan Sameullah",470,570); if(dFs[0].getHealth() > 0) { - g.setFont(new Font("serif", Font.BOLD, 30)); + g.setFont(new Font("Agency FB", Font.BOLD, 190)); g.setColor(Color.red); - g.drawString("Read wiiiin",320,480); + g.drawString("Red Wins",360,200); + + + Graphics2D g2 = (Graphics2D) g; + AffineTransform at = new AffineTransform(); + at.setToRotation(Math.toRadians(270), 440, 380); + g2.setTransform(at); + g2.setColor(Color.magenta); + g2.setFont(new Font("Magneto", Font.BOLD, 170)); + g2.drawString("Game",250,80); + g2.drawString("Over",300,250); }else { - g.setFont(new Font("serif", Font.BOLD, 30)); - g.setColor(Color.cyan); - g.drawString("Blew wiiiin",320,480); - + g.setFont(new Font("Magneto", Font.BOLD, 200)); + g.setColor(Color.magenta); + g.drawString("Game",270,180); + g.drawString("Over",320,380); + + Graphics2D g2 = (Graphics2D) g; + AffineTransform at = new AffineTransform(); + at.setToRotation(Math.toRadians(270), 440, 380); + g2.setTransform(at); + g2.setColor(Color.cyan); + g2.setFont(new Font("Agency FB", Font.BOLD, 170)); + g2.drawString("Blue Wins",250,130); } + } g.dispose(); @@ -371,7 +395,9 @@ public void bringBack(Fighter f1) public void setAttacking (Fighter f1 , Platform plat, boolean[] inputs) { - if (inputs[4] == true) + if (inputs[5]) { + f1.setBlocking(true); + } else if (inputs[4] == true) { if(f1.getAttacking() == 0) { diff --git a/Driver.class b/Driver.class index d2174d5..a22e0c8 100644 Binary files a/Driver.class and b/Driver.class differ diff --git a/Driver.java b/Driver.java index ba51acc..8c6124a 100644 --- a/Driver.java +++ b/Driver.java @@ -1,50 +1,75 @@ +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; import javax.swing.*; - +import java.io.*; +import sun.audio.*; public class Driver { - public static void main(String[] args) - { - JFrame frame = new JFrame("Yeet Fighter"); - frame.setSize(965, 640); - frame.setLocation(200,100); - frame.setResizable(false); - frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - Display disp = new Display(); - frame.add(disp); - frame.setVisible(true); - - Fighter f1; - Fighter f2; - Platform plat = new Platform(550); - Fighter fighters[] = new Fighter[2]; - int m = 0; - while(disp.getMode() == 0) - { - - } - fighters = disp.loadGame(plat); - - int fps = 60; - double timePerTick = 1000000000 / fps; - double delta = 0; - long now; - long lastTime = System.nanoTime(); - - - - while (fighters[0].getHealth() > 0 && fighters[1].getHealth() > 0) - { - now = System.nanoTime(); - delta += (now - lastTime) / timePerTick; - lastTime = now; - - if(delta >= 1){ - boolean ins[][] = disp.getInputs(); - fighters = disp.update(fighters,plat,ins); - disp.draw(fighters); - delta--; - } - } - disp.endGame(fighters); - } + public static void main(String[] args) + { + playMusicInALoop("CoolBeats/Spectre.wav"); + JFrame frame = new JFrame("Yeet Fighter"); + frame.setSize(965, 640); + frame.setLocation(200,100); + frame.setResizable(false); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + Display disp = new Display(); + frame.add(disp); + frame.setVisible(true); + + Platform plat = new Platform(550); + Fighter fighters[] = new Fighter[2]; + while(disp.getMode() == 0) + {} + + fighters = disp.loadGame(plat); + + int fps = 60; + double timePerTick = 1000000000 / fps; + double delta = 0; + long now; + long lastTime = System.nanoTime(); + + + + while (fighters[0].getHealth() > 0 && fighters[1].getHealth() > 0) + { + now = System.nanoTime(); + delta += (now - lastTime) / timePerTick; + lastTime = now; + + if(delta >= 1){ + boolean ins[][] = disp.getInputs(); + fighters = disp.update(fighters,plat,ins); + disp.draw(fighters); + delta--; + } + } + disp.endGame(fighters); + } + public static void playMusic(String filename){ + InputStream music; + try{ + System.out.println("Playing Audio Once"); + music = new FileInputStream(new File(filename)); + AudioStream aud = new AudioStream(music); + AudioPlayer.player.start(aud); + } + catch(Exception e){ + System.out.println("Playing Music Once"); + } + } + public static void playMusicInALoop(String filename){ + try{ + AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(filename)); + Clip clip = AudioSystem.getClip(); + clip.open(inputStream); + clip.loop(Clip.LOOP_CONTINUOUSLY); + } + catch(Exception e){ + System.out.println(e); + playMusic(filename); + } + } } \ No newline at end of file diff --git a/Fighter$AirDirection.class b/Fighter$AirDirection.class index b30e584..56ef497 100644 Binary files a/Fighter$AirDirection.class and b/Fighter$AirDirection.class differ diff --git a/Fighter$AirDown.class b/Fighter$AirDown.class index b401046..38710b4 100644 Binary files a/Fighter$AirDown.class and b/Fighter$AirDown.class differ diff --git a/Fighter$AirNeutral.class b/Fighter$AirNeutral.class index 517ad5b..4d23f33 100644 Binary files a/Fighter$AirNeutral.class and b/Fighter$AirNeutral.class differ diff --git a/Fighter$Attack.class b/Fighter$Attack.class index 9181401..1c8f6d1 100644 Binary files a/Fighter$Attack.class and b/Fighter$Attack.class differ diff --git a/Fighter$BasicDirection.class b/Fighter$BasicDirection.class index cb6a4fe..81c3e41 100644 Binary files a/Fighter$BasicDirection.class and b/Fighter$BasicDirection.class differ diff --git a/Fighter$BasicNeutral.class b/Fighter$BasicNeutral.class index c3258f2..fbb02dd 100644 Binary files a/Fighter$BasicNeutral.class and b/Fighter$BasicNeutral.class differ diff --git a/Fighter$BasicUp.class b/Fighter$BasicUp.class index 4d61301..24a6bf4 100644 Binary files a/Fighter$BasicUp.class and b/Fighter$BasicUp.class differ diff --git a/Fighter.class b/Fighter.class index 470af9e..669bcbe 100644 Binary files a/Fighter.class and b/Fighter.class differ diff --git a/Fighter.java b/Fighter.java index 3af742a..8a663dc 100644 --- a/Fighter.java +++ b/Fighter.java @@ -8,6 +8,7 @@ public class Fighter boolean right = false; int attacking = 0; int attackT = 0; + boolean blocking; Fighter.Attack attack; @@ -83,7 +84,14 @@ public int getAttacking() { return this.attacking; } - + public boolean getBlocking() + { + return this.blocking; + } + public void setBlocking(boolean r) + { + this.blocking = r; + } public void setRight(boolean r) { this.right = r; @@ -113,7 +121,6 @@ public int getAttackT() public abstract class Attack { - double[] pos = new double[2]; int[] size = new int[2]; double damage; @@ -123,6 +130,7 @@ public abstract class Attack public double[] getKnockBack() { + return this.knockback; } @@ -208,31 +216,58 @@ public class AirNeutral extends Attack public class BasicDirection extends Attack { BasicDirection(){ - setPos(10,10); - setSize(150,10); - setDamage(40); - setKnockBack(40,-10); - setTime(20); + + if (blocking) { + setPos(10,10); + setSize(150,10); + setDamage(10); + setKnockBack(15,-10); + setTime(20); + } else { + setPos(10,10); + setSize(150,10); + setDamage(40); + setKnockBack(40,-10); + setTime(20); + } } } public class BasicNeutral extends Attack { BasicNeutral(){ - setPos(10,10); - setSize(70,30); - setDamage(150); - setKnockBack(60,-60); - setTime(30); + if (blocking) { + setPos(10,10); + setSize(70,30); + setDamage(50); + setKnockBack(30,-30); + setTime(30); + } else { + setPos(10,10); + setSize(70,30); + setDamage(150); + setKnockBack(60,-60); + setTime(30); + } + } } public class BasicUp extends Attack { BasicUp(){ - setPos(20,-10); - setSize(10,20); - setDamage(200); - setKnockBack(0,-200); - setTime(50); + if (blocking) { + setPos(20,-10); + setSize(10,20); + setDamage(50); + setKnockBack(0,-20); + setTime(50); + } else { + setPos(20,-10); + setSize(10,20); + setDamage(200); + setKnockBack(0,-200); + setTime(50); + } + } } } \ No newline at end of file diff --git a/Force.mp3 b/Force.mp3 new file mode 100644 index 0000000..8eee2cb Binary files /dev/null and b/Force.mp3 differ diff --git a/Platform.class b/Platform.class index b13bcdb..b429767 100644 Binary files a/Platform.class and b/Platform.class differ diff --git a/Spectre.mp3 b/Spectre.mp3 new file mode 100644 index 0000000..997d777 Binary files /dev/null and b/Spectre.mp3 differ