diff --git a/Display.class b/Display.class index cbb1f93..c21bd02 100644 Binary files a/Display.class and b/Display.class differ diff --git a/Display.java b/Display.java index 80a742e..6d75a32 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; @@ -17,7 +18,6 @@ public class Display extends JPanel implements KeyListener private double s = 2; private double j = 20; - private double mX = 10; private double g = 1.5; private double f = 1.3; private double kf = 1.09; @@ -83,18 +83,32 @@ public void paint(Graphics g) } else if(mode == 1) { + g.setColor(Color.white); g.fillRect(0,yMin, 1000, 10); - g.setColor(Color.red); - + Color healthbar1 = new Color(255-(int)((dFs[0].getHealth()/totalH) * 255),(int)((dFs[0].getHealth()/totalH) * 255),0);//(int)((dFs[0].getHealth()/totalH) * 255)/2 ); + g.setColor(healthbar1); g.fillRect(10,10,(int)((dFs[0].getHealth()/totalH) * 465),10); - g.fillRect(480,10,(int)((dFs[1].getHealth()/totalH) * 465),10); + Color healthbar2 = new Color(255-(int)((dFs[1].getHealth()/totalH) * 255),(int)((dFs[1].getHealth()/totalH) * 255),0);//(int)((dFs[1].getHealth()/totalH) * 255)/2 ); + g.setColor(healthbar2); + g.fillRect(480+(465-(int)((dFs[1].getHealth()/totalH) * 465)),10,(int)((dFs[1].getHealth()/totalH) * 465),10); + g.setColor(Color.red); + + + if(dFs[0].getAttacking() == 2) + { + g.setColor(new Color(150, 0, 0)); + }else + { + g.setColor(new Color(255, 0, 0)); + } + 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].getAttacking() == 1) + { g.setColor(Color.red); - //g.setColor(Color.green); int[] i = new int[4]; i = attackHitBox(dFs[0]); @@ -102,12 +116,32 @@ else if(mode == 1) g.fillRect(i[0],i[1],i[2],i[3]); } - g.setColor(Color.cyan); + if(dFs[0].getBlocking() != 0) + { + if(dFs[0].getBlocking() == 1) + { + g.setColor(new Color(255, 255, 255)); + }else + { + g.setColor(new Color(150, 150, 150)); + } + g.fillRect((int) (dFs[0].getPos()[0] + 10) ,(int) (dFs[0].getPos()[1] + 10), dFs[0].getSize() -20 , dFs[0].getSize() - 20); + } + + + if(dFs[1].getAttacking() == 2) + { + g.setColor(new Color(0, 150, 150)); + }else + { + g.setColor(new Color(0, 255, 255)); + } + g.fillRect((int)dFs[1].getPos()[0],(int)dFs[1].getPos()[1],dFs[1].getSize(),dFs[1].getSize()); - if(dFs[1].getAttacking() == 1){ - g.setColor(Color.cyan); - //g.setColor(Color.green); + if(dFs[1].getAttacking() == 1) + { + g.setColor(new Color(0, 255, 255)); int[] i = new int[4]; i = attackHitBox(dFs[1]); @@ -115,23 +149,55 @@ else if(mode == 1) g.fillRect(i[0],i[1],i[2],i[3]); } + if(dFs[1].getBlocking() != 0) + { + if(dFs[1].getBlocking() == 1) + { + g.setColor(new Color(255, 255, 255)); + }else + { + g.setColor(new Color(150, 150, 150)); + } + g.fillRect((int) (dFs[1].getPos()[0] + 10) ,(int) (dFs[1].getPos()[1] + 10), dFs[1].getSize() -20 , dFs[1].getSize() - 20); + } + + + }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); } } @@ -148,113 +214,109 @@ public void keyPressed(KeyEvent e) { if (mode == 0){ mode = 1; - }else - if(mode == 1) + } + + if(e.getKeyChar() == 'w') { - if(e.getKeyChar() == 'w') - { - buttons[0][0] = true; - } - if(e.getKeyChar() == 'a') - { - buttons[0][1] = true; - } - if(e.getKeyChar() == 's') - { - buttons[0][2] = true; - } - if(e.getKeyChar() == 'd') - { - buttons[0][3] = true; - } - if(e.getKeyChar() == 'f') - { - buttons[0][4] = true; - } - if(e.getKeyChar() == 'g') - { - buttons[0][5] = true; - } - if(e.getKeyCode() == KeyEvent.VK_UP) - { - buttons[1][0] = true; - } - if(e.getKeyCode() == KeyEvent.VK_LEFT) - { - buttons[1][1] = true; - } - if(e.getKeyCode() == KeyEvent.VK_DOWN) - { - buttons[1][2] = true; - } - if(e.getKeyCode() == KeyEvent.VK_RIGHT) - { - buttons[1][3] = true; - } - if(e.getKeyChar() == '.') - { - buttons[1][4] = true; - } - if(e.getKeyChar() == '/') - { - buttons[1][5] = true; - } + buttons[0][0] = true; + } + if(e.getKeyChar() == 'a') + { + buttons[0][1] = true; + } + if(e.getKeyChar() == 's') + { + buttons[0][2] = true; + } + if(e.getKeyChar() == 'd') + { + buttons[0][3] = true; + } + if(e.getKeyChar() == 'f') + { + buttons[0][4] = true; + } + if(e.getKeyChar() == 'g') + { + buttons[0][5] = true; + } + if(e.getKeyCode() == KeyEvent.VK_UP) + { + buttons[1][0] = true; + } + if(e.getKeyCode() == KeyEvent.VK_LEFT) + { + buttons[1][1] = true; + } + if(e.getKeyCode() == KeyEvent.VK_DOWN) + { + buttons[1][2] = true; + } + if(e.getKeyCode() == KeyEvent.VK_RIGHT) + { + buttons[1][3] = true; + } + if(e.getKeyChar() == '.') + { + buttons[1][4] = true; + } + if(e.getKeyChar() == '/') + { + buttons[1][5] = true; } } @Override public void keyReleased(KeyEvent e) { - if(mode == 1) + + if(e.getKeyChar() == 'w') { - if(e.getKeyChar() == 'w') - { - buttons[0][0] = false; - } - if(e.getKeyChar() == 'a') - { - buttons[0][1] = false; - } - if(e.getKeyChar() == 's') - { - buttons[0][2] = false; - } - if(e.getKeyChar() == 'd') - { - buttons[0][3] = false; - } - if(e.getKeyChar() == 'f') - { - buttons[0][4] = false; - } - if(e.getKeyChar() == 'g') - { - buttons[0][5] = false; - } - if(e.getKeyCode() == KeyEvent.VK_UP) - { - buttons[1][0] = false; - } - if(e.getKeyCode() == KeyEvent.VK_LEFT) - { - buttons[1][1] = false; - } - if(e.getKeyCode() == KeyEvent.VK_DOWN) - { - buttons[1][2] = false; - } - if(e.getKeyCode() == KeyEvent.VK_RIGHT) - { - buttons[1][3] = false; - } - if(e.getKeyChar() == '.') - { - buttons[1][4] = false; - } - if(e.getKeyChar() == '/') - { - buttons[1][5] = false; - } + buttons[0][0] = false; + } + if(e.getKeyChar() == 'a') + { + buttons[0][1] = false; + } + if(e.getKeyChar() == 's') + { + buttons[0][2] = false; + } + if(e.getKeyChar() == 'd') + { + buttons[0][3] = false; + } + if(e.getKeyChar() == 'f') + { + buttons[0][4] = false; + } + if(e.getKeyChar() == 'g') + { + buttons[0][5] = false; + } + if(e.getKeyCode() == KeyEvent.VK_UP) + { + buttons[1][0] = false; + } + if(e.getKeyCode() == KeyEvent.VK_LEFT) + { + buttons[1][1] = false; + } + if(e.getKeyCode() == KeyEvent.VK_DOWN) + { + buttons[1][2] = false; + } + if(e.getKeyCode() == KeyEvent.VK_RIGHT) + { + buttons[1][3] = false; + } + if(e.getKeyChar() == '.') + { + buttons[1][4] = false; + } + if(e.getKeyChar() == '/') + { + buttons[1][5] = false; } } @@ -276,6 +338,12 @@ public boolean[][] getInputs() public Fighter[] update(Fighter[] fs, Platform plat, boolean[][] inputs) { + setBlocking(fs[0],inputs[0]); + setBlocking(fs[1],inputs[1]); + + incrementBlock(fs[0]); + incrementBlock(fs[1]); + setAttacking(fs[0],plat,inputs[0]); setAttacking(fs[1],plat,inputs[1]); @@ -369,9 +437,52 @@ public void bringBack(Fighter f1) } } + public void setBlocking (Fighter f1, boolean[] inputs) + { + if (inputs[5] == true) + { + if(f1.getBlocking() == 0) + { + System.out.println("weewoo"); + f1.setBlocking(1); + } + } + } + + public void incrementBlock(Fighter f1) + { + if(f1.getBlocking() == 1) + { + if(f1.getBlockT() == 20) + { + + f1.setBlockT(0); + System.out.println("wombo"); + f1.setBlocking(2); + }else + { + f1.setBlockT(f1.getBlockT() + 1); + } + } + + if(f1.getBlocking() == 2) + { + if(f1.getBlockT() == 240) + { + f1.setBlockT(0); + System.out.println("welmpo"); + f1.setBlocking(0); + } + else + { + f1.setBlockT(f1.getBlockT() + 1); + } + } + } + public void setAttacking (Fighter f1 , Platform plat, boolean[] inputs) { - if (inputs[4] == true) + if (inputs[4] == true && f1.getBlocking() != 1) { if(f1.getAttacking() == 0) { @@ -418,7 +529,7 @@ public void incrementAttack(Fighter f1, Fighter f2) int[] i = new int[4]; i = attackHitBox(f1); - if (i[0] <= f2.getPos()[0] + f2.getSize() && i[0] + i[2] >= f2.getPos()[0] && i[1] <= f2.getPos()[1] + f2.getSize() && i[1] + i[3] >= f2.getPos()[1]) + if (i[0] <= f2.getPos()[0] + f2.getSize() && i[0] + i[2] >= f2.getPos()[0] && i[1] <= f2.getPos()[1] + f2.getSize() && i[1] + i[3] >= f2.getPos()[1] && f2.getBlocking() != 1) { f2.setHealth(f2.getHealth() - f1.getAttack().getDamage()); if(f1.getRight() == true){ diff --git a/Driver.class b/Driver.class index d2174d5..07dea47 100644 Binary files a/Driver.class and b/Driver.class differ diff --git a/Driver.java b/Driver.java index ba51acc..367601c 100644 --- a/Driver.java +++ b/Driver.java @@ -1,9 +1,15 @@ +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; +import javax.sound.sampled.Clip; import javax.swing.*; - +import java.io.*; +import javax.sound.sampled.*; +import javax.sound.sampled.DataLine.Info; public class Driver { public static void main(String[] args) { + playContinuous("Spectre.wav"); JFrame frame = new JFrame("Yeet Fighter"); frame.setSize(965, 640); frame.setLocation(200,100); @@ -19,9 +25,7 @@ public static void main(String[] args) Fighter fighters[] = new Fighter[2]; int m = 0; while(disp.getMode() == 0) - { - - } + {} fighters = disp.loadGame(plat); int fps = 60; @@ -47,4 +51,52 @@ public static void main(String[] args) } disp.endGame(fighters); } -} \ No newline at end of file +// 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); +// } +// } + public static void playContinuous(String filename){ + try{ + AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File(filename)); + DataLine.Info lineInfo = new DataLine.Info(SourceDataLine.class, inputStream.getFormat()); + SourceDataLine clip = (SourceDataLine)AudioSystem.getLine(lineInfo); + clip.open(inputStream.getFormat()); + clip.start(); + final int BUFFERSIZE = 1024; + byte[] buffer = new byte[BUFFERSIZE]; + int bytesRead = -1; + bytesRead = inputStream.read(buffer); + while (bytesRead != 1){ + clip.write(buffer, 0 ,bytesRead); + bytesRead = inputStream.read(buffer); + } + clip.drain(); + clip.close(); + inputStream.close(); + } + catch(Exception e){ + System.out.println(e); +// playMusic(filename); + } + } +} diff --git a/Fighter$AirDirection.class b/Fighter$AirDirection.class index b30e584..a6a0bb5 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..0c47f94 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..c2be183 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..318b603 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..5ae4a1a 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..642de49 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..5604acf 100644 Binary files a/Fighter$BasicUp.class and b/Fighter$BasicUp.class differ diff --git a/Fighter.class b/Fighter.class index 470af9e..0cd8761 100644 Binary files a/Fighter.class and b/Fighter.class differ diff --git a/Fighter.java b/Fighter.java index 3af742a..9e2dae2 100644 --- a/Fighter.java +++ b/Fighter.java @@ -8,6 +8,8 @@ public class Fighter boolean right = false; int attacking = 0; int attackT = 0; + int blocking = 0; + int blockT = 0; Fighter.Attack attack; @@ -83,6 +85,16 @@ public int getAttacking() { return this.attacking; } + + public void setBlocking(int a) + { + this.blocking = a; + } + + public int getBlocking() + { + return this.blocking; + } public void setRight(boolean r) { @@ -104,6 +116,16 @@ public int getAttackT() return this.attackT; } + public void setBlockT(int a) + { + this.blockT = a; + } + + public int getBlockT() + { + return this.blockT; + } + @@ -182,7 +204,7 @@ public class AirDirection extends Attack setSize(120,10); setDamage(50); setKnockBack(120,-10); - setTime(30); + setTime(20); } } public class AirDown extends Attack @@ -200,7 +222,7 @@ public class AirNeutral extends Attack AirNeutral(){ setPos(20,20); setSize(50,50); - setDamage(100); + setDamage(110); setKnockBack(40,-10); setTime(25); } @@ -229,9 +251,9 @@ public class BasicUp extends Attack { BasicUp(){ setPos(20,-10); - setSize(10,20); + setSize(10,10); setDamage(200); - setKnockBack(0,-200); + setKnockBack(4,-200); setTime(50); } } 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/Spectre.mp3 b/Spectre.mp3 new file mode 100644 index 0000000..997d777 Binary files /dev/null and b/Spectre.mp3 differ