ALLEGRO_VSYNC
Set to 1 to tell the driver to wait for vsync in al_flip_display, or to 2 to force vsync off. The default of 0 means that Allegro does not try to modify the vsync behavior so it may be on or off. Note that even in the case of 1 or 2 it is possible to override the vsync behavior in the graphics driver so you should not rely on it.
Maybe you can toy with that option a little ?
The speed issue now has solved, thank you. The quote you provided explains why it runs well on my computer but too fast on others. I am busy at the moment, I will inspect it deeper later, maybe some days later.
And this is the main loop:
var
Event: ALLEGRO_EVENT;
begin
ProcessInit;
Start(Intro1);
while (GameIsRunning) do begin
al_wait_for_event(EventQueue, Event);
ProcessUserInput;
ProcessUpdate;
ProcessDrawing;
end;
ProcessShutdown;
end.
I'm really curious about your sources. Your game loop looks as the loops used in the old times, when the target system had a fixed speed (i.e: game consoles, z80 based computers, ect.). Nowadays a single target (i.e. PC) may have different speed (not only CPU but also memory, disk and graphics hardware, that affects the final speed). Of course, it is possible to control speed using different ways, and I'm curious to know which one you've used as I'm sure it's very different to the one I'm using in my engine.
The code you quoted is the revised version, which should work correctly. I heard that Allegro 5 uses event concept, which I am not familiar with. I followed the sample from the wiki page, added the Allegro timer event, and the speed issue now has solved.
@ Scoops, lainz, minesadorada
Thank you for you helps. I found no such information on the web! This information is very valuable.
@ all
I am overwhelmed by 'real' job currently, I may be able to come back maybe some days later. Please report anything that seems weird. If no new bug found, I then will start to write the tutorial.
Of course I know I am not an expert in game programming, the code may not conform to the standard. So will first let it checked by seniors before publicized to the public.
This Furious Paladin is far from complete, but it has many interesting thing inside:
- How to manage animation
- Using app state (or others called it 'game state')
- Using dynamic array (instead of TFPList)
It uses dynamic array for storing the actor data. I set a test running dynamic array vs TFPList, the result is dynamic array runs a bit faster compare to TFPList but it runs much slower when adding/deleting items. In the game, it doesn't really delete the item, it simply mark it as 'expired', so can be reuse later.
See you.