help moving a sprite in a ellipse - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: help moving a sprite in a ellipse (/showthread.php?tid=1815) |
help moving a sprite in a ellipse - Cobalt - 07-06-2023 Can somebody help me figure out the code to get a sprite to follow an ellipse? I've tried various methods with SIN() but can't quite pull it off, I am trying to recreate the effect in the attached gif RE: help moving a sprite in a ellipse - TerryRitchie - 07-06-2023 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)
RE: help moving a sprite in a ellipse - bplus - 07-06-2023 Here is one sprite in constant ellipse Y- and b+ constantly tilting ellipse by a degree after every orbit: Code: (Select All)
RE: help moving a sprite in a ellipse - OldMoses - 07-06-2023 (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. RE: help moving a sprite in a ellipse - bplus - 07-06-2023 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. RE: help moving a sprite in a ellipse - TerryRitchie - 07-06-2023 (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(). RE: help moving a sprite in a ellipse - bplus - 07-06-2023 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. RE: help moving a sprite in a ellipse - Cobalt - 07-06-2023 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. RE: help moving a sprite in a ellipse - TerryRitchie - 07-06-2023 (07-06-2023, 01:02 PM)bplus Wrote: Oops! sorry Terry, once again I didn't read carefully, I assumed. Really embarrassing. No worries |