pingus-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: cleanup patch / design rules


From: Kenneth Gangstoe
Subject: Re: cleanup patch / design rules
Date: Sat, 24 Aug 2002 20:10:47 +0200
User-agent: Mutt/1.3.28i

Here is an interesting article (actually, its the comments that are
interesting, make sure you read them):
http://www.flipcode.com/cgi-bin/msg.cgi?showThread=Tip-MainLoopTimeSteps&forum=totd&id=-1

They talk alot about pros and cons about fixed vs. variable.

- Kenneth

Quoting Ingo Ruhnke (address@hidden):

> Kenneth Gangstoe <address@hidden> writes:
> 
> > Are you running more ticks than screen refreshes? Are you running
> > various things at various ticks? If the logic code ticks higher than
> > screen refresh, do you interpolate gamedata in any way?
> 
> Pingus has a very simple integer based[1] game logic. The code of a
> walking pingu looks something like this:
> 
> void
> Pingu::update()
> {
>         if (pixel_free(x, y))
>         {
>                 x += 1;
>         } else {
>                 reverse_direction()
>         }
> }
> 
> Which means that it run both update() and screen refreshes syncron at
> the same rate (refreshes every 30 milisec). However on slower
> computers it might be possible to skip every second frame to reduce
> the number of time consuming screen refreshes. Interpolation isn't
> done and can't be easily done, due to the interger nature of the
> engine (a pingu can't stand 'between' two pixels).
> 
> All this works relativly well, since Pingus is actually quite simple,
> but for a game that needs a physic engine or something like that (like
> Feuerkraft) you most likly want to use variable ticks. In Feuerkraft
> it works like this:
> 
> void
> Feuerkraft::update(float delta)
> {
>   pos += direction * delta;
> }
> 
> And I have (or want to have, havn't touched the code for a while) a
> mainloop like:
> 
> while (1)
> {
>   float total_delta = get_passed_time();
> 
>   world.draw();
>   for (float i = total_delta; i > 0; i -= tick_rate)
>      world.update (tick_rate);
> }
> 
> as opposed to just:
> 
> while (1)
> {
>   float total_delta = get_passed_time();
> 
>   world.draw();
>   world.update (total_delta);
> }
> 
> Which means the game runs at a fixed tick_rate, but could run at a
> variable one, the only difference is in the main-loop, not in the rest
> of the game code. The advantage is that one doesn't have to care about
> unnatural large delta-times, which could make the engine go wild. By
> adjusting the tick_rate one could freely change the game speed if
> necessary. The fixed tickrate assures also that the game always
> behaves the same, on both and slow computers.
> 
> -- 
> WWW:      http://pingus.seul.org/~grumbel/ 
> Games:    http://pingus.seul.org/~grumbel/gamedesigns/
> JabberID: address@hidden 
> ICQ:      59461927
> 
> 
> _______________________________________________
> Pingus-Devel mailing list
> address@hidden
> http://mail.freesoftware.fsf.org/mailman/listinfo/pingus-devel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]