Main Menu
  • Welcome to The RPG Maker Resource Kit.

[VXA] Trigonometry values

Started by Acolyte, February 18, 2014, 05:48:25 AM

0 Members and 1 Guest are viewing this topic.

Acolyte

This may be somewhat of a weird request, and I'm not even sure it really counts as a "script", but I've been trying to recreate this rm2k3 event system in vx ace for quite some time. Even after painstakingly recreating every event, I couldn't get it to work. After thinking about it some more, I realized that there's probably already a way to have rgss do the math instead, without having to worry about creating a huge lookup table in a common event.

After a bit of searching, I found this. (pg. 284, under math, module functions.)

I don't have much experience at all with RGSS3, or ruby in general, so I have no idea how I would utilize this. Would I use a script call, or would it need some sort of code snippet? Any guidance would be appreciated.

Basic description of what I want: I'd like to be able to calculate angles from numbers stored in variables, and then pass the angle into a different variable for eventing purposes.

D&P3

[spoiler]class Game_Interpreter
  def calculate_angle
    ax = $game_variables[?]
    ay = $game_variables[?]
    bx = $game_variables[?]
    by = $game_variables[?]

    deltaX = bx - ax
    deltaY = by - ay

    angle = Math.atan2(deltaY, deltaX) * 180.0 / Math::PI
    $game_variables[?] = angle
  end
end
[/spoiler]

Place that in a new script slot and edit the $game_variables for the ones you want to use; then you can use
calculate_angle
in a script call which will place the result into the Game_Variable.



A brief explanation of scripting for you:
Anything inside of the Game_Interpreter class can be used directly through an event's script call.
Notice how the method is called calculate_angle, and you can now use calculate_angle in a script call.

That's pretty much the basics of that. If you want to modify it or add to it, video tutorials 2~4 should cover what you need in my playlist
All of my scripts are totally free to use for commercial use. You don't need to ask me for permission. I'm too lazy to update every single script post I ever made with this addendum. So ignore whatever "rule" I posted there. :)

All scripts can be found at: https://pastebin.com/u/diamondandplatinum3

Acolyte


yuyu!


[Spoiler=My Games and Art]
ℒℴѵℯ❤


My Artwork Thread

The Lhuvia Tales [Current]

Ambassador [Complete]

The Postman [Complete]

The Wyvern [Complete]

Phoenix Wright: Haunted Turnabout [Complete]

Major Arcana [Cancelled]

[/Spoiler]