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.

AppGameKit Classic Chat / help with jumpy sprite movement on Windows

Author
Message
Lavaflyer
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location: Wisconsin, U.S.
Posted: 25th Oct 2012 00:28
I'm trying to simply move ledges (sprites) in a tier 1 AppGameKit game from the bottom of the screen to the top. As the player survives longer, the ledges move faster from bottom to top.

The problem I am having is that on Windows, the movement of the ledges looks more and more jumpy (not smooth) as the speed of the ledges increase. I am simply moving the ledges once per main do loop with a setspriteposition() call. It sort of makes sense to me that it looks jumpy because I am changing the y pos more each frame as speed increases. But on the other hand, how else can I make the ledges (sprites) move faster on the screen other than to make them move more each frame?

Any suggestions on how to do this so that it looks smooth on Windows is greatly appreciated. Does not seem to be much of a problem on the iPhone (probably because the screen is so much smaller).

Here is a small example that demonstrates the issue. The greater you make iYMoveAmt, the more jumpy the movement looks.

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 25th Oct 2012 01:23 Edited at: 25th Oct 2012 01:23
The jumping could be caused by a number of things not being totally in time with each other and it may take a combination of solutions to get the result you want.

First step is probably to make sure your movements are smooth between frames by switching to a time based method.

There are many examples around and Baxslash has done an excellent article on the basics in one of the newsletters.

Short version is to use the time taken to render the last frame as a basis for the amount moved in the current frame. That way if the frame rate drops for any reason, the movement stays fluid.

To implement timed movement, you multiply the distance you want to move in one second by getFrameTime(), which will give you the distance per frame.

Currently you move at 8 pixels per frame, which (at 60 fps) is 480 pixels per second.

Applying that to your code gives;

Give it a try and see if there is any improvement.

Converting to floats will smooth out the movement further as it will be able to move partial pixels.
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 25th Oct 2012 02:09
This sounds an awful lot like a bug I fixed in Windows Vista + 7 where the Desktop Window Manager was interfering with the double buffering to produce occasional frame skipping. Once 1083 is ready and released let me know if you still experience problems.
Lavaflyer
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location: Wisconsin, U.S.
Posted: 25th Oct 2012 19:54 Edited at: 25th Oct 2012 19:59
Thanks Marl and Paul for responding.

I don't think I'm experiencing the bug Paul is fixing in Windows Vista + 7 because once I used Marl's suggestions (along with help from the Timer Based Movement article in this newsletter -- http://www.thegamecreators.com/pages/newsletters/newsletter_issue_111.html), I was able to correct the jumpy sprite movement.

Here is a short code sample of what seems to be working for me. This works on Windows 7 as well as on the iPhone. Note: Setting the sync rate to 1000 works on Windows but has little to no affect on the iPhone's I've tested with since they seem to max out at about 60 fps (which appears to be the default fps when you don't call setSyncRate()). Since I did not have the issue on the iPhone, this solution works for me.

Thanks again for all the help guys!

[b]

Login to post a reply

Server time is: 2024-04-27 23:14:23
Your offset time is: 2024-04-27 23:14:23