Advertisement

Bad Direction 2

Started by July 11, 2000 10:52 AM
2 comments, last by kroiz 24 years, 5 months ago
hi this the second time i''m sending the question cause of some problem i can''t reply to the first one i made. it goes something like that: i''m making a 2d tank game. i made a sprite with 32 iterations. i also made a look up table, but when i move the sprites some iterations move to the same direction as the one next to them. here is what i mean in numbers: when i debug this code: -------------------------------------------------------- vx = CosLookUp[CurrentFrame]; vy = SinLookUp[CurrentFrame]; xfactor = int(4 * vx); yfactor = int(4 * vy); ------------------------------------------------------- for CurrentFrame = 8 i get: vx = 0.999 vy = -0.034 and then: xfactor = 3 yfactor = 0 and for CurrentFrame = 9 i get: vx = 0.987 vy = 0.1564 and then: xfactor = 3 yfactor = 0 as u can see i get the same xfactor and yfactor for different CurrentFrame. i tried increasing the tank speed (4) it works but the tank moves to fast, and i don''t want to reduce the iteration number. can any one think of a solution, maybe an alternative algo. hope u dig. tnx very much for your time and for trying to help.
0 error(s), 0 warning(s)

I suggest you to store the position and the factor in a float.

xfactor = 4.0f * vx;

Floyd
Floyd
Advertisement
that wont help, since i have to cast any way, to put it on screen.
the vx and vy are float but the factors are int.
tnz anyway.

Edited by - kroiz on July 12, 2000 11:31:28 AM
0 error(s), 0 warning(s)
It will not help on the first step through, but it will help in subsequent steps.

Example:
Let''s say you want to add .3 to a variable. If it is an int it will forever stay at 0. Because when you cast it to an int, the .3 just falls off. But if it was a float, and you cast it to an int when you printed it, you would get a 1 on the fourth time through. Try making it a float like Floyd'' said. and just cast it to an int when you need to.


Later,
Eck

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

This topic is closed to new replies.

Advertisement