arrays - Moving object, maze game -
i'm new in java , right working on simple maze game. thing is, object moving in console doesn't on scene, seems object not updated on gridpane. have tried many things can not find, problem, may need animationtimer update gridpane?:
this 1 part of moving, (array located in method):
tilemap.add(hero.getplayer(); hero.getx()/50; hero.gety()/50); public void mapscene2() { tilemap = new gridpane(); stage stage = new stage(); scene scene = new scene( tilemap, maplengthtiles * tilesizepx, maplengthtiles * tilesizepx ); scene.setonkeypressed( new eventhandler<keyevent>() { @override public void handle(keyevent event) { switch (event.getcode()) { case a: case left: { hero.move( -50, 0, -1, 0 ); system.out.println( "move left" ); break; } class of player: public class player{ public static int x, y, tilex, tiley; public rectangular gamer; public player{ x=50; y=50; tilex=1; tiley=1; gamer=new rectangular(x, y); } public rectangular getplayer(){ return gamer; } public int getx(){ return x; } public int gety(){ return y; } public int gettilex(){ return tilex; } public int gettiley(){ return tiley; } public void move(int dx, int dy, int tx, int ty){ x+=dx; y+=dy; tilex+=tx; tiley+=ty;
Comments
Post a Comment