Commit 434941b7 authored by Melissa Tjong's avatar Melissa Tjong
Browse files

Merge origin/master into Melissa2

parents cbf43429 eaec7ca0
File added
......@@ -21,7 +21,7 @@ import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import project.MainGame;
import project.Level1;
/**
*
......@@ -29,6 +29,8 @@ import project.MainGame;
*/
public class Laser extends Entity {
boolean isPrimed;
@Override
public void render(GameContainer gc, Graphics g) {
......@@ -41,13 +43,13 @@ public class Laser extends Entity {
@Override
public void init() {
width = MainGame.WIDTH;
width = Level1.WIDTH;
height = 50;
x = 0;
y = (float) (Math.random() * (MainGame.HEIGHT - height));
y = (float) (Math.random() * (Level1.HEIGHT - height));
try {
image = new Image("Images/laser_on.png");
image = image.getScaledCopy(MainGame.WIDTH, image.getHeight());
image = image.getScaledCopy(Level1.WIDTH, image.getHeight());
} catch (SlickException ex) {
Logger.getLogger(Laser.class.getName()).log(Level.SEVERE, null, ex);
}
......
......@@ -23,7 +23,7 @@ import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import project.MainGame;
import project.Level1;
/**
*
......@@ -67,8 +67,8 @@ public class Player extends Entity {
public void init() {
width = 100;
height = 100;
x = MainGame.WIDTH / 2;
y = (float) (MainGame.HEIGHT - height);
x = Level1.WIDTH / 2;
y = (float) (Level1.HEIGHT - height);
try {
if (image == null && !sprite) {
image = new Image("Images/Link.png");
......
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 25, 2019
* Time: 2:30:51 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: GameOver
* Description:
*
* ****************************************
*/
package project;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author njb013
*/
public class GameOver extends BasicGameState {
private Image gameOver;
private Input input = null;
private Music loseMusic;
GameOver(int state) {
}
@Override
public int getID() {
return Main.LOSE;
}
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
gameOver = new Image("Images/gameOver.png");
loseMusic = new Music("Music/loseMusic.ogg");
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
g.setColor(Color.black);
g.drawRect(0, 0, Level1.WIDTH, Level1.HEIGHT);
gameOver.draw(0, 0, Level1.WIDTH, Level1.HEIGHT);
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
input = container.getInput();
if (input.isMousePressed(0)) {
loseMusic.stop();
game.enterState(Main.MAINMENU);
}
if (!loseMusic.playing()) {
loseMusic.loop();
}
}
}
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 25, 2019
* Time: 2:34:17 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: GameWin
* Description:
*
* ****************************************
*/
package project;
import java.awt.Font;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.TrueTypeFont;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author njb013
*/
public class GameWin extends BasicGameState {
private TrueTypeFont tff;
private Input input = null;
private Music winMusic;
GameWin(int state) {
}
@Override
public int getID() {
return Main.WIN;
}
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
Font font = new Font("Courier", Font.BOLD, 50);
tff = new TrueTypeFont(font, true);
winMusic = new Music("Music/sweetVictory.ogg");
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
g.setColor(Color.white);
g.fillRect(0, 0, Level1.WIDTH, Level1.HEIGHT);
float width = ((Level1.WIDTH) / 2) - tff.getWidth("YOU WIN");
tff.drawString(width, (Level1.HEIGHT) / 2, "YOU WIN!",
Color.black);
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
input = container.getInput();
if (input.isMousePressed(0)) {
winMusic.stop();
game.enterState(Main.LOSE);
}
if (!winMusic.playing()) {
winMusic.loop();
}
}
}
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 25, 2019
* Time: 3:44:58 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: Level
* Description:
*
* ****************************************
*/
package project;
import entities.Laser;
import entities.Player;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author njb013
*/
public abstract class Level extends BasicGameState {
private Player character = null;
private Image background = null;
private Image fireImage = null;
Music mainMusic = null;
private SpriteSheet xeonSheet = null;
private Animation playerAnimation;
private float startY = (float) (HEIGHT - char_Height);
private float startX = WIDTH / 6;
public static final int HEIGHT = 700;
public static final int WIDTH = 1500;
private static int char_Width = 100;
private static int char_Height = 100;
private static float backgroundX2 = (float) WIDTH;
private static float backgroundX = (float) 0.0;
private static float dX = (float) 1;
public static int pointCounter;
private String meters = "M";
private int topScore;
private boolean isRising = false;
private boolean isFalling = false;
Laser laser;
public static final int levelLength = 5000;
public int getTopScore() {
return topScore;
}
public Level(int state) {
super();
}
public void setTopScore(int topScore) {
this.topScore = topScore;
}
public abstract int getID();
public abstract void init(GameContainer container, StateBasedGame sbg) throws SlickException;
public abstract void update(GameContainer container, StateBasedGame sbg,
int delta) throws SlickException;
public abstract void render(GameContainer container, StateBasedGame sbg,
Graphics g) throws SlickException;
}
......@@ -8,7 +8,7 @@
*
* Project: csci205FinalProject_SP19
* Package: project
* File: MainGame
* File: Level1
* Description:
*
* ****************************************
......@@ -17,8 +17,6 @@ package project;
import entities.Laser;
import entities.Player;
import java.util.ArrayList;
import java.util.ListIterator;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
......@@ -27,36 +25,26 @@ import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author njb013
*/
public class MainGame extends BasicGameState {
public class Level1 extends Level {
private Player character = null;
private Image background = null;
private Image fireImage = null;
Music mainMusic = null;
private SpriteSheet xeonSheet = null;
private Animation playerAnimation;
ArrayList<Image> backgrounds = new ArrayList<Image>();
ListIterator<Image> changeBackground;
ArrayList<Music> songs = new ArrayList<Music>();
ListIterator<Music> playList;
Music mainMusic;
private float startY = (float) (HEIGHT - char_Height);
private float startX = WIDTH / 6;
private float fireStartX;
private float fireStartY;
public static final int HEIGHT = 700;
public static final int WIDTH = 1500;
......@@ -67,7 +55,6 @@ public class MainGame extends BasicGameState {
private static float backgroundX = (float) 0.0;
private static float dX = (float) 1;
private int pointCounter = 0;
private String meters = "M";
private int topScore;
......@@ -85,42 +72,22 @@ public class MainGame extends BasicGameState {
this.topScore = topScore;
}
public MainGame(int state) {
super();
public Level1(int state) {
super(state);
}
public int getID() {
return 1;
return Main.LVL1;
}
public void init(GameContainer container, StateBasedGame sbg) throws SlickException {
container.setSmoothDeltas(true);
pointCounter = 0;
Image city = new Image("Images/city.png");
Image game_background_1 = new Image("Images/game_background_1.png");
Image game_background_2 = new Image("Images/game_background_2.png");
Image game_background_3 = new Image("Images/game_background_3.png");
Image dancy = new Image("Images/DancyChris.png");
Image bravo = new Image("Images/Bravo.png");
city = city.getScaledCopy(WIDTH + 55, HEIGHT);
game_background_1 = game_background_1.getScaledCopy(WIDTH + 55, HEIGHT);
game_background_2 = game_background_2.getScaledCopy(WIDTH + 55, HEIGHT);
game_background_3 = game_background_3.getScaledCopy(WIDTH + 55, HEIGHT);
dancy = dancy.getScaledCopy(WIDTH + 55, HEIGHT);
bravo = bravo.getScaledCopy(WIDTH + 55, HEIGHT);
backgrounds.add(city);
backgrounds.add(game_background_1);
backgrounds.add(game_background_2);
backgrounds.add(game_background_3);
backgrounds.add(dancy);
backgrounds.add(bravo);
background = backgrounds.get(0);
changeBackground = backgrounds.listIterator();
background = city;
//character = new Player(new Image("Images/Link.png"));
SpriteSheet charSprite = new SpriteSheet("Images/xeonSprite.png", 56,
......@@ -142,14 +109,7 @@ public class MainGame extends BasicGameState {
fireImage = fireImage.getScaledCopy(50, 100);
Music sonic = new Music("Music/SonicTheme.ogg");
Music gerudo = new Music("Music/GerudoValley.ogg");
songs.add(sonic);
songs.add(gerudo);
mainMusic = songs.get(0);
playList = songs.listIterator();
mainMusic = sonic;
laser = new Laser();
}
......@@ -163,11 +123,11 @@ public class MainGame extends BasicGameState {
}
if (input.isKeyDown(Input.KEY_SPACE)) {
startY -= 1;
startY -= 0.75;
isRising = true;
}
else {
startY += 1;
startY += 0.75;
isRising = false;
isFalling = true;
}
......@@ -180,20 +140,9 @@ public class MainGame extends BasicGameState {
startY = 0;
}
pointCounter += 1;
if ((pointCounter % 6000 == 0)) {
if (changeBackground.hasNext()) {
background = changeBackground.next();
}
else if (!changeBackground.hasNext()) {
changeBackground = backgrounds.listIterator();
}
if (playList.hasNext()) {
mainMusic = playList.next();
}
else {
playList = songs.listIterator();
}
if ((pointCounter % levelLength == 0)) {
mainMusic.stop();
sbg.enterState(Main.LVL2);
}
}
......@@ -217,6 +166,7 @@ public class MainGame extends BasicGameState {
//g.setColor(Color.black);
g.drawString(Integer.toString(pointCounter / 20) + meters, 0, 0);
g.drawString(Integer.toString(getTopScore()) + meters, 0, 20);
g.drawString("Level " + Integer.toString(this.getID()), WIDTH - 70, 0);
Input input = container.getInput();
......@@ -241,5 +191,4 @@ public class MainGame extends BasicGameState {
//laser.image.draw(100, 100);
//xeonSheet.draw();
}
}
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 25, 2019
* Time: 3:38:11 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: Level2
* Description:
*
* ****************************************
*/
package project;
import entities.Laser;
import entities.Player;
import org.newdawn.slick.Animation;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.SpriteSheet;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author njb013
*/
public class Level2 extends Level {
private Player character = null;
private Image background = null;
private Image fireImage = null;
Music mainMusic = null;
private SpriteSheet xeonSheet = null;
private Animation playerAnimation;
private float startY = (float) (HEIGHT - char_Height);
private float startX = WIDTH / 6;
public static final int HEIGHT = 700;
public static final int WIDTH = 1500;
private static int char_Width = 100;
private static int char_Height = 100;
private static float backgroundX2 = (float) WIDTH;
private static float backgroundX = (float) 0.0;
private static float dX = (float) 1;
private String meters = "M";
private int topScore;
private boolean isRising = false;
private boolean isFalling = false;
Laser laser;
public int getTopScore() {
return topScore;
}
public void setTopScore(int topScore) {
this.topScore = topScore;
}
public Level2(int state) {
super(state);
}
public int getID() {
return Main.LVL2;
}
public void init(GameContainer container, StateBasedGame sbg) throws SlickException {
container.setSmoothDeltas(true);
Image game_background_1 = new Image("Images/game_background_1.png");
game_background_1 = game_background_1.getScaledCopy(WIDTH + 55, HEIGHT);
background = game_background_1;
//character = new Player(new Image("Images/Link.png"));
SpriteSheet charSprite = new SpriteSheet("Images/xeonSprite.png", 56,
64);
Image rising = new Image("Images/xeonRising.png");
Image falling = new Image("Images/xeonFalling.png");
rising = rising.getScaledCopy(56, 64);
falling = falling.getScaledCopy(56, 64);
character = new Player(charSprite, rising,
falling);
//character.setImage(character.getImage().getScaledCopy(char_Width,
// char_Height));
//xeonSheet = new SpriteSheet("Images/xeonsheet.bmp", 45, 70);
if (character.hasSprite()) {
character.getAnimation().setPingPong(false);
}
fireImage = new Image("Images/Fireball_Vertical.png");
fireImage = fireImage.getScaledCopy(50, 100);
Music circuit = new Music("Music/CircuitTheme.ogg");
mainMusic = circuit;
laser = new Laser();
}