Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.04 KB | None | 0 0
  1. //tiled.main ----------------------------
  2.  
  3.  
  4. package tiled;
  5.  
  6. import org.newdawn.slick.*;
  7. import org.newdawn.slick.state.*;
  8.  
  9. public class main extends StateBasedGame {
  10.  
  11.     private static final String gamename = "TiledWorld";
  12.    
  13.     public static final int play = 1;
  14.    
  15.     public main(String gamename) {
  16.         super(gamename);
  17.         this.addState(new play());
  18.     }
  19.  
  20.     @Override
  21.     public void initStatesList(GameContainer gc) throws SlickException {
  22.         this.getState(play).init(gc, this);
  23.     }
  24.      public static void main(String[] args) {
  25.           AppGameContainer appgc;
  26.           try{
  27.              appgc = new AppGameContainer(new main(gamename));
  28.              appgc.setDisplayMode(800, 600, false);
  29.              appgc.setTargetFrameRate(60);
  30.              appgc.start();
  31.           }catch(SlickException e){
  32.              e.printStackTrace();
  33.           }
  34.      }
  35. }
  36.  
  37. //tiled.play -------------------------------
  38.  
  39. package tiled;
  40.  
  41. import org.newdawn.slick.*;
  42. import org.newdawn.slick.state.*;
  43.  
  44. public class play extends BasicGameState {
  45.        
  46.         int xSize = 10;
  47.         int ySize = 10;
  48.         int xSizeA = 0;
  49.         int ySizeA = 0;
  50.         int state;
  51.         Image grass1;
  52.         public play() {
  53.                 this.state = 1;
  54.         }
  55.         public void init(GameContainer gc, StateBasedGame sbg)
  56.                         throws SlickException {
  57.                 grass1 = new Image("res/grass1.png");
  58.                
  59.         }
  60.  
  61.         public void render(GameContainer gc, StateBasedGame sbg, Graphics g)
  62.                 throws SlickException {
  63.             xSizeA = 0;
  64.             ySizeA = 0;
  65.             for (int i = 0; i < 10; ++i) {
  66.                 for (int j = 0; j < 10; ++j) {
  67.                     g.drawImage(grass1, xSizeA, ySizeA);
  68.                     xSizeA += 50;
  69.                     }
  70.                 xSizeA = 0;
  71.                 ySizeA += 50;
  72.                 }
  73.             }
  74.         public void update(GameContainer gc, StateBasedGame sbg, int delta)
  75.                         throws SlickException {
  76.                
  77.         }
  78.  
  79.         public int getID() {
  80.                 return this.state;
  81.         }
  82.        
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement