Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

add more characters on the same Tile map Slick2D  RSS feed

 
Adryan Bone
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,please help me with that problem.I tried to add another character on the same map with own input key, but that character don't apear

this is my code:
public class Map extends BasicGameState {
int[] duration={200,200,};
boolean quit=false;
int heroPositionX=0;
int heroPositionY=0;
float shiftX= heroPositionX+400;
float shiftY= heroPositionY+302;
//////////////////////////////////
int enemyPositionX=0;
int enemyPositionY=0;
float shifteX= heroPositionX+600;
float shifteY= heroPositionY+302;






public TiledMap mapt;
private Image im;
/////////////////////////////
private Image en;

@Override
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException {
mapt=new TiledMap("maps/1.tmx");
im=new Image("K.png");
//////////////////////
en=new Image("Deidara chars.png");

}

@Override
public void render(GameContainer gc, StateBasedGame arg1, Graphics g) throws SlickException {
mapt.render(heroPositionX, heroPositionY);
im.draw(shiftX, shiftY,37,66);
en.draw(shifteX,shifteY,40,66);
g.drawString("hero X:"+ heroPositionX+"\nhero Y: "+ heroPositionY,400,20);
////////////////////////////////////////
mapt.render(enemyPositionX, enemyPositionY);
im.draw(shifteX, shifteY,37,66);
g.drawString("enemy X:"+ enemyPositionX+"\nhero Y: "+ enemyPositionY,600,10);






}

@Override
public void update(GameContainer gc, StateBasedGame s, int delta) throws SlickException {




Input input=gc.getInput();
if(input.isKeyDown(Input.KEY_RIGHT)){
heroPositionX -=delta *.2f;

}
if(input.isKeyDown(Input.KEY_LEFT)){
heroPositionX +=delta *.2f;}
if(input.isKeyDown(Input.KEY_UP)){
heroPositionY +=delta *.2f;


}

if(input.isKeyDown(Input.KEY_DOWN)){
heroPositionY -=delta *.2f;}
if(heroPositionY<-439&&(heroPositionX<218)){

heroPositionY+=delta* .2f;}
if(heroPositionY<-583){


s.enterState(4);}
//////////////////////////////



if(input.isKeyDown(Input.KEY_D)){
enemyPositionX -=delta *.2f;

}
if(input.isKeyDown(Input.KEY_A)){
enemyPositionX +=delta *.2f;}
if(input.isKeyDown(Input.KEY_W)){
enemyPositionY +=delta *.2f;


}

if(input.isKeyDown(Input.KEY_S)){
enemyPositionY -=delta *.2f;}

}






@Override
public int getID() {

return 5;
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!