I am using Slick2d
Im using a tilemap for the world map and an image/spritesheet for the game character when I render the tilemap the sprite doesnt show up on screen. If I comment out the tilemap render method the sprite shows up there are no errors so i do not know if it is even possible to use a tilemap and a image file in same state here is my code.
import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
import org.newdawn.slick.tiled.TiledMap;
public class Play extends BasicGameState{
Image worldMap;
boolean quit = false;
boolean facingUp = false;
boolean facingDown = true;
boolean facingRight = false;
boolean facingLeft = false;
int[] duration = {200,200};
int health = 100;
float monsterPositionX = 0;
float monsterPositionY = 0;
float shiftX = monsterPositionX +320;
float shiftY = monsterPositionY +160;
public TiledMap map = null;
public Image monsterImage = null;
public SpriteSheet monsterSheet;
public Animation monster;
public Animation monsterAnimationDown;
public Animation monsterAnimationUp;
public Animation monsterAnimationLeft;
public Animation monsterAnimationRight;
public Animation monsterAttackUp;
public Animation monsterAttackDown;
public Animation monsterAttackRight;
public Animation monsterAttackLeft;
public Animation monsterDeath;
public Play(int state){
}
public void init(GameContainer gc, StateBasedGame sbg)throws SlickException{
monsterImage = new Image("/res/Monster.png");
monsterSheet = new SpriteSheet(monsterImage, 64 , 64);
map = new TiledMap("/res/MonsterMap.tmx","res");
monsterAnimationUp = new Animation(monsterSheet, 0,8,8,8,true,200,false);
monsterAnimationLeft = new Animation(monsterSheet, 0,9,8,9,true,200,false);
monsterAnimationDown = new Animation(monsterSheet, 0,10,8,10,true,200,false);
monsterAnimationRight = new Animation(monsterSheet, 0,11,8,11,true,200,false);
monsterAttackUp = new Animation(monsterSheet, 0,4,7,4,true,100,false);
monsterAttackLeft = new Animation(monsterSheet, 0,5,7,5,true,100,false);
monsterAttackDown = new Animation(monsterSheet, 0,6,7,6,true,100,false);
monsterAttackRight = new Animation(monsterSheet, 0,7,7,7,true,100,false);
monsterDeath = new Animation(monsterSheet, 0,20,4,20,true,200,false);
monster = monsterAnimationDown;
facingDown = true;
}
//renders images to screen0
public void render(GameContainer gc, StateBasedGame sbg, Graphics g)throws SlickException{
monster.draw(320,160);
//map.render(0,0);
if(quit == true){
g.drawString("Resume (R)", 250, 100);
g.drawString("Main Menu (M)", 250, 150);
g.drawString("Quit Game (Q)", 250, 200);
if(quit == false){
g.clear();
}
}
}
// changes translations of game objects
public void update(GameContainer gc, StateBasedGame sbg, int delta)throws SlickException{
Input input = gc.getInput();
//MOVEMENT
if(input.isKeyDown(Input.KEY_W)){
monster = monsterAnimationUp;
monster.update(delta);
monsterPositionY += delta *.1f;
facingUp = true;
}else if(input.isKeyDown(Input.KEY_S)){
monster = monsterAnimationDown;
monster.update(delta);
monsterPositionY -= delta *.1f;
facingDown = true;
} else if(input.isKeyDown(Input.KEY_D)){
monster = monsterAnimationRight;
monster.update(delta);
monsterPositionX += delta *.1f;
facingRight = true;
}else if(input.isKeyDown(Input.KEY_A)){
monster = monsterAnimationLeft;
monster.update(delta);
monsterPositionX -= delta *.1f;
facingLeft = true;
}
//DIAGNOL MOVEMENT
if(input.isKeyDown(Input.KEY_W)&& input.isKeyDown(Input.KEY_D)){
monster = monsterAnimationUp;
monster.update(delta);
monsterPositionY += delta *.1f;
monsterPositionX += delta *.1f;
facingUp = true;
}if(input.isKeyDown(Input.KEY_W)&& input.isKeyDown(Input.KEY_A)){
monster = monsterAnimationUp;
monster.update(delta);
monsterPositionY += delta *.1f;
monsterPositionX -= delta *.1f;
facingUp = true;
}if(input.isKeyDown(Input.KEY_S)&& input.isKeyDown(Input.KEY_D)){
monster = monsterAnimationDown;
monster.update(delta);
monsterPositionY -= delta *.1f;
monsterPositionX += delta *.1f;
facingDown = true;
}
if(input.isKeyDown(Input.KEY_S)&& input.isKeyDown(Input.KEY_A)){
monster = monsterAnimationDown;
monster.update(delta);
monsterPositionY -= delta *.1f;
monsterPositionX -= delta *.1f;
facingDown = true;
}
if(facingUp == true && input.isKeyDown(input.KEY_SPACE )){
monster = monsterAttackUp;
monster.update(delta);
}
if(facingDown == true && input.isKeyDown(input.KEY_SPACE )){
monster = monsterAttackDown;
monster.update(delta);
}
if(facingRight == true && input.isKeyDown(input.KEY_SPACE )){
monster = monsterAttackRight;
monster.update(delta);
}
if(facingLeft == true && input.isKeyDown(input.KEY_SPACE )){
monster = monsterAttackLeft;
monster.update(delta);
}
}
public int getID(){
return 1;
}
}
any and all help will be apprecieated also if i cannot use the tmx file with the png file is there a .tmx to .png converter.