Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Movement Buffer (skipping more spaces than intended)

Author
Message
RxMadJack
14
Years of Service
User Offline
Joined: 28th Jun 2010
Location:
Posted: 19th Jan 2011 18:43 Edited at: 19th Jan 2011 19:08
Hey guys,
I am creating a basic tetris game, when i am moving my pieces left or right, often times i mean to just move it one space and it will move the piece two spaces over. I am using a function that checks for a keypress every so often. (dbkeystate) i tried my application on another computer and it seems like the problem is worse. This computer has a faster processor, i wonder if its running my check keypress loop faster? Any thoughts on how to resolve this or on a better method for checking keypress?
thanks in advance
RomuluS85
18
Years of Service
User Offline
Joined: 10th Apr 2006
Location:
Posted: 19th Jan 2011 20:05
it sounds like you need to do a check on if the key is being pressed...

(Pseudocode)

this can execute rather fast, and cause the object to "jump", because the code can run faster than your brain can register movement on the screen... what you would need to do is something like



basically it gives 50 millisecond delay between checks of the key being pressed, i.e. if you hold down a key, it will only move the item 1's per every 50 milliseconds... (have fun tinkering this to a far better value )
Freedom Fighters
15
Years of Service
User Offline
Joined: 2nd Nov 2009
Location:
Posted: 20th Jan 2011 02:59
i would recommend you use a method such as delta timing, this is a rather handy method for such when you have fast, slow computers etc.

What is it?
http://en.wikipedia.org/wiki/Delta_timing

i have written some code that does delta timing, if you want ill give it to you.

with delta timing its not a matter of the speed of the computer or frames but on time.
if one computer has like 60 fps and another had 30 fps they wouldn't move at the same rate. even if you had the 30fps go twice the speed.

FF_Timer.h


FF_Timer.cpp



[ FF - Engine ] - Coming Soon...

Login to post a reply

Server time is: 2024-11-19 14:43:41
Your offset time is: 2024-11-19 14:43:41