I would like my character to be the center of the screen at all times. I am using allegro and C++. Right now I am rendering the full 30x30 map at all times. But my end goal is to have only 9x9 rendering at once. I don't know if I should do this by changing the displays variables. (tried this but it just changed the windows size.) Or change the which part of the map is displayed. ( I tried this but the character wasnt centered and the map did change but character moved left, and the map followed. So I stayed in the same spot indefinitely. )
I achieved this result with this code.
for(int col=0;col<height;col++) { for(int row=0;row<width;row++) { al_draw_bitmap_region(tileset, mv[col][row].sx * 16, mv[col][row].sy * 16, 16, 16, (row*16 + hero.wloc*16), col*16, 0); } }
And it looks like this (Before and after 7 movements. Notice how the character isnt centered and the map isnt being drawn around him.)
Here is something I am curious about. Should I draw the whole map or only the part I am currently on?
for(int col=0;col<height;col++) { for(int row=0;row<width;row++) { al_draw_bitmap_region(tileset, mv[col][row].sx * 16, mv[col][row].sy * 16, 16, 16, row*16, col*16, 0); } }
For reference here is a screenshot of my character. Notice how he is in the bottom right corner.
Okay. I deleted the previous attempt at centering and this is how my character is displayed. Every time he moves the screen stays stationary. (notice how he is at bottom right of screen instead of centered.)
The following video is an example of how I want my character to behave.
">
A release of my game.
https://www.dropbox.com/s/pxnnfmvwgslkxcs/negfaron.rar
Source code
main.cpp - http://pastie.org/5565697
make_map.h - http://pastie.org/5565698
main.h - http://pastie.org/5565699
Display initialization
ALLEGRO_DISPLAY* display = NULL;