Hello, I'm creating a game with Allegro 5, Visual Studio 8 and Windows XP.
Well, when I run the game, the tiles that are on the screen suffer a deformation, this effect occurs around the display of the Allegro, and only when I move the tiles, when they stopped the deformation disappears.
The effect starts low, rises and deforming the tiles, it happens every 4 seconds or so. Tried to replace the images by the most primitive effect is the same.
A photo of the problem:
{"name":"2w3nfuw.jpg","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/9\/999e772caec7c6f0b2be4a54e280c06a.jpg","w":885,"h":471,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/9\/999e772caec7c6f0b2be4a54e280c06a"}
A video of the "bug":
http://youtu.be/Nf-Qa7VaWs0
Below the drawing code of tiles:
In tile class has a std :: vector<tile> contains that all existing tiles on the map, and the method draw () the map I draw them like this:
Do not bother to swap the buffers because the documentation says that the Allegro automatically identifies what the current backbuffer. I think be no problem with my computer 'cause I have done some games in Java (which is much slower than c ++) and ran perfectly. Does the problem is because Windows XP? Or am I doing something wrong?
Show more relevant code. Where are you flipping the display? Are you using transforms?
Also, have you verified vsync is running?
I have not posted much of anything because the code is very simple.
Swapping buffers to the end of the method repaint() the main class:
void repaint(){ al_clear_to_color(WHITE); mapa.draw(); al_flip_display(); }
Information that may be important: each object has a pointer to tile corresponds to their respective image. Carry the tileset atlas, he divided the tiles, and move the pointer of each image to its corresponding tile.
That alone, without effects, transformation, rotations, etc ..
Show ALL the code.
This is very unlikely to be a bug with Allegro, or it would be more common.
Where are you setting up the display?
Main class:
map class:
tileset class:
tile class:
It is all.
That video looks like a vsync problem to me. The display is updated while the monitor is halfway through showing the previous frame. Try this before creating the display:
al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST);
and if that doesn't work, there should be a setting in your graphics utility to allow programs to set vsync/flipping and not override it.
al_set_new_display_option (ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST); worked, the tiles are perfect now, but the game is too slow, the controls are coming with 1 sec delay ;
Try adjusting your timer values.
Tips? because they seem ok to me.
Check if your event queue is empty before drawing, that should solve the input delay.
I was thinking that somehow the timer would cause a delay after the vsync or something, so it'd have two delays, one for the vsync and one for the timer itself. If you sped up the timer a bit so it'd always ask for a redraw before a vsync kicked in, then it'd work better I'd think.
It worked guys, is perfect right now with vsync!
I did so:
while (!al_event_queue_is_empty(eventqueue)) { al_wait_for_event(eventqueue, & event); if (evento.type == ALLEGRO_EVENT_KEY_DOWN) { //do something ... } }
Many thanks for the help.