Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #14

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
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.
79 changes: 58 additions & 21 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,6 +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].getBlocking()) {
g.setColor(Color.white);
g.fillRect((int)dFs[1].getPos()[0]+10, (int)dFs[1].getPos()[1]+10, 30, 30);
}
if(dFs[0].getAttacking() == 1){
g.setColor(Color.red);
//g.setColor(Color.green);
Expand All @@ -101,10 +105,17 @@ else if(mode == 1)

g.fillRect(i[0],i[1],i[2],i[3]);
}

if (dFs[1].getBlocking()) {
g.setColor(Color.white);
g.fillRect((int)dFs[0].getPos()[0]+10, (int)dFs[0].getPos()[1]+10, 30, 30);
}
g.setColor(Color.cyan);
g.fillRect((int)dFs[1].getPos()[0],(int)dFs[1].getPos()[1],dFs[1].getSize(),dFs[1].getSize());

if (dFs[0].getBlocking()) {
g.setColor(Color.white);
g.fillRect((int)dFs[1].getPos()[0]+10, (int)dFs[1].getPos()[1]+10, 30, 30);
}

if(dFs[1].getAttacking() == 1){
g.setColor(Color.cyan);
//g.setColor(Color.green);
Expand All @@ -117,22 +128,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 @@ -171,7 +200,7 @@ public void keyPressed(KeyEvent e)
{
buttons[0][4] = true;
}
if(e.getKeyChar() == 'g')
if(e.getKeyChar() == '/')
{
buttons[0][5] = true;
}
Expand All @@ -195,7 +224,7 @@ public void keyPressed(KeyEvent e)
{
buttons[1][4] = true;
}
if(e.getKeyChar() == '/')
if(e.getKeyChar() == 'g')
{
buttons[1][5] = true;
}
Expand Down Expand Up @@ -227,7 +256,7 @@ public void keyReleased(KeyEvent e)
{
buttons[0][4] = false;
}
if(e.getKeyChar() == 'g')
if(e.getKeyChar() == '/')
{
buttons[0][5] = false;
}
Expand All @@ -251,7 +280,7 @@ public void keyReleased(KeyEvent e)
{
buttons[1][4] = false;
}
if(e.getKeyChar() == '/')
if(e.getKeyChar() == 'g')
{
buttons[1][5] = false;
}
Expand Down Expand Up @@ -371,7 +400,9 @@ public void bringBack(Fighter f1)

public void setAttacking (Fighter f1 , Platform plat, boolean[] inputs)
{
if (inputs[4] == true)

f1.setBlocking(inputs[5]);
if (inputs[4] == true)
{
if(f1.getAttacking() == 0)
{
Expand Down Expand Up @@ -407,20 +438,26 @@ public void setAttacking (Fighter f1 , Platform plat, boolean[] inputs)
f1.setAttacking(1);
}
}

}

public void incrementAttack(Fighter f1, Fighter f2)
{
if(f1.getAttacking() == 1)

if(f1.getAttacking() == 1)
{
if(f1.getAttackT() == 5)
{
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.setHealth(f2.getHealth() - f1.getAttack().getDamage());
// if (!f1.getBlocking()) {
f2.setHealth(f2.getHealth() - f1.getAttack().getDamage());
// } else {
// f2.setHealth(f2.getHealth());
// }
if(f1.getRight() == true){
f2.setKnockBackVel(f1.getAttack().getKnockBack()[0],f1.getAttack().getKnockBack()[1]);
}else
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.
Loading