Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package world0;
- 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;
- public class GameplayState extends BasicGameState
- {
- int stateID = -1;
- Image background = null;
- Image background1 = null;
- Image background2 = null;
- Image ground = null;
- private Player player;
- GameplayState (int stateID)
- {
- this.stateID = stateID;
- }
- @Override
- public int getID()
- {
- return stateID;
- }
- public void init (GameContainer gc, StateBasedGame sbg) throws SlickException
- {
- background = new Image("textures/levels/world_0/background0.jpg");
- background1 = new Image("textures/levels/world_0/background1.png");
- background2 = new Image("textures/levels/world_0/background2.png");
- player = new Player(200, 608, new Image("textures/charakters/spieler1.png"));
- ground = new Image("textures/levels/world_0/ground.jpg");
- }
- public void render (GameContainer gc, StateBasedGame sbg, Graphics g) throws SlickException
- {
- background.draw();
- background1.draw(0, 120);
- background2.draw(0, 100);
- player.draw(g);
- ground.draw(0, gc.getHeight() - ground.getHeight());
- }
- public void update (GameContainer gc, StateBasedGame sbg, int delta) throws SlickException
- {
- Input input = gc.getInput();
- // yet useless
- int mouseX = input.getMouseX();
- int mouseY = input.getMouseY();
- if (input.isKeyPressed(Input.KEY_RIGHT))
- {
- player.updateR(delta);
- }
- if (input.isKeyPressed(Input.KEY_LEFT))
- {
- player.updateL(delta);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement