-
Graphics problems!!!
Sorry... I am a very newbie to game programming, and this website so if I say something wrong, please be forgivable. I recently try to code the game tankwar and run into one of the graphics problem. The tank that I create move very rigid, not smooth at all. And If I try to make it go smooth, the tank wont ever stop. Here is portion of my code.
The if else statement below, if I took off the else. The tank wont ever stop but it move quite smooth. If I have the else, the tank stop when I stop pressing the key but it move very rigid. I wrote my program in C using Allegro Library.
Code:
if(keypressed()){
press++;
getinput();
}else{
tank[0].speed = 0;
tank[1].speed = 0;
}
clear_keybuf(); //clear the key buffer
rest(20);
I also include my codes here. I cant upload my excute file because the website wont allow me.
-
Because you have it making the tank increase in speed as you press forwards, it will gradually become jerkier, to get the same overall speed, you could reduce the distance moved by max speed and then reduce the rest time. Or just have a set speed rather than making it accelerate.
-
Thanks a lot. It look a lot better.
But I got another question for u. I got a function call checkpath() and clearpath(), those 2 are my collision detection. It detect when the tank hit the object fine, but when 2 tank collide they just go right through. Why is it like that?
-
I can't actually see anything wrong about your code But are you sure you are passing the right values the second time round? Maybe your problem will require the expertise of Bubba.