Hello I am currently working on my first pong / space shooter game, i have the pong aspect pretty much running fine in an applet, I am having a little trouble with smoothimg out the keyboard controls. I use the UP and DOWN key to control the Y pos of the blocker in the game. My problem is that i cant figure out how to make the blocker move more smoothly up and down the Y axis, here is my current code for when each button is pressed:
Is there somthing I can do numerically to smoothen my controls?
Thanks, Kp [ July 22, 2005: Message edited by: Kevin Peterso ]
In my games, I implement what I call "inertia counters," which are integer variables that contain values that change over time. Specifically, there are two(2) such values: one for x-axis changes, and one for y-axis changes. The values can be either negative or positive. You can use a separate "thread" to manage how these values change per millisecond, which ultimately results in those values adjusting themselves so that they increment (or decrement) back to zero(0). Zero indicates no "movement" (i.e. no inertia). I use this technique in games that require "thrust" or "propulsion" of somekind, such that if the thrust key is released, these values (which contained the increment in x/y to "move" the ship) slowly revert back to zero - i.e. no thrust. Hope that makes sense. :-) In all, it always boils down to math.
The reason why it is not smooth it is because you move it 20 pixels at a time. You could move of 1 pixel instead of 20 and have an higher refresh rate, this would make it smoother. What do you think???
catch it before it slithers away! Oh wait, it's a tiny ad: