Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Point Direction, useful for a-rpgs and other cool things
Rukiri
post Feb 22 2011, 01:20 PM
Post #1


emerge -avt awesome! Wait... it brings me.... HERE?!
Group Icon

Group: Revolutionary
Posts: 1,723
Type: Scripter
RM Skill: Advanced




This is something I wrote to originally translate into ruby(which it will eventually) but I first had to figure out what point direction does. Obviously it points to x,y,x2,y2 and trig is involved but after disecting the function I came up with something that did exactly what I needed.

I generally only use this for a-rpgs when it comes to battle collisions, so it points from herox,heroy,aix,aiy and depending on each X/Y it'll move straight back or diagonally.

This is also great for space shooters.

Script:
CODE
x1 = argument0;
y1 = argument1;
x2 = argument2;
y2 = argument3;

dt = sqrt(sqr(x2 - x1) + sqr(y2 - y1));
dir = 0;

if (x2 > x1){
   if (y2 > y1){
       dir = ceil(arcsin((y2 - y1)/dt));
   }else{
       dir = ceil(360 - arcsin((x2 - x1)/dt));
   }
}else{
   if (y2 > y1){
       dir = ceil(180 - arcsin((y2 - y1)/dt));
   }else{
       dir = ceil(180 + arcsin((x2 - x1)/dt));
   }
}
return (((arctan2(argument0-argument2,argument1-argument3)* (180/pi))) + 450) mod 360;


__________________________
Xeilsoft
- Follow your dreams to the very end..

Kits that I'm working on.
[Unity3D 4.0] LTTP/Minish Cap - I don't have time for custom gfx like what the pze folks are doing but I will try and work on some enhanced LTTP graphics.

Main PC
Core i7 3820 overclocked @ 4.8GHZ
Galaxy: Nvidia Geforce GTX 680 GDDR5 2GB
Asrock X79 Extreme9 w' creative sound
64GB corsair platinum @ 1600MHZ
Muchkin 128GB SSD(boot), OZKIN 2TB SSD, Western Digital GREEN 1TB HDD.
Rosewill Lightning 1000W PSU
OS: Funtoo Linux, Windows 8 (Virtual Machine)

iMac (March 2013)
3.4GHz Quad-core Intel Core i7, Turbo Boost up to 3.9GHz
16GB 1600MHz DDR3 SDRAM - 2X8GB
1TB Serial ATA Drive @ 7200 rpm
NVIDIA GeForce GTX 680MX 2GB GDDR5
Go to the top of the page
 
+Quote Post
   
Shadyone
post Feb 23 2011, 12:02 AM
Post #2


K@w411ii~desudesu:3<(^^)>s@$uk3Kun$0h0T~.~kyaaaa
Group Icon

Group: Revolutionary
Posts: 1,211
Type: Developer
RM Skill: Beginner
Rev Points: 20




I know how to script in gml but what the hell I can't understand that script o.O


__________________________







Speedtest



ISML 2012

ARENA 01: [Elucia de Lute Ima] Kasugano Sora
ARENA 02: Gasai Yuno [Aragaki Ayase]
ARENA 03: Irisviel von Einzbern [Abstained] Haruna
ARENA 04: Shimada Minami [Iwasawa Masami]
ARENA 05: [Nakagawa Kanon] Kirishima Shōko
ARENA 06: [Fear Kubrick] Himeji Mizuki
ARENA 07: [Eucliwood Hellscythe] Kanzaki H. Aria
ARENA 08: Gokō Ruri (Kuroneko) [Makise Kurisu]
ARENA 09: [Yui] Victorique de Blois
ARENA 10: [Shiomiya Shiori] Mine Riko
ARENA 11: Mikazuki Yozora [Sakura Kyōko]
ARENA 12: Charlotte Dunois [Abstained] Yuzuriha Inori
ARENA 13: [Akemi Homura] Tōwa Erio
ARENA 14: Hasegawa Kobato [Kuroi Mato]
ARENA 15: [Kōsaka Kirino] Kashiwazaki Sena
ARENA 16: [Tachibana Kanade] Nakamura Yuri
ARENA 17: Suzutsuki Kanade [Haqua du Lot Herminium]
ARENA 18: [Honma Meiko] Konoe Subaru
ARENA 19: [Nagato Yuki, Asakura Ryōko] Misaka Mikoto, Shirai Kuroko
ARENA 20: [Hiiragi Kagami] Shiina Mafuyu
ARENA 21: Ichinose Kotomi [Sanzen'in Nagi]
ARENA 22: [Last Order] Hirasawa Ui
ARENA 23: Shirai Kuroko [Izumi Konata]
ARENA 24: [Nymph] Ikaros
ARENA 25: Konjiki no Yami [Holo]
ARENA 26: [Nakano Azusa] Tōsaka Rin
ARENA 27: [Misaka Mikoto] Hirasawa Yui
ARENA 28: [Suzumiya Haruhi] Saber
ARENA 29: C.C. [Asahina Mikuru]
ARENA 30: [Sakagami Tomoyo] Index L. Prohibitorum
ARENA 31: Akiyama Mio [Oshino Shinobu]
ARENA 32: [Aisaka Taiga] Louise Vallière
ARENA 33: [Sengoku Nadeko] Katsura Hinagiku
ARENA 34: [Nagato Yuki] Senjōgahara Hitagi
ARENA 35: [Shana] Illyasviel von Einzbern
ARENA 36: Hecate [Fujibayashi Kyō]
ARENA 37: Kotobuki Tsumugi [Furukawa Nagisa]
ARENA 38: [Kamina, Yoko Littner] Natsu Dragneel, Lisanna Strauss
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th May 2013 - 09:24 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker