Game Development Reference
In-Depth Information
case DIR_DOWN:
destination = new int []{col,row+1};
break ;
case DIR_LEFT:
destination = new int []{col-1,row};
break ;
case DIR_RIGHT:
destination = new int []{col+1,row};
break ;
case DIR_UP:
destination = new int []{col,row-1};
break ;
}
this .dx = destination[0]*TILE_SIZE;
this .dy = destination[1]*TILE_SIZE+TILE_SIZE-SPRITE_HEIGHT;
col = destination[0];
row = destination[1];
new Thread(){
public void run(){
int mv = MOVE_SPAN_M;
isLocked = true ; //non-alert mode
for ( int i=0;i<TILE_SIZE/mv;i++){
if (dx>x) x += mv;
else if (dx<x) x -= mv;
if (dy>y) y += mv;
else if (dy<y) y -= mv;
if (currSegment != direction) currSegment = direction;
//Detects collision
if (gv.isOverlapped(gv.hero.x,gv.hero.y,
SPRITE_WIDTH,SPRITE_HEIGHT,x,y,
SPRITE_WIDTH,SPRITE_HEIGHT,OVERLAP))
{
if (gv.gameState == STATE_PLAY){
Search WWH ::




Custom Search