Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //tiled.main ----------------------------
- package tiled;
- import org.newdawn.slick.*;
- import org.newdawn.slick.state.*;
- public class main extends StateBasedGame {
- private static final String gamename = "TiledWorld";
- public static final int play = 1;
- public main(String gamename) {
- super(gamename);
- this.addState(new play());
- }
- @Override
- public void initStatesList(GameContainer gc) throws SlickException {
- this.getState(play).init(gc, this);
- }
- public static void main(String[] args) {
- AppGameContainer appgc;
- try{
- appgc = new AppGameContainer(new main(gamename));
- appgc.setDisplayMode(800, 600, false);
- appgc.setTargetFrameRate(60);
- appgc.start();
- }catch(SlickException e){
- e.printStackTrace();
- }
- }
- }
- //tiled.play -------------------------------
- package tiled;
- import org.newdawn.slick.*;
- import org.newdawn.slick.state.*;
- public class play extends BasicGameState {
- int xSize = 10;
- int ySize = 10;
- int xSizeA = 0;
- int ySizeA = 0;
- int state;
- Image grass1;
- public play() {
- this.state = 1;
- }
- public void init(GameContainer gc, StateBasedGame sbg)
- throws SlickException {
- grass1 = new Image("res/grass1.png");
- }
- public void render(GameContainer gc, StateBasedGame sbg, Graphics g)
- throws SlickException {
- xSizeA = 0;
- ySizeA = 0;
- for (int i = 0; i < 10; ++i) {
- for (int j = 0; j < 10; ++j) {
- g.drawImage(grass1, xSizeA, ySizeA);
- xSizeA += 50;
- }
- xSizeA = 0;
- ySizeA += 50;
- }
- }
- public void update(GameContainer gc, StateBasedGame sbg, int delta)
- throws SlickException {
- }
- public int getID() {
- return this.state;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement