![]() |
| | #16 |
| Woof, woof! Join Date: Mar 2007 Location: Australia
Posts: 3,139
| |
| zacs7 is offline |
| | #17 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,099
| The point is: do not use polling. At all. A fully event-driven system will make sure the processor of the events sleep until there are events to handle. Then it handles them at full speed and falls asleep again.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline |
| | #18 |
| Registered User Join Date: Oct 2008
Posts: 452
| So when would you do the rendering? At a timer tick event? |
| EVOEx is online now |
| | #19 |
| Super Moderator Join Date: Aug 2001
Posts: 7,472
| Key difference here is how a game-style programmer approaches the problem and how an application-style programmer approaches it. Most apps are sitting there waiting for input and are not real-time per se. Most games are real-time and thus cannot utilize the same approaches or architecture that apps do.
__________________ If you aim at everything you will hit something but you won't know what it is. |
| Bubba is offline |
| | #20 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,099
| An event, of course! That is what I have been trying to say.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline |
| | #21 |
| Registered User Join Date: Oct 2008
Posts: 452
| What kind of event? A "this character moved a pixel"-event? C'mon, there's no way a system like that is going to work if there are a lot of objects that move a lot. Imagine a 3D game. Falling event. And again. And again. It's going to be a race against clock. And if the events aren't sent at the same interval the speed of falling will differ all the time. And what if two objects move at the same time? We get two events to render for what ought to be the same frame. We could of course render every time a timer ticks. That'd be fun if rendering the frame takes more time than the timer ticking. The render events would stack without them ever being handled. |
| EVOEx is online now |
| | #22 | |
| Mysterious C++ User Join Date: Oct 2007
Posts: 14,099
| Come on. You could make an event that say "make character fall distance x with a speed of y." Making an event should have as little overhead as possible. But this is what I meant with my event-driven solution. I do not know if it feasible or not, but for small projects, it certainly is.
__________________ Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System I dedicated my life to helping others. This is only a small sample of what they said: "Thanks Elysia. You're a programming master! How the hell do you know every thing?" Quoted... at least once. Quote:
| |
| Elysia is offline |
| | #23 |
| Super Moderator Join Date: Aug 2001
Posts: 7,472
| Event systems are great but are not good for the core rendering loop. You can use events to signal something has happened such as receiving data from a socket, receiving input, queuing up a sound to play, notify when a sound stops, notifying when a character dies and thus needs removed from the world, etc. But core rendering should be a tight loop that is ran through every 16.6666667 ms to attain 60 FPS. Most games take some time to render or update and fall short of this but they most likely won't go below 33.33~3 ms b/c that is 30 FPS.
__________________ If you aim at everything you will hit something but you won't know what it is. |
| Bubba is offline |
| | #24 |
| Robot Join Date: Mar 2009
Posts: 100
| Let's say you go with the state bases approach; how would you use it in a situation like this: You're in a game and have a key that brings up a little menu on the screen, but bringing up the menu will not pause the game (think recent Resident Evil games). Should the menu be a different state than the main game? It will change some of the keybindings, so it might sound good in theory, but how are you going to keep the game running as usual at the same time? |
| Memloop is offline |
| | #25 |
| Super Moderator Join Date: Aug 2001
Posts: 7,472
| Please don't bump old threads.
__________________ If you aim at everything you will hit something but you won't know what it is. |
| Bubba is offline |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C Programming 2d Array Question | jeev2005 | C Programming | 3 | 04-26-2006 03:18 PM |
| beach bar (sims type game) | DrKillPatient | Game Programming | 1 | 03-06-2006 01:32 PM |
| Game Engine Link Prob | swgh | Game Programming | 2 | 01-26-2006 12:14 AM |
| My Memory Game | jazy921 | C Programming | 0 | 05-05-2003 05:13 PM |
| Im a Newbie with a graphics design problem for my simple game | Robert_Ingleby | C++ Programming | 1 | 11-23-2001 06:41 PM |