Game Development Reference
In-Depth Information
This method determines whether 2 objects, hero and any bonus in the vicinity, are overlap-
ping on the scene, if so, the hero will pick up the bonus.
//Picks up bonuses. Checks whether the 2 bounding boxes overlap
//Parameters:
// stage - the current stage (level)
// row - row# of hero
// col - column# of hero
public void pickBonus( int stage, int row, int col) {
int b = 0;
for ( int i=-1;i<2;i++){
for ( int j=-1;j<2;j++){
b = getBonusId(stage,row+i,col+j);
if (b>0 && !isDelPoints(row+i,col+j) &&
isOverlapped(hero.x-DA,
hero.y-DA,
SPRITE_WIDTH+2*DA,
SPRITE_HEIGHT+2*DA,
(col+j)*TILE_SIZE,
(row+i)*TILE_SIZE,
TILE_SIZE,
TILE_SIZE,
OVERLAP1))
{
getReward(b,row+i,col+j);
return ;
}
}
}
}
Overridden Surface Methods
Here are the 3 overridden Surface related methods implemented in the Game View:
@Override
public void surfaceCreated(SurfaceHolder holder) {
dt.isViewOn = true ;
if (! dt.isAlive()){
Search WWH ::




Custom Search