Commit 1e383f32 authored by Nicholas Bindela's avatar Nicholas Bindela
Browse files

Changed to statebased game

parent e505e771
/* *****************************************
* CSCI205 - Software Engineering and Design
* Spring 2019
*
* Name: Aditi Vijayvergia, Melissa Tjong, Mitch Gavars, and Nick Bindela
* Date: Apr 16, 2019
* Time: 8:35:57 PM
*
* Project: csci205FinalProject_SP19
* Package: project
* File: SetUpClass
* Description:
*
* ****************************************
*/
package project;
import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
/**
*
* @author njb013
*/
public class SetUpClass extends BasicGame {
private Image character = null;
private Image background = null;
private Image fireImage = null;
private float startY = (float) (HEIGHT - char_Height);
private float startX = WIDTH / 2;
private float fireStartX;
private float fireStartY;
private static final int HEIGHT = 600;
private static final int WIDTH = 800;
private static int char_Width = 100;
private static int char_Height = 100;
public SetUpClass(String title) {
super(title);
}
public void init(GameContainer container) throws SlickException {
container.setShowFPS(false);
character = new Image(
"Images/Link.png");
background = new Image("Images/city.png");
character = character.getScaledCopy(char_Width, char_Height);
background = background.getScaledCopy(WIDTH, HEIGHT);
fireImage = new Image("Images/Fireball_Vertical.png");
fireImage = fireImage.getScaledCopy(50, 100);
}
public void update(GameContainer container, int delta) throws SlickException {
Input input = container.getInput();
if (input.isKeyDown(Input.KEY_SPACE)) {
startY -= 1;
}
else {
startY += 1;
}
if (startY >= HEIGHT - (char_Height)) {
startY = HEIGHT - (char_Height);
}
if (startY < 0) {
startY = 0;
}
}
public void render(GameContainer container, Graphics g) throws SlickException {
background.draw();
character.draw(startX, startY);
Input input = container.getInput();
if (input.isKeyDown(Input.KEY_SPACE)) {
fireImage.draw(startX + 10, startY + 80);
}
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws SlickException {
AppGameContainer app = new AppGameContainer(new SetUpClass(
"Jetpack Joyride"));
app.setDisplayMode(WIDTH, HEIGHT, false);
app.start();
}
}
Supports Markdown
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