Javascript(gameQuery game) how can I get the next bottom element in the tilemap? -
how can next bottom element (id, class) of selected tile without loop through whole tilemap? e.g.: tile $('.gq_tiletype_4') rock in game , should fall down if next bottom tile $('.gq_tiletype_8') space is. loop throug whole tilemap , compare elements against there xy coordinates. think wrong way, because game performance slowing down.
gamequery gives unique id each tiles constructed in following way:
$.gamequery.tileidprefix+name+"_"+row+"_"+column
this means if tilemap called "foo" can access tile @ position (a,b) writing:
$("#"+$.gamequery.tileidprefi+"foo_"+a+"_"+b);
in same way can deduce position (index-wise) of tile parsing it's id. means given tile can find it's position , probe state of tile bellow.
how ever i'm not sure using tile-maps best solution since not supposed change. @ moment shouldn't cause problems cannot guaranty in future version wont break functions collision detection.
in situation use sprites display elements. make game logic implementation of game faster store tiles states in two-dimensional array reference associated sprite.
this way can work array , update associated sprites if need to.
Comments
Post a Comment