Game Development Reference
In-Depth Information
//The main drawing method that takes care of drawing objects:
//sprites, maps, bonuses, and others.
//Parameters:
// canvas - a Canvas to hold the draw calls
public void doDraw(Canvas canvas){
//retrieves hero's position
int heroX = hero.x;
int heroY = hero.y;
int hRow = (heroY+SPRITE_HEIGHT-1) / TILE_SIZE ;
int hCol = (heroX+SPRITE_WIDTH-1) / TILE_SIZE;
int tempStartRow = this .startRow;
int tempStartCol = this .startCol;
int tempOffsetX = this .offsetX;
int tempOffsetY = this .offsetY;
//Clears off screen
canvas.drawColor(Color.BLACK);
//Displays background image
if (father.screenType>1) BitmapManager.drawGamePublic(0,canvas,0,0);
else BitmapManager.drawSystemPublic(19,canvas,0,0);
//Displays objects through a for loop
for ( int i=-1; i<=SCREEN_ROWS; i++){
if (tempStartRow+i < 0 || tempStartRow+i>=MAP_ROWS){
continue ;
}
for ( int j=-1; j<=SCREEN_COLS; j++){
if (tempStartCol+j <0 || tempStartCol+j>=MAP_COLS){
continue ;
}
//layers & maps
for (Layer l:layerList.layerList){
if (l.mapMatrix[tempStartRow+i][tempStartCol+j]
!= null &&
Search WWH ::




Custom Search