![]() |
|
Views in allegro 5 |
xantier
Member #12,521
January 2011
|
I read the allegro 5 API but found no information about views. You have a room 3500x900 but the screen is 640x480. How can i make the screen follow the player ? And how can i divide room into views as i mentioned above |
Dario ff
Member #10,065
August 2008
![]() |
That really doesn't concern Allegro 5 since it's a bit higher level, it's up to you to do a "scrolling" camera. If your background is simply going to be one big bitmap, Allegro can draw specific regions of a bitmap using al_draw_bitmap_region. For any other map engines, there are plenty of tutorials around. TranslatorHack 2010, a human translation chain in a.cc. |
xantier
Member #12,521
January 2011
|
which functions should i use for scrolling camera ? |
23yrold3yrold
Member #1,134
March 2001
![]() |
I usually keep an x and y coordinate for a camera, personally. Set it to be offset from the player's position by a certain amount at all times. Then, during the render, I offset everything I draw by that x and y. Simplest way in my opinion. Allegro has no "function" for that. It's something you take care of. Or write a function for yourself. -- |
Todd Cope
Member #998
November 2000
![]() |
xantier said: which functions should i use for scrolling camera ? You can use transformations to "scroll the camera" if you don't want to offset your rendering manually. For example: ALLEGRO_TRANSFORM camera_transform; al_identity_transform(&camera_transform); al_translate_transform(&camera_transform, -camera_x, -camera_y); al_use_transform(&camera_transform); render_everything();
|
jmasterx
Member #11,410
October 2009
|
int camx; for each bitmap The idea is that if object is at 15 and camera is at 15, then by subtracting 15 it will be at 0 therefore in the center. Agui GUI API -> https://github.com/jmasterx/Agui |
|