C Board  

Go Back   C Board > General Programming Boards > Game Programming

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 11-02-2009, 02:58 PM   #16
Woof, woof!
 
zacs7's Avatar
 
Join Date: Mar 2007
Location: Australia
Posts: 3,139
Quote:
Originally Posted by Elysia View Post
A lot (I think? ). The whole while running is unnecessary polling.
Use a block to stop the main thread from running when there are no events and use a quit event to quit the game.
You seem to miss the big point, it's NOT unnecessary. What if you sleep? Then the OS decides not to schedule you back for a while then you find yourself with quite a few events to deal with. Or you get more events than you can handle per frame, given the low polling.
__________________
"I.T. gets the chicky-babes" - M. Kelly
bakefile | vim
zacs7 is offline  
Old 11-02-2009, 04:47 PM   #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:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline  
Old 11-02-2009, 04:56 PM   #18
Registered User
 
Join Date: Oct 2008
Posts: 452
Quote:
Originally Posted by Elysia View Post
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.
So when would you do the rendering? At a timer tick event?
EVOEx is offline  
Old 11-02-2009, 08:39 PM   #19
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,470
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  
Old 11-03-2009, 10:06 AM   #20
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
Quote:
Originally Posted by EVOEx View Post
So when would you do the rendering? At a timer tick event?
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:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline  
Old 11-03-2009, 10:33 AM   #21
Registered User
 
Join Date: Oct 2008
Posts: 452
Quote:
Originally Posted by Elysia View Post
An event, of course! That is what I have been trying to say.
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 offline  
Old 11-03-2009, 01:00 PM   #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:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline  
Old 11-03-2009, 04:36 PM   #23
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,470
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  
Old 11-19-2009, 08:57 AM   #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  
Old 11-19-2009, 11:32 PM   #25
Super Moderator
 
Bubba's Avatar
 
Join Date: Aug 2001
Posts: 7,470
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  
Closed Thread

Thread Tools
Display Modes

Forum Jump

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


All times are GMT -6. The time now is 02:04 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22