Re: [AD] generic game loop |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Monday 14 March 2005 23:05, Jon Rafkind wrote:
> Something like
> int game_loop( int (*logic)( void * data ), int (*draw)( void * data),
> int time, void * data );
>
> Where logic is a function pointer to the function that performs all the
> game logic, draw is a function that draws everything, time is how much
> time to wait between loops and data is passed to logic() and draw() when
> they are called.
I'm of two minds here (if that's indeed a saying). On the one hand, I see
where this would benefit new users and help them get going properly. On
the other hand, it is not something I would ever use myself (mainly
because I already have my own module for such a thing).
I think it would be ideal for a module in the demo game and a prime
candidate for the Allegro+addons distribution discussed. I don't think it
fits well with the likes of install_allegro(), set_gfx_mode() and such
since it's a lot highter level.
Things to consider: how does it allow the user to specify the update rate?
Would it be possible to lock to a specific graphical framerate instead of
a logic rate? Is the user code able to query the current value of the time
counter? How does the user specify that the graphics need to be updated at
the next opportunity (does he call a function that sets a flag, say
request_graphics_update(), whenever the logic dictates that a graphics
update will be needed)?
> The reason I think this could be in Allegro is a) the question of how to
> do correct timing loops comes up again and again
Well, that means it should be in the FAQ... which it already is ;)
> b) im sure many users
> get the timing loop suboptimal even if they know what it is and c) it
> reminds them of the "correct" way to structure games by seperating
> drawing and logic code.
Good points.
> I can see a critiscm be "This is a basic part of games that people
> should know how to do and doesnt belong in a graphics library." but this
> is exactly the point, its so common( or should be ) that it might as
> well go in a game library, which Allegro is supposed to be.
Yes - but as a `supported addon' or whatever name we would choose to give
to addons that are bundled with the larger Allegro distribution.
Let's get 4.2 out of the way first though.
Evert