I need to add collision to my tile map using MarteEngine. MarteEngine is built of of slick2D. Here's my tile generation code:
Code:
public void render(GameContainer gc, StateBasedGame game, Graphics g) throws SlickException
   {
      for (int x = 0; x < 16; x++) {
         for (int y = 0; y < 16; y++) {
            map[x][y] = AIR;
               air.draw(x * GameWorld.tilesize, y * GameWorld.tilesize);
         }
      }
   for (int x = 0; x < 16; x++) {
         for (int y = 7; y < 8; y++) {
               map[x][y] = GRASS;
               grass.draw(x * tilesize, y * tilesize);
         }
      }
   for (int x = 0; x < 16; x++) {
         for (int y = 8; y < 10; y++) {
            map[x][y] = DIRT;
               dirt.draw(x * tilesize, y * tilesize);
         }
      }
   for (int x = 0; x < 16; x++) {
         for (int y = 10; y < 16; y++) {
            map[x][y] = STONE;
               stone.draw(x * tilesize, y * tilesize);   
         }
      }
      super.render(gc, game, g);
   }
And one of my tile classes (they're all the same, the image names are just different):
Code:
package MarteEngine;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import it.randomtower.engine.entity.Entity;
public class Grass extends Entity {
   public static Image grass = null;
   public Grass(float x, float y) throws SlickException {
      super(x, y);
       grass = new Image("res/grass.png");
       setHitBox(0, 0, 50, 50);
       addType(SOLID);
   }
}
I tried to do it like this:
Code:
for (int x = 0; x < 16; x++) {
         for (int y = 7; y < 8; y++) {
               map[x][y] = GRASS;
               Grass.grass.draw(x * tilesize, y * tilesize);
         }
      }
But it gave me a NullPointerException. No idea why, everything looks initialized right? I would be very grateful for some help!