Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified Display.class
Binary file not shown.
54 changes: 40 additions & 14 deletions Display.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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();
Expand Down Expand Up @@ -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)
{
Expand Down
Binary file modified Driver.class
Binary file not shown.
117 changes: 71 additions & 46 deletions Driver.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Binary file modified Fighter$AirDirection.class
Binary file not shown.
Binary file modified Fighter$AirDown.class
Binary file not shown.
Binary file modified Fighter$AirNeutral.class
Binary file not shown.
Binary file modified Fighter$Attack.class
Binary file not shown.
Binary file modified Fighter$BasicDirection.class
Binary file not shown.
Binary file modified Fighter$BasicNeutral.class
Binary file not shown.
Binary file modified Fighter$BasicUp.class
Binary file not shown.
Binary file modified Fighter.class
Binary file not shown.
69 changes: 52 additions & 17 deletions Fighter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class Fighter
boolean right = false;
int attacking = 0;
int attackT = 0;
boolean blocking;
Fighter.Attack attack;


Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -113,7 +121,6 @@ public int getAttackT()

public abstract class Attack
{

double[] pos = new double[2];
int[] size = new int[2];
double damage;
Expand All @@ -123,6 +130,7 @@ public abstract class Attack

public double[] getKnockBack()
{

return this.knockback;
}

Expand Down Expand Up @@ -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);
}

}
}
}
Binary file added Force.mp3
Binary file not shown.
Binary file modified Platform.class
Binary file not shown.
Binary file added Spectre.mp3
Binary file not shown.