Sign in to follow this  
Fantastic Jason

a 2D Loaded Question-Scrolling

Recommended Posts

Hi people... Okay, so I am writing a 2D (Ortho Mode) scrolling platform game. The maps are Tiled. I have no problem in a basic scrolling screen...hooray...HOWEVER: 1) The scrolling is not ultra smooth. I currently draw a screen of textured quads (only 20 tiles wide x 12 tiles high (tiles 32 x 32 pixels)). As the player moves these are redrawn at new position until 32 is reached when the map array position changes. As GL clips all, would it be better to draw all the tiles of the world (lets say 120 tiles wide x 24 tiles high) which will then be clipped by GL to the viewport. Then move the camara position rather than draw the quads at ever changing positions? This would mean drawing 4320 tiles each frame rather than 240 tiles per frame?? HELP 2) As I am drawing whole quads to the screen, when the map array position changes I have a blank tile at one edge of the screen. Should I draw part quads to compensate for this part of a tile display or can I draw to a buffer an amount of tiles slightly bigger than the viewport then flip the buffers? Hope this makes sense...It just seems that what I am doing should not be so jerky....its not bad but not perfect??? Thanks in advance...

Share this post


Link to post
Share on other sites
Quote:
Original post by Fantastic Jason
Hi people...

Okay, so I am writing a 2D (Ortho Mode) scrolling platform game. The maps are Tiled. I have no problem in a basic scrolling screen...hooray...HOWEVER:

1) The scrolling is not ultra smooth. I currently draw a screen of textured quads (only 20 tiles wide x 12 tiles high (tiles 32 x 32 pixels)). As the player moves these are redrawn at new position until 32 is reached when the map array position changes. As GL clips all, would it be better to draw all the tiles of the world (lets say 120 tiles wide x 24 tiles high) which will then be clipped by GL to the viewport. Then move the camara position rather than draw the quads at ever changing positions? This would mean drawing 4320 tiles each frame rather than 240 tiles per frame?? HELP


One of the best options would be to create a set of display lists that each draw a screen-sized portion of the entire background (not just the visible part). You would have 12 such display lists. This way, you won't have to mention the vertex data every frame (it will most likely be cached) and you can also optimize state changes by grouping tiles by texture (texture changes are not cheap). Then, render to the screen the four display lists that are closest to your character with the correct translation in order to perform scrolling. This way, you will reduce the amount of transformed (and lighted) polygons, the amount of state changes and the flow of vertex data to the graphics card.

Quote:

2) As I am drawing whole quads to the screen, when the map array position changes I have a blank tile at one edge of the screen. Should I draw part quads to compensate for this part of a tile display or can I draw to a buffer an amount of tiles slightly bigger than the viewport then flip the buffers?


OpenGL has very efficient clipping, so you should just draw everything (as I suggested above) and it will not rasterize whatever is outside the screen.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this