I've got something basic to work, but looking for thoughts on how/if it can be done better. I've downloaded source for SuperVDP but its in assembly and I am making my game demo in C (plus I'm not sure I need some of those features yet).
Below you can see I have created a "floor" with a single repeating tile.
Its not quite as smooth as before. I sort of expected that. But not too choppy yet.
Here is roughly the algorithm I use. The tiles are arbitrarily 16x16
Code: Select all
for(background_tile_x = 0;background_tile_x < MAP_SCREEN_WIDTH; background_tile_x++)
{
for(background_tile_y = 10;background_tile_y < MAP_SCREEN_HEIGHT; background_tile_y++)
{
//where map_tiles[0] contains my 16x16 tile
drawSprite(map_tiles[0],
background_tile_x * BG_TILE_SIZE,
background_tile_y * BG_TILE_SIZE,
BG_TILE_SIZE,
BG_TILE_SIZE,0);
}
}
- Is there something specifically bad about how I've built my for loops? Note that each drawSprite() call involves drawing pixels to the part of the framebuffer. It was logical to me and it seemed flexible so in the future I'll have a lookup to a tilemap where I'll have what tile to draw at each square. Maybe there is a better way to draw the data, like going across an entire line in one pass or something?
- I could do a "dirty rectangle" algorithm, and try to redraw only tiles that have a sprite move in front of them. But I think in the long term its going to be more work when I have a lot more sprites plus the entire background may be scrolling as the characters walk around.
- Is there any best practice around how large the tiles should be? I just picked 16x16 as it seemed to make sense. Not sure any significance to how large or small it needs to be.
- Is there any standard way that I can follow to represent the tile map for a level or stage?
- What about scrolling this horizontally? I would probably start that by just redrawing with the tiles shifted left or right, then maybe drawing different tiles from the map.
Edit: and how can we measure performance more quantitatively? Fusion seems to always tell me around 60 fps no matter how choppy the gameplay seems to be.
Thank you