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
> [GM]Simple Grid Tutorial and Code , This is an easy and quick way to set up grid movement for your game.
LarsonCreativity
post May 18 2009, 04:47 PM
Post #1


Level 4
Group Icon

Group: Member
Posts: 47
Type: None
RM Skill: Undisclosed




I'm working on a new game, and it involves grid movement. I first set it up using a bunch of if statements, but then a friend helped me realize there was an easier way. I thought it was neat, and could help some people out. Also, there are many other things you can do with this method as well. Let me know what you think, or if you need help understanding something better.

This should go in the Step event for the object you are controlling.

CODE

x=x
y=y

//This is the amount of that you move each time
mspace = 32


/*These are the grid limits, and they set the grid boundries.  Right now their for a 10x10 grid.  
If your grid is bigger, change the xrbound and the ydbound*/

xlbound = mspace*0
xrbound = mspace*9  
ydbound = mspace*9
yubound = mspace*0

y = min( max( y - mspace * keyboard_check_pressed( vk_up )+ mspace * keyboard_check_pressed( vk_down ), yubound ), ydbound )

x = min( max( x - mspace * keyboard_check_pressed( vk_left )+ mspace * keyboard_check_pressed( vk_right ), xlbound ), xrbound )


~LC~

This post has been edited by LarsonCreativity: Feb 28 2010, 10:59 AM
Go to the top of the page
 
+Quote Post
   
The Law G14
post May 18 2009, 04:56 PM
Post #2


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,348
Type: Scripter
RM Skill: Skilled
Rev Points: 5




Does this go for rmxp or rmvx? Also, what exactly is grid movement?
Sorry if I'm being a pest.


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
LarsonCreativity
post May 18 2009, 05:05 PM
Post #3


Level 4
Group Icon

Group: Member
Posts: 47
Type: None
RM Skill: Undisclosed




Sorry, I guess I forgot to mention this is in GML (Game Maker Language). This is simple 2D grid movement. Basically, for my game at least, I created an object which was basically like a frame. I put this code in the Step event and I was able to move the frame like it was situated on a grid. This is something like 2D Fire Emblem games.

Sorry for not explaining as well as I should have.

~LC~
Go to the top of the page
 
+Quote Post
   
The Law G14
post May 18 2009, 05:18 PM
Post #4


Scripter FTW
Group Icon

Group: Local Mod
Posts: 1,348
Type: Scripter
RM Skill: Skilled
Rev Points: 5




That's alright, it looks great! But I don't have game maker, so I hope this becomes useful for some other people.


__________________________

To put in sig, copy this link:
CODE
[url="http://www.rpgrevolution.com/forums/index.php?showtopic=51540"][img]http://img40.imageshack.us/img40/6504/conceptthelawbanner.png[/img][/url]


Sig Stuff


"When you first come, no one knows you. When help them out, they all know you. When you leave, they all love you. When you come back, they've already forgotten you." -- copy into your sig if you think this quote speaks true!

If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others. -Exiled One

My Project Thread: Gai's Hunters


Go to the top of the page
 
+Quote Post
   
LarsonCreativity
post May 18 2009, 05:50 PM
Post #5


Level 4
Group Icon

Group: Member
Posts: 47
Type: None
RM Skill: Undisclosed




That's fine. I realize the GM users here are few and far apart.

~LC~
Go to the top of the page
 
+Quote Post
   
HeroOfHyla
post May 18 2009, 06:13 PM
Post #6


Twirling towards freedom
Group Icon

Group: +Gold Member
Posts: 2,791
Type: Scripter
RM Skill: Advanced




Ah, so this is for panning the map on a grid using the arrow keys? Neat script. I don't think I'd ever really have a use for it (and even if I did, I absolutely hate using stuff other people made for some reason), but I'm sure someone will be able to use it. Thanks for contributing!


__________________________
Asexual - Arizonan - Atheist
I've got a gmail account and a yahoo mail account under this name, if you need to contact me.
You can find me on facebook too. facebook.com/heroofhyla . If you send me a friend request, tell me who you are so I don't get confused.

PlagueRPG SITE IS WORKING! (if you see "test page," hit ctrl+f5)
Latest update: New battle system demo, April 19, 2010

http://heroofhyla.deviantart.com/ ----- http://heroofhyla.livejournal.com/ ----- http://thatonecomic.smackjeeves.com
Go to the top of the page
 
+Quote Post
   
LarsonCreativity
post May 18 2009, 06:18 PM
Post #7


Level 4
Group Icon

Group: Member
Posts: 47
Type: None
RM Skill: Undisclosed




Originally, I just had a bunch of if statements. This works better though, and I just added those variables in and voila. I am making a Fire Emblem engine with it, and it defiantly does the trick.

QUOTE
(and even if I did, I absolutely hate using stuff other people made for some reason)


Same here, but this could defiantly also help get people thinking about other ways to do something like this. After I figure this out, I realized there could be a lot of possibilities using this kind technique.

~LC~

This post has been edited by LarsonCreativity: May 18 2009, 06:24 PM
Go to the top of the page
 
+Quote Post
   
Rukiri
post May 19 2009, 02:34 PM
Post #8


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

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




You know you can "Snap" it to a grid right?
But this works to.


__________________________
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
   

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: 18th June 2013 - 01:10 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker