Skip to main content
gamedev.net
🔒 Locked

Smoothness

Started by trondb 1 reply 250+ views
Original Post
trondb
trondb
Hi, I am wondering about a simple implementation problem... I got a pong game I am working on, and it looks very bad for now... * Sprites are moving to slow, even by moving them 6 pixels at the time. Can I speed up the program somehow and move the sprites one-by-one pixels? Or are there any other suggestions on how to smooth this stuff out?!?? Thanks
"That's Tron. He fights for the users."
falkone
falkone
I''m assuming that your doing a little "If LeftKey then x = x - 6" type thing.. if so.. you might want to use a little ''speed'' (i can''t think of a better term).. for example.. each loop the x value of the paddle is increased by the ''speed''. As you press the right arrow key, the speed value is increased, and the paddle goes faster.. you of course can have a limit... and the left key will decrease the speed value.. every game loop you can then decrease the speed to simulate ''friction''.. here''s an example in basic (sorta).. FRICTION is how much you want to slow the paddle by.. and ACCELERATION is how fast you want it to speed up..

Do
x = x + sx
if sx > 0 then sx = sx - FRICTION
if sx < 0 then sx = sx + FRICTION

if LeftKey()
sx = sx - ACCELERATION
elseif RightKey()
sx = sx + ACCELERATION
end if

DoOtherStuff()

Loop

That should help with the smoothing problem.. you might also want to add a limit to how high sx can get.. and make sure their nice numbers or you''ll get all kinds of funny effects... hope i was of help..





Disclaimer: "I am in no way qualified to present advice n any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)" o
trondb
trondb
Yeah, sounds like a nie solution.. thanx
"That's Tron. He fights for the users."

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.