![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Software Programming Software programming talk, ask questions about computer software programming or help others |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Basically I have 2D, tiled, turn based space game. I collect input (keyboard and mouse) with a seperate thread that I currently have set to collect 20 times per second. The problem : Timing. Each of my screens (intro, character selection, etc.) execute varying amounts of code (drawing, rule checking, etc.) so keeping in mind the input collection at 20 seconds per second sometimes I'll miss a mouse click and sometimes I'll have registered several mouse clicks. For example on one of my screens I have a button that basically increments a number each time it's clicked. Since there is not a whole lot of stuff being drawn and/or other rule checking going on when I click the mouse quickly the number will increment by 2 or 3 instead of the expected 1 per click. On a completely different screen that has more stuff going on if you will, when I click the mouse on a button sometimes it doesn't register instead of the expected 1 per click. I know it's a timing issue and I can tweak it to work properly for a particular screen, but obviously not for all the screens. So I would like to have consistency along with appropriate input collection frequency. How can I control this? My guess is by limiting the times through the loop with something like gettickcount(). The flow of my program is basically like this. I'm leaving a lot out, but enough to get the point across. main() { loop(until user quit) { dispatch message application->run(); } } application::run() { switch(what state am I in) case : initialization dointialization(); case : start_screen dostart_screen(); case : char_selection dochar_selection(); } Using the example above the dostart_screen() subroutine has very little to draw/do so clicks register quickly. Meanwhile, on the dochar_selection() has a lot more stuff being drawn/checked so the clicks register slower. My thoughts on how to fix this would be: (adjusting the top/main loop only) main() { loop(until user quit) { gettickcount dispatch message if(tickcount is >= 30 fps) application->run(); } } Any thoughts? Also I know I went overkill with spawning a seperate thread and doing action mapping, but I was learning it at the time and thought I would use that moving forward, especially if I was planning on ever doing a FPS/realtime game. I think it would work out pretty well for a FPS/realtime game. regards, dn | |||
| Featured Websites | ||||
|
![]() |
| Tags: dinput, problems, seperate, thread |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How can i save layers as seperate images? | Łngelkott | Graphics in general | 5 | 06-11-2007 10:37 PM |
| Yet another GHII thread | Bobby Internet | Console Subjects | 4 | 06-11-2007 12:59 AM |
| Deleted a thread | MadKad | Community Chat | 0 | 11-04-2006 1:30 PM |
| Thread suggestions | Scoot | Bugs And Feedback | 14 | 05-22-2006 6:22 PM |
| What is going on with these posts and thread | Scoot | Community Chat | 11 | 04-13-2006 12:30 AM |
| Featured Websites | ||||
|