Pure game programming problem


For example: a rectangle, rotating in the plane. (The actual rotation, not just the camera)
Camera how to follow the rotation?

Edgar Reynaldo

Thank you for your help. I think it's very useful. ;D

But, obviously, I can't find this example.

Neil Roy

There is no "ex_camera.c" for Allegro 5 (that comes with the source anyhow). Allegro 4 has that though.

I honestly can't find an equivalent example for Allegro 5.

Edgar Reynaldo

Yes, yes there is. It's right there in the examples folder. ex_camera.c .

Yes, Allegro 5 has ex_camera.c .


Neil Roy

The last version of Allegro 5 I have doesn't have it (which honestly surprised me as it used to be there).

Strange. (checks version I have) I have v5.1.9 source on my system... so a little out of date. I just noticed it is in 5.2.2, last compiled version I have, my bad, sorry. ;)

Edgar Reynaldo

I get mine from github with git, so I always have an up to date version. If you'll kindly remember, when we were messing around with skyboxes and opengl = never did get that to work using a triangle fan ??? )Elias pointed out that he updated ex_camera.c to use a skybox.

You should really try building allegro again sometime. It's a very satisfying experience to have it all do what you tell it to. That's the problem with computers, they only do what you tell them to, disregarding hardware failure.

Neil Roy

Elias pointed out that he updated ex_camera.c to use a skybox.

You're right. I checked that out. Looked good.

I dont' use a triangle fan for skyboxes. Just a cube made up of either quads or two triangles per side. There isn't much of a hit on performance no matter which way you do it. I kind of like quads for it so when I view everything in wireframe mode I just see a normal box. I'm not sure how one would do a cube with a triangle fan. Check my City3D source I sent you, you should be able to copy the OpenGL from it straight into Allegro as the OpenGL is independent of that.

I still have yet to build Allegro 5, though I came close. It is a better option, I just always seem to run into problems. Never had a problem with Allegro 4. It's those Allegro 5 dependencies that always get me.

Edgar Reynaldo

I'll teach you a trick. I've already compiled all the dependencies for you.

Use those binaries I gave you. They include the /include and /lib folders for all the dependencies to build allegro yourself. Just use cmake-gui and specify the correct directories and libraries for allegro to link to.

Or you can do like the manual suggests and use the build/deps directory to store the lib and include folders for the dependencies. Makes it easier so I hear.

Just check out allegro from git here : https://github.com/liballeg/allegro5.git

At a c:\ prompt, enter the following :

mkdir allegro
cd allegro
git clone https://github.com/liballeg/allegro5.git
git checkout master
git pull
mkdir build
cd build
mkdir deps
copy c:\path\to\distrofolder\* deps\
mkdir include
mkdir lib
mkdir bin
cmake-gui -DCMAKE_INSTALL_PREFIX=.\ ..
{specify a whole bunch of stuff, hope it sees the deps folder}
make install

And you'll note I had to patch several libraries. I'll see if there are newer versions that fix the problems the old ones had.


@Edgar Reynaldo

Hello, developer. :)
I play your game, "skyline", I feel there are many deficiencies.
For example, why do I need to press esc to open the menu?
Moreover, there are bug, the upper left corner "aimed Cross" of the screen.

But it is still as it was like, I do not know how to play. ;D

However, although there are many problems, but he still is a complete game.
However, I would like to ask, Allegro supports transparent bitmaps do?

I checked your picture, found a lot of purple background, can not directly use the transparent background? ???

Edgar Reynaldo

I made skyline in 24 hours. There are bugs I never got around to fixing. It was made with allegro 4 not 5.


Sorry, I did not notice. :-[
However, Allegro 5 supports a transparent background? :)

Edgar Reynaldo

Yes , by loading a proper image file such as 32 bit png. I think .tga is supported too.



Oh, that's awesome. :D

Neil Roy

My Deluxe Pacman 2 game is written in C using Allegro 5 and it uses all PNGs for the menu buttons etc... all have transparent backgrounds. The player, ghosts, pills etc... are all transparent PNGs.


@Neil Roy

I also play your game, but as always.
I am still easily eaten by ghosts. :P

Talking about, do you have a complete example of moving the Camera?
Can you give me a copy? Right here. :D

Neil Roy

I'm not exactly certain what you mean by "moving the Camera"? 3D? 2D scrolling?

Don't feel bad about my game, I suck at it too!!! ;D ;)


Yes,of course it is a 2D.

Neil Roy

If you have a 2D game with a large scrolling map, where only part of your map is visible on the screen. What you have is an X and Y co-ordinate, scroll_x and scroll_y, you store which keeps track of the upper left corner of the area you are viewing. When you scroll left, you increase the scroll_x co-ordinate until you cannot scroll any more. If for example you are viewing the rightmost section of the screen and you cannot scroll to the right any more, you have reached the maximum scroll_x co-ordinate so that the right size of the viewable area is the right side of the map. Then you start to move the character to the right instead of scroll the screen. When moving the character back to the left, when he reaches the center of the screen, you then start to scroll back to the left again until you cannot scroll left anymore, in which case your character moves left of center. The same for up and down movements.

When you draw the map, you start drawing it at the scroll_x and scroll_y co-ordinates which will be the upper left corner of the area to view and then you show that area on the main screen. The scroll_x and scroll_y (or whatever you call it) can be the upper left TILES of the screen, or, pixel area or whatever, depending on your game type.

Thread #617287. Printed from Allegro.cc