Commit e505e771 authored by Nicholas Bindela's avatar Nicholas Bindela
Browse files

Changed to statebased game

parent 91aaecb0
/* *****************************************
* 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: MainGame
* Description:
*
* ****************************************
*/
package project;
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;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;
/**
*
* @author njb013
*/
public class MainGame extends BasicGameState {
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 MainGame() {
super();
}
public int getID() {
return 0;
}
public void init(GameContainer container, StateBasedGame sbg) throws SlickException {
container.setShowFPS(true);
container.setSmoothDeltas(true);
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, StateBasedGame sbg, 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, StateBasedGame sbg, 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);
}
}
}
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