07-06-2023, 12:21 AM
help moving a sprite in a ellipse
|
07-06-2023, 01:04 AM
(This post was last modified: 07-06-2023, 01:06 AM by TerryRitchie.)
Here is the simplest example I could come up with. This code creates 360 points around a circle. By varying XSIZE and YSIZE you can squash (YSIZE) or elongate (XSIZE) the ellipse.
Replace the CIRCLE command with your sprite's _PUTIMAGE statement. Code: (Select All)
07-06-2023, 01:48 AM
Here is one sprite in constant ellipse Y- and b+ constantly tilting ellipse by a degree after every orbit:
Code: (Select All)
b = b + ...
07-06-2023, 02:01 AM
(07-06-2023, 01:48 AM)bplus Wrote: Here is one sprite in constant ellipse Y- and b+ constantly tilting ellipse by a degree after every orbit: Oh, I did not know that _PI carries a multiplier parameter and that you can _PI(2) instead of _PI * 2 It's good to have one's _PI horizons expanded.
DO: LOOP: DO: LOOP
sha_na_na_na_na_na_na_na_na_na:
Yeah _Pi() is a handy multiplier function
Would it be anymore efficient if QB64pe had a multiplier for RND? I should note my ellipse demo was a quick throw up and first best mod would be to use the ell() as sprite centers as apposed to Left, Top corners ie subtract -_Width(sprite) *.5, _height(sprite) and Step (_width(_sprite, _height(sprite))... in the destination section of _putimage.... that would center the 2 sprites to the center of screen. Compare Terries always recalcs the sprite positions, mine calcs all positions before running once and then for first sprite to do tilts useing the rotate sub to adjust for tilts in orbits.
b = b + ...
07-06-2023, 12:56 PM
(07-06-2023, 12:13 PM)bplus Wrote: Compare Terries always recalcs the sprite positions, mine calcs all positions before running once and then for first sprite to do tilts useing the rotate sub to adjust for tilts in orbits. Huh? The example I posted performs all the calculations beforehand and stores the results in X() and y().
Oops! sorry Terry, once again I didn't read carefully, I assumed. Really embarrassing.
Between time Cobalt posted and I got my demo ready, Terry had posted, I mostly just ran his program to see what it did.
b = b + ...
07-06-2023, 05:33 PM
Awesome, thanks guys.
So I was forgetting COS, well I least I had half of what I needed to start with. now just 56 more monster groups to get programed! I'll just spend a few hours finishing up a few of them and then upload an updated demo. |
« Next Oldest | Next Newest »
|
Users browsing this thread: 6 Guest(s)