3
*************************************************************************
5
ArmageTron -- Just another Tron Lightcycle Game in 3D.
6
Copyright (C) 2000 Manuel Moos (manuel@moosnet.de)
8
**************************************************************************
10
This program is free software; you can redistribute it and/or
11
modify it under the terms of the GNU General Public License
12
as published by the Free Software Foundation; either version 2
13
of the License, or (at your option) any later version.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, write to the Free Software
22
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24
***************************************************************************
28
#ifndef ArmageTron_EVENT_QUEUE_H
29
#define ArmageTron_EVENT_QUEUE_H
35
we try to establish a future event management based on the following
36
assumption that every possible event can guarantee that it won't happen
37
for the next x seconds; for example, if you are in the center of
38
an arena, your max speed is 5 mps and the next wall is 30 m away,
39
you know you won't hit a wall for the next 6 seconds.
41
To efficiently manage many such possible events, we store them
42
in a heap-type data structure, where the most urgent events
43
reside at the bottom (why is everything upside down in informatics?)
46
Note: time may be replaced by other monotonely increasing functions,
52
// the events. WARNING: tEvents may be deleted by tEventQueue,
53
// so make sure that this is allways possible.
58
class tEvent:public tHeapElement{
59
friend class tEventQueue;
64
virtual bool Check(REAL time)=0;
65
// check the tEvent and update value. (the time we have to check it again)
66
// return value: TRUE if the tEvent needs to be checked again
67
// FALSE if the tEvent happened and can be deleted.
69
// tEventQueue *Queue();
70
// in wich queue are we?
72
virtual void Render(){}
76
class tEventQueue:public tHeap<tEvent>{
77
REAL currentTime; // the current time
80
tEventQueue():currentTime(0){}
83
void Timestep(REAL time); // processes all the tEvents that
84
// may happen until time.