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.

Dark GDK / Player Shot Locked

Author
Message
haliop
User Banned
Posted: 18th Jan 2009 19:53
how to?
let me explain

when i'm shooting
using


when i fire the Shot (sprite) dosen't go Stright
becouse the calculation above is still running..
any idea on how to make it go stright actually to LOCK this calc
for that shot , and again for the next shot..

so the "Bullet" will go stright and won't get more Angles to calc.

i don't need the code just "How to do it" like what method? should i use a Boolean to lock the shot Angle? maybe other way? ..

ty for your time.
nadav.
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 18th Jan 2009 22:07
The primary think to keep in mind is that using integers to track position is a bad idea if the object is moving, especially at an angle to any of the major axes. If you use the current position in integer form you lose precision. Either track it using a float and round the location up or down to an integer when you tell it where to display or always work from the starting position and do your calculations predicated on where it should be each time through the loop.

When I wrote my own line drawing routine I initially determined an x-slope and a y-slope and based the movement on an independent variable then calculated the x and y position separately based on the "cycle."

x = startx + xslope * cyclenumber;
y = starty + yslope * cyclenumber;

to be brief. The problem is that you have to do some casting since the slopes should be floats. You might also look up some line drawing algorithms. I found some that, IIRC, use only integers and depend on the current position rather than the initial position. I personally don't like using floats unless I have to.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
haliop
User Banned
Posted: 19th Jan 2009 10:42
all i can say
i'm very sorry i don't understand my english is not that well

maybe a simplier explanation?
Matty H
15
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 19th Jan 2009 15:02
If your problem is what I think it is then the solution might be to use dbRotateSprite and dbMoveSprite, this way you work out the initial angle once, set it with dbRotateSprite then just use dbMoveSprite in your loop.
If this is not what you meant, post more of your code(or a smaller workable example) so I can have a more detailed understanding of the problem.

Login to post a reply

Server time is: 2024-09-30 15:36:39
Your offset time is: 2024-09-30 15:36:39