GLBasic forum

Main forum => GLBasic - en => Topic started by: XanthorXIII on 2010-Oct-30

Title: Drawsprite Function and the values it takes
Post by: XanthorXIII on 2010-Oct-30
Ok, from my understanding Drawsprite takes Integer based values on the call for drawing on the Screen. However I have run into a situation where I need to choose a random X position at the top of the screen, choose a random x position at the bottom of the screen. Using Atan I calculate the Angle and then use COS and SIN to get the X/Y offset for drawing. However when I send those values to Drawsprite, my values get truncated after the . and I'm left with 0's. Has anyone run across this situation that they need to have a sprite move at an angle but calculate correct offsets that Drawsprite won't kill the values?
Title: Re: Drawsprite Function and the values it takes
Post by: MrTAToad on 2010-Oct-30
It sounds as though you are doing the calculations using integers.  If so, use floating-point variables and pass them to DRAWSPRITE
Title: Re: Drawsprite Function and the values it takes
Post by: XanthorXIII on 2010-Oct-30
I'll double check to make sure that I am passing reals but I am fairly certain that drawsprite will truncate my values as Integers. Also I may need to clean up my code some. I'm not at my machine at the moment.
Title: Re: Drawsprite Function and the values it takes
Post by: MrTAToad on 2010-Oct-30
Oh yes, DRAWSPRITE will use integers, but that shouldn't make any difference...
Title: Re: Drawsprite Function and the values it takes
Post by: Moru on 2010-Oct-30
I have been using floats just fine for coordinates for all sprite drawing. (That was the only way before we got integers :-)
Title: Re: Drawsprite Function and the values it takes
Post by: XanthorXIII on 2010-Nov-02
Thanks for the clarification. Looks like I just had to go through and clean up my code. Decided to get fancy with TYPES and that helped me out a ton.
Title: Re: Drawsprite Function and the values it takes
Post by: MrTAToad on 2010-Nov-02
Types are very useful - you cant go wrong with them!