Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Rotation of picture

wlzza

Sponsor

Hi there, I'm trying to make a compass for my game using VX. I need to know what is the command for rotating a picture to a certain angle but on it's centre x y. So far this is what i have figured out...

Code:
@pic = Sprite.new

@pic.bitmap = Cache.picture("Compass")

@pic.ox = @pic.bitmap.width / 2

@pic.oy = @pic.bitmap.height / 2

@pic.x = 100

@pic.y = 100

Now how to rotate it to eg. 90degrees?

Thanks in advance.
 

khmp

Sponsor

Code:
@pic.angle = 90
I believe that's all you need. Moving the draw point to the center you already have. Is there a problem that you have with the above line or didn't you know about it?

Good luck with your compass wlzza! :thumb:
 

Jason

Awesome Bro

khmp":15isdqah said:
Code:
@pic.angle = 90
I believe that's all you need. Moving the draw point to the center you already have. Is there a problem that you have with the above line or didn't you know about it?

Good luck with your compass wlzza! :thumb:

Would there be any way to do that on XP ? Would it be the same syntax or something different ?
 

Jason

Awesome Bro

Well if you know how to make a wait command in RGSS2, I suppose you could do;

wait 1 frames
rotate 10 degrees
wait 1 frame
rotate 10 degrees

Although I don't know how to do wait commands with scripting, so I can't help. (Besides, there's probably a more logical way of doing it, lol)
 

khmp

Sponsor

Some psuedo code for ya. I think the math should work but let me know.

Code:
class Wlzza_Compass

 

  Frames_To_Rotate = 5

 

  ... # Other code

 

  def update

 

    if @frames_left > 0

      degrees_to_move = @pic.angle - @destination_angle / Frames_To_Rotate

      @pic.angle += degrees_to_move

      @frames -= 1

    else

      # Just in case the division leaves a remainder

      @pic.angle = @destination_angle if @pic.angle != @destination_angle

    end

 

    ... # Other code

 

  end

 

  ... # Other code

 

  def initialize_rotate( destination_angle )

    @destination_angle = destination_angle

    @frames_left = Frames_To_Rotate

  end

end
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top