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.

Newcomers AppGameKit Corner / Consistent sprite movement speed in Tier1 2D

Author
Message
RGBZ
7
Years of Service
User Offline
Joined: 19th Apr 2017
Location:
Posted: 25th Apr 2017 16:36
I searched the forums, but couldn't really find a post that answered my question so I thought I would put it out there and see if anyone can point me in the right direction. All of the tutorials I have looked at moves a sprite at a constant number of pixels each time through the game loop regardless of how much time has passed from consecutive calls to the main loop. In other frameworks I have used, the framework reports the delta time between calls to the main processing loop so you can adjust you movement to account for time so your object can move at consistent speed.

I have tried using the timer() function to keep track for time between iterations of the main processing loop and I just wanted to see if that's the best way or are there better ways to accomplish a consistent speed of a sprite in 2D tier 1 ?

So far I am very impressed with app game kit and I really like how responsive the community is and I really appreciate the assistance.
RGBZ
7
Years of Service
User Offline
Joined: 19th Apr 2017
Location:
Posted: 25th Apr 2017 16:53
Never mind, I guess I need to look a little harder at the documentation

https://www.appgamekit.com/documentation/examples/timers/1_timer_movement.htm

RGBZ
7
Years of Service
User Offline
Joined: 19th Apr 2017
Location:
Posted: 25th Apr 2017 17:06
I also found you can use GetFrameTime(), but that has some restrictions.
RGBZ
7
Years of Service
User Offline
Joined: 19th Apr 2017
Location:
Posted: 25th Apr 2017 18:18
Just for others, I incorporated managing delta time into separate functions. Just for this example I took the timer movement example included with the install and modified it. Not saying it has to be done this way but I thought it would work pretty well and encapsulate the functionality as much as possible. This is my first attempt posting code to the forum so hopefully I did it correctly

main.agc


TimeManagement.agc


Login to post a reply

Server time is: 2024-04-20 13:36:41
Your offset time is: 2024-04-20 13:36:41