Author Topic: Moving sprites in a circle  (Read 12844 times)

0 Members and 2 Guests are viewing this topic.

Offline Raylin

  • Godslayer
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1392
  • Rating: +83/-25
  • I am a certifiable squirrel ninja.
    • View Profile
    • Ray M. Perry
Moving sprites in a circle
« on: April 05, 2010, 11:39:17 pm »
I just now looked at a tech demo BuilderBoy released with an old update of Axe.
I am in need of some explanation of said technique.

Or is this physics magic again?
Bug me about my book.

Sarah: TI-83 Plus Silver Edition [OS 1.19]
Cassie: TI-86 [OS 1.XX]
Elizabeth: TI-81 [OS 1.XX]
Jehuty: TI-83 Plus Silver Edition [OS 1.19]
Tesla: CASIO Prizm







Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Moving sprites in a circle
« Reply #1 on: April 05, 2010, 11:40:45 pm »
Which one?
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Moving sprites in a circle
« Reply #2 on: April 05, 2010, 11:50:45 pm »
You would prbly need Builderboy help directly, but now his forum posting activity is getting more and more sparse (he will post a lot on a day, then not post for 3 or 4 days, then post like 30 times one day and go in hiatus again) so good luck x.x

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Moving sprites in a circle
« Reply #3 on: April 06, 2010, 12:17:34 am »
Hiya, and yeah, right now is a pretty busy time in school for me, so activity will probably be pretyt low until AP testing is all finished and my teachers stop giving me all this review homework X.X

As for the rotating sprites, it uses a custom Sin routine that is located both early in the routines section, and at the end of the program.  It inputs a value from 0-63 (0 to 2PI) and outputs the result in 0-10.  Using this sin routine, it is fairly easy to generate a roaring sprite loop, using the sin routine for Y, and offsetting the angle by 90 to change it into a Cos routine (cos(ang) = sin(ang+90)) for X.  Do you want me to go into more detail about the specifics of the code, and how the Sin routine works?

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Moving sprites in a circle
« Reply #4 on: April 06, 2010, 12:59:08 am »
When does AP testing ends?

It would be cool if you wrote some kind of tutorial, especially for ppl who didn't do trig for years like me (we only skimmed through it in math, during a few days, then moved on, in 2002)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Moving sprites in a circle
« Reply #5 on: April 06, 2010, 01:10:20 am »
In a couple of weeks.  Its a big deal right now since its Senior year and i'm taking 3 AP classes. 

I think i will include a trig tutorial in my physics thread, as it is sooo useful that i use it all the time in complex physics and even basic rotational movement.  I might post that while i'm still getting the collision section finished (its more complicated to explain than i thought)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Moving sprites in a circle
« Reply #6 on: April 06, 2010, 01:16:27 am »
Ouch x.x, I sure hope the same thing that happened to Liazon, nitacku and the like won't happen to you x.x (they took that many and eventually moved on completly from other stuff like calcs x.x)

Offline meishe91

  • Super Ninja
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2946
  • Rating: +115/-11
    • View Profile
    • DeviantArt
Re: Moving sprites in a circle
« Reply #7 on: April 06, 2010, 01:16:40 am »
I could possibly help with some explanations of trigonometry things.

@Builderboy
If you know what kind of things you might wanna explain or anything like that you could send me a list or something and I could start working on explanations/tutorials or something. If ya want :)
Spoiler For Spoiler:



For the 51st time, that is not my card! (Magic Joke)

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Moving sprites in a circle
« Reply #8 on: April 06, 2010, 04:21:09 am »
Axe doesn't have sin() and cos() yet.  I'm adding those when I switch to singed numbers.  Builderboy used the first 2 terms of the taylor series expansion of sin to get approximations.  That's probably why the code doesn't make much sense at first glance.  If you haven't taken calculus then its probably best you wait until I get the trig functions supported becasue the actual math involved is a lot more complicated.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Moving sprites in a circle
« Reply #9 on: April 06, 2010, 04:25:40 am »
I thought Axe alerady switched to signed numbers a few versions ago?

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: Moving sprites in a circle
« Reply #10 on: April 06, 2010, 04:28:35 am »
Nope x.x  The only one I did so far was multiplication.  I still have to write about 15 new routines from scratch for signed math, but I'll see if I can do them all (or most) by next version.
« Last Edit: April 06, 2010, 04:29:08 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Moving sprites in a circle
« Reply #11 on: April 06, 2010, 04:31:58 am »
Oh ok, I guess when I heard about the multiplication part I misunderstood and thought it was Axe as a whole x.x. Take your time, though (since there's school and stuff)

SirCmpwn

  • Guest
Re: Moving sprites in a circle
« Reply #12 on: April 06, 2010, 08:47:17 am »
Well, if you find a viable sine and cosine routine, then these equations are used to rotate, where x and y are the position, and x' and y' are the resulting position:
x' = x*cos(angle) - y*sin(angle)
y' = x*sin(angle) + y*cos(angle)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Moving sprites in a circle
« Reply #13 on: April 06, 2010, 02:11:17 pm »
so for example something like this? (TI-BASIC)

9->X
9->Y
ClrDraw
While 1
For(Z,0,359
Pt-On(X*cos(Z)-y*sin(Z),X*sin(Z)-y*cos(Z
End
End

right?

(Altough this example appears to be kinda buggy... the first time the dot is displayed at the highest top value it can be as well as the farthest to the right x.x)

SirCmpwn

  • Guest
Re: Moving sprites in a circle
« Reply #14 on: April 06, 2010, 06:20:31 pm »
That looks almost right.
The Pt-On line should look like this:
         Look here↓
Pt-On(X*cos(Z)+Y*sin(Z),X*sin(Z)-Y*cos(Z
And, it can be optimized to this as well:
Pt-On(Xcos(Z)+Ysin(Z),Xsin(Z)-Ycos(Z   // Removed "*" tokens
Keep in mind that it rotates around the origin, or the 0, 0 point.  Also, you can keep adding 1 to Z, and it will still work.  Z does not have to be between 0 and 360, 361 will rotate it 1 degree.