Erm..
I'll try.
*Goes off to comment bits of code*
//_x and _y are the x and y screen offsets of the maze's top-left corner
//tile_size = 32
//tile_map_xMax = maximum no. of tiles in the maze, width-wise
//tile_map_yMax = maximum no. of tiles in the maze, height-wise
//tile_spr_map = 2D array containing pointers to "Sprite" classes
//The "Sprite" is just a wrapper class with a stack because I'm too lazy to remember which numbers belong to which sprite; I just call Sprite::getInstance([argument list]) to get a sprite and call [some sprite]->release() when I am done with it.
//tile_val_map = 2D array containing integers that represent which tiles belong to which part of the maze
//tiles = 1D array containing Images
//Image = wrapper class for DGDK's dbImage
void Maze::drawMaze(int _x, int _y) {
int drawX = _x/-tile_size,
drawY = _y/-tile_size;
for (int x=0; x<21; x++) {
for (int y=0; y<16; y++) {
if (drawX+x >= 0 && drawX+x < tile_map_xMax && drawY+y >= 0 && drawY+y < tile_map_yMax) {
tile_spr_map[x][y]->setImage(tiles[tile_val_map[drawX+x][drawY+y]]);
tile_spr_map[x][y]->setXY(_x+(drawX+x)*tile_size, _y+(drawY+y)*tile_size);
}
}
}
}
.
.
.
//We don't need to care about isAnimation for the current problem
//img is a Image* member
//getID() returns the ID of the resource "Image"
void Sprite::setImage(Image* newImg) {
if (isAnimation) {
dbDeleteSprite(id);
isAnimation = false;
isPause = true;
frame_delay = 200;
}
img = newImg;
dbSprite(id, x, y, img->getID());
}
.
.
.
void Sprite::setXY(int newX, int newY) {
//Simple enough, xy position changes
x = newX;
y = newY;
drawSelf();
}
.
.
.
void Sprite::drawSelf () {
if (!isPause && isAnimation) {
dbPlaySprite(id, anim_start, anim_end, frame_delay);
}
dbSprite(id, x, y, img->getID());
}
And the loop:
while (LoopGDK()) {
dbCLS(); //dbCLS() is always at the top of the loop
//Some other unimportant stuff
//calls a method that calculates stuff and calls drawMaze(x, y)
dbSync(); //Always at the bottom of the loop
}
First year student of a game-programming course