[Top][All Lists]

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

Re: cleanup patch / design rules

From: Ingo Ruhnke
Subject: Re: cleanup patch / design rules
Date: 24 Aug 2002 20:05:41 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

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:

        if (pixel_free(x, y))
                x += 1;
        } else {

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:

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();

  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.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.

JabberID: address@hidden 
ICQ:      59461927

reply via email to

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