image - Creating a 2D grid for a board game in Java using Slick2D -


i need create 2d grid of fixed size e.g 20x20 using java slick lib. have array [ ][ ] containing symbols (text). these symbols stand different tiles (squares) on board.

i know how render/draw individual images onto screen not sure how same grid (loop? wouldn't rendering game?). should concept of spritesheets ?

ideally thought of creating

  1. tile object: tilexpos, tileypos, size, image(based on type)
  2. grid object: tile tiles[ ][ ]

i wouldn't know how draw/render screen. should draw in init method below , game start re-draw accordingly in update method ?

would appreciate guidance.

import org.newdawn.slick.*; import org.newdawn.slick.state.*;   public class gameplaystate extends basicgamestate {      public gameplaystate(int stateid){      }       public void init(gamecontainer container, statebasedgame game)             throws slickexception {     }      public void render(gamecontainer container, statebasedgame game, graphics g)             throws slickexception {     }      public void update(gamecontainer container, statebasedgame game, int delta)             throws slickexception {     }      public int getid() {         return 1;     } } 

i use tiled: http://www.mapeditor.org/

slick2d has support tiled's .tmx files. create 20 x 20 tile map symbols. can access every tile in tile map , properties (position, layer, , other custom properties defined in tiled). and, best don't have render whole map. can render section of it, wanted. take here, in slick2d wiki:

http://slick.ninjacave.com/wiki/index.php?title=tiled_import_and_usage

you can check in javadoc: http://slick.ninjacave.com/javadoc/

say if need code. n.n


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -