Knuckle Cracker

Creeper World 3 => The Coder's Corner => Topic started by: Nicant on August 20, 2015, 05:18:07 PM

Title: need help on image rotation
Post by: Nicant on August 20, 2015, 05:18:07 PM
Is it possible to have a CRPL core rotate it's image the direction it is moving? I am trying to make a plane producing unit and the planes look hilarious if they don't rotate in the direction they are moving. If anyone knows if it is possible please tell me how.

P.S. I am a noob at CRPL.
Title: Re: need help on image rotation
Post by: driesemol on August 20, 2015, 06:25:50 PM
i'm a newbie as well at CRPL, but i think you need to take a look at the chimera map in the VirgilW system in the alpha sector. He uses CRPL to make a cannon-like structure, and the cannon itself (image) rotates to the place it's going to fire (direction). Perhaps you can get something usefull from it.

To get this CRPL script (and others from existing maps): check this wiki article: http://knucklecracker.com/wiki/doku.php?id=crpl:examine_map_resources
Title: Re: need help on image rotation
Post by: Nicant on August 21, 2015, 08:43:21 AM
ok thanks i'll give it a try
Title: Re: need help on image rotation
Post by: warren on August 21, 2015, 09:08:46 AM
Well, there is the setImageRotation (http://knucklecracker.com/wiki/doku.php?id=crpl:docs:setimagerotation) command.

example:
self "main" 1.2 SetImageRotation

Edit: oh, if you were talking about calculating it out, you need a vector.
deltaX = destX - startX
deltaY = destY - startY
ang = atan2(deltax,deltay)


Title: Re: need help on image rotation
Post by: Nicant on August 21, 2015, 02:07:45 PM
I knew about the command i just had no idea how to calculate but thanks for telling me about the vector!