Commit f3509bb1 authored by Melissa Tjong's avatar Melissa Tjong
Browse files

Choose Character Screen

parent 7f120c37
Images/xeonStand.png

2.49 KB | W: | H:

Images/xeonStand.png

26.7 KB | W: | H:

Images/xeonStand.png
Images/xeonStand.png
Images/xeonStand.png
Images/xeonStand.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -45,12 +45,7 @@ public abstract class Entity extends Box {
public abstract void init();
public void render(GameContainer gc, Graphics g) {
/*if (image != null) {
image.draw(x, y, width, height, color);
}
else if (spriteSheet != null) {
playerAnimation.draw(x, y, width, height);
}*/
}
}
......@@ -53,7 +53,6 @@ public class Obstacle extends Entity {
}
@Override
public void update(GameContainer gc, int delta) {
if (this.getEndX() > 0) {
x -= speed;
......
......@@ -34,26 +34,23 @@ import project.Level1;
public class Player extends Entity {
private boolean sprite = false;
private Image risingImage = null;
private Image fallingImage = null;
public Image risingImage = null;
public Image fallingImage = null;
private boolean isRising = false;
private boolean isFalling = false;
private int character;
public Player() {
super();
}
public Player(Image i) {
super();
this.image = i;
}
public Player(SpriteSheet s, Image rise, Image fall) {
sprite = true;
this.spriteSheet = s;
risingImage = rise;
fallingImage = fall;
public Player(int character) {
this.character = character;
// sprite = true;
// this.spriteSheet = s;
// risingImage = rise;
// fallingImage = fall;
init();
}
......@@ -99,19 +96,41 @@ public class Player extends Entity {
height = 100;
x = Level1.WIDTH / 6;
y = (float) (Level1.HEIGHT - height);
try {
if (image == null && !sprite) {
image = new Image("Images/Link.png");
if (this.character == 0) {
try {
this.image = new Image("Images/xeonStand.png");
this.spriteSheet = new SpriteSheet("Images/xeonSprite.png", 56,
64);
this.risingImage = new Image("Images/xeonRising.png");
this.fallingImage = new Image("Images/xeonFalling.png");
playerAnimation = new Animation(spriteSheet, 75);
width = image.getWidth();
height = image.getHeight();
} catch (SlickException ex) {
Logger.getLogger(Player.class.getName()).log(Level.SEVERE, null,
ex);
}
else if (sprite) {
image = new Image("Images/xeonStand.png");
}
if (this.character == 1) {
try {
this.image = new Image("Images/megaManIcon.png");
this.spriteSheet = new SpriteSheet("Images/megaManSprite.png",
114,
100);
this.risingImage = new Image("Images/megaManRising.png");
this.fallingImage = new Image("Images/megaManFalling.png");
playerAnimation = new Animation(spriteSheet, 75);
width = image.getWidth();
height = image.getHeight();
} catch (SlickException ex) {
Logger.getLogger(Player.class.getName()).log(Level.SEVERE, null,
ex);
}
} catch (SlickException ex) {
Logger.getLogger(Player.class.getName()).log(Level.SEVERE, null, ex);
}
}
public Image getRisingImage() {
......
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 17, 2019
* Time: 7:20:05 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: MainMenu
* Description:
*
* ****************************************
*/
package project;
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
/**
*
* @author mt034
*/
public class ChooseCharacter extends BasicGameState {
Image xeon;
Image megaMan;
Image background;
Image back;
Image backInverted;
Music menuMusic;
private float xeonWidth;
private float xeonHeight;
private float xeonX;
private float xeonY;
private float megaManX;
private float megaManY;
private float megaManWidth;
private float megaManHeight;
private float backWidth;
private float backHeight;
private static final int HEIGHT = Level1.HEIGHT;
private static final int WIDTH = Level1.WIDTH;
private final float backX = WIDTH / 2.5f;
private final float backY = 450;
private boolean overBack = false;
private Input input = null;
ChooseCharacter(int state) {
}
@Override
public int getID() {
return Main.CHOOSECHAR;
}
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
background = new Image("Images/city.png");
xeon = new Image("Images/xeonStand.png");
megaMan = new Image("Images/megaManIcon.png");
back = new Image("Images/Back.png");
backInverted = new Image("Images/BackInverted.png");
background = background.getScaledCopy(WIDTH, HEIGHT);
menuMusic = new Music("Music/bucknellfight.ogg");
xeonWidth = xeon.getWidth();
xeonHeight = xeon.getHeight();
xeonX = 600;
xeonY = 250;
megaManX = 720;
megaManY = 250;
megaManWidth = megaMan.getWidth();
megaManHeight = megaMan.getHeight();
backWidth = back.getWidth();
backHeight = back.getHeight();
}
@Override
public void render(GameContainer container, StateBasedGame game, Graphics g) throws SlickException {
background.draw();
xeon.draw(xeonX, xeonY);
megaMan.draw(megaManX, megaManY);
back.draw(backX, backY);
if (overBack) {
backInverted.draw(backX, backY);
}
}
@Override
public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
input = container.getInput();
int posX = input.getMouseX();
int posY = input.getMouseY();
if ((posX > backX && posX < (backX + backWidth)) && (posY > backY && posY < (backY + backHeight))) {
overBack = true;
}
else {
overBack = false;
}
if (input.isMousePressed(0)) {
if ((posX > backX && posX < (backX + backWidth)) && (posY > backY && posY < (backY + backHeight))) {
game.getState(Main.MAINMENU).init(container, game);
game.enterState(Main.MAINMENU);
}
if ((posX > xeonX && posX < (xeonX + xeonWidth)) && (posY > xeonY && posY < (xeonY + xeonHeight))) {
game.getState(Main.MAINMENU).init(container, game);
MainMenu.chosenPlayer = 0;
game.enterState(Main.MAINMENU);
}
if ((posX > megaManX && posX < (megaManX + megaManWidth)) && (posY > megaManY && posY < (megaManY + megaManHeight))) {
game.getState(Main.MAINMENU).init(container, game);
MainMenu.chosenPlayer = 1;
game.enterState(Main.MAINMENU);
}
}
}
}
......@@ -65,7 +65,6 @@ public class Level1 extends Level {
private boolean isRising = false;
private boolean isFalling = false;
Animation backgroundAnimation;
ArrayList<Laser> lasers;
Laser laser;
......@@ -102,19 +101,16 @@ public class Level1 extends Level {
city = city.getScaledCopy(WIDTH + 55, HEIGHT);
background = city;
//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);
switch (MainMenu.chosenPlayer) {
case 0:
character = new Player(0);
break;
case 1:
character = new Player(1);
break;
}
if (character.hasSprite()) {
character.getAnimation().setPingPong(false);
}
......@@ -133,19 +129,12 @@ public class Level1 extends Level {
backgroundX2 += dX;
backgroundX += dX;
// for (Laser l : lasers) {
// l.x -= dX;
// l.image.draw(laser.x, laser.y);
// }
laser.x -= dX;
laser.image.draw(laser.x, laser.y);
if (character.hasSprite()) {
character.getAnimation().update(delta);
}
// if (character.hitTest(laser) == true) {
// sbg.enterState(Main.LOSE);
// }
character.update(container, delta);
......@@ -188,7 +177,6 @@ public class Level1 extends Level {
mainMusic.loop();
}
//g.setColor(Color.black);
g.drawString(Integer.toString(pointCounter / 20) + meters, 0, 0);
g.drawString(Integer.toString(getTopScore()) + meters, 0, 20);
......@@ -201,8 +189,6 @@ public class Level1 extends Level {
for (Obstacle o : obstacles) {
o.render(container, g);
}
//laser.image.draw(100, 100);
//xeonSheet.draw();
}
public float getStartY() {
......
......@@ -90,19 +90,16 @@ public class Level2 extends Level {
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);
switch (MainMenu.chosenPlayer) {
case 0:
character = new Player(0);
break;
case 1:
character = new Player(1);
break;
}
if (character.hasSprite()) {
character.getAnimation().setPingPong(false);
}
......
......@@ -91,19 +91,16 @@ public class Level3 extends Level {
background = game_background_2;
//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);
switch (MainMenu.chosenPlayer) {
case 0:
character = new Player(0);
break;
case 1:
character = new Player(1);
break;
}
if (character.hasSprite()) {
character.getAnimation().setPingPong(false);
}
......
......@@ -90,19 +90,16 @@ public class Level4 extends Level {
background = game_background_3;
//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);
switch (MainMenu.chosenPlayer) {
case 0:
character = new Player(0);
break;
case 1:
character = new Player(1);
break;
}
if (character.hasSprite()) {
character.getAnimation().setPingPong(false);
}
......
......@@ -89,19 +89,16 @@ public class Level5 extends Level {
background = dancy;
//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);
switch (MainMenu.chosenPlayer) {
case 0:
character = new Player(0);
break;
case 1:
character = new Player(1);
break;
}
if (character.hasSprite()) {
character.getAnimation().setPingPong(false);
}
......
......@@ -90,19 +90,16 @@ public class Level6 extends Level {
background = bravo;
//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);
switch (MainMenu.chosenPlayer) {
case 0:
character = new Player(0);
break;
case 1:
character = new Player(1);
break;
}
if (character.hasSprite()) {
character.getAnimation().setPingPong(false);
}
......
......@@ -37,6 +37,7 @@ public class Main extends StateBasedGame {
public static final int LVL6 = 6;
public static final int LOSE = 7;
public static final int WIN = 8;
public static final int CHOOSECHAR = 9;
public Main(String name) {
super(name);
......@@ -49,6 +50,7 @@ public class Main extends StateBasedGame {
this.addState(new Level4(LVL4));
this.addState(new Level5(LVL5));
this.addState(new Level6(LVL6));
this.addState(new ChooseCharacter(CHOOSECHAR));
}
@Override
......@@ -62,6 +64,7 @@ public class Main extends StateBasedGame {
this.getState(LVL6).init(container, this);
this.getState(LOSE).init(container, this);
this.getState(WIN).init(container, this);
this.getState(CHOOSECHAR).init(container, this);
this.enterState(MAINMENU);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment