Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Moving things in a curvy motion  (Read 2567 times)

0 Members and 1 Guest are viewing this topic.

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Moving things in a curvy motion
« on: February 10, 2012, 11:55:16 PM »

Hello! =)

So, I kinda got sick of making a cicular/curvy motion frame for frame. =D"
Then I found >this< Thread, but unfortunatly the links are down.
Would somebody mind explaining it to me?
While I tried to overcome my... uhm... dislike for maths, I'm still not too sure how to translate this into WME script.

I'd appreciate your help, it means a lot to me. :>

- R.
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Moving things in a curvy motion
« Reply #1 on: February 11, 2012, 09:21:15 PM »

Hey :))

I did this in ghost in the sheet using predefined sin / cos table. I'd need to check the 6 years old sources, but it was something like this (entirely untested):

in game.script

Code: WME Script
  1.  
  2. global SinTable;
  3. global CosTable;
  4.  
  5. for (var angle=0;angle<360;angle=angle+1)
  6. {
  7.    SinTable[angle] = Math.Sin(angle);    // note, that WME sin / cos eats angles, not radians which made me pulling my hair off
  8.    CosTable[angle] = Math.Cos(angle);   
  9. }
  10.  

Now when you need the circular motion, you can use

Code: WME Script
  1.  
  2. global SinTable;
  3. global CosTable;
  4.  
  5. var ent = Scene.GetNode("Some entity");
  6. var radius = 30; // radius of the circular motion
  7.  
  8. var centerX = ent.X;
  9. var centerY = ent.Y;
  10. var angle = 0;
  11.  
  12. while(1)
  13. {
  14.    
  15.     ent.X = centerX + SinTable[angle] * radius;
  16.     ent.Y = centerY + CosTable[angle] * radius;
  17.  
  18.     angle = angle + 1;
  19.     if (angle == 360) angle =0;
  20.     Sleep(50);
  21. }
  22.  
  23.  

Also note, that for this to work well, you should use a sprite with a hotspot defined in the center of the image and not the default upper left corner.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

Ryouko

  • Clumpsy, tea loving artist~
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Female
  • Posts: 23
  • Uhm... nothing to say here! =D
    • View Profile
Re: Moving things in a curvy motion
« Reply #2 on: February 11, 2012, 09:29:46 PM »

Oh my gosh, this is just perfect!
Thank you sooooooooooo much, metamorphium! :>
It makes everything so much easier! <3

- R.
Logged
 

Page created in 0.078 seconds with 25 queries.