Game Development Reference
In-Depth Information
case
DIR_DOWN:
if
(dir == DIR_UP)
this
.y -= MOVE_SPAN;
else this
.y += MOVE_SPAN;
//Detects collision
if
(gv.checkCollision()){
this
.x = TILE_SIZE*
this
.col;
this
.y
=
TILE_SIZE*
this
.row+TILE_SIZE-
SPRITE_HEIGHT;
ret =
false
;
}
else
{
this
.row = (
this
.y+SPRITE_HEIGHT-SPRITE_WIDTH/2)/
TILE_SIZE;
}
break
;
case
DIR_LEFT:
case
DIR_RIGHT:
if
(dir == DIR_LEFT)
this
.x -= MOVE_SPAN;
else this
.x += MOVE_SPAN;
//Detects collision
if
(gv.checkCollision()){
this
.x = TILE_SIZE*
this
.col;
this
.y
=
TILE_SIZE*
this
.row+TILE_SIZE-
SPRITE_HEIGHT;
ret =
false
;
}
else
{
this
.col = (
this
.x+SPRITE_WIDTH/2)/TILE_SIZE;
}
break
;
default
:
break
;
}
//Sets the current direction and animation segment.
this
.direction = dir;
Search WWH ::
Custom Search