• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

grids

W

Wild_West

Guest
I'm trying to make a game with grid movement and grid based attacking but try as I may I can't seem to figure out even how to get the grid set right in the room.
Can anyone direct me to or else provide a good simple for an idiot like me to follow tutorial on how to use ds_grid functions.
 

Nux

GameMaker Staff
GameMaker Dev.
(watch this to better understand the fundamentals of grids)
(watch this whole series because it shows you how to create a map from which you can collide with)
 
W

Wild_West

Guest
(watch this to better understand the fundamentals of grids)
(watch this whole series because it shows you how to create a map from which you can collide with)
I already watched all the stuff on youtube I could find, that's why I'm asking here.
I have HeartBeast's book too.
I mean I get how they work, it's just the tutorials don't really help with what I'm trying to do specifically, which yeah if I understood it well enough I wouldn't need an exact tutorial but I guess I'll have to ho over them again.
 
W

Wild_West

Guest
(watch this to better understand the fundamentals of grids)
(watch this whole series because it shows you how to create a map from which you can collide with)
Maybe if you could just help me with the math. I mean if I wanted to make a grid that just sets itself to the roo's height and width how would I figure out how many cells that is? since I'm not defining it with just a number like in the docs example
 

Nux

GameMaker Staff
GameMaker Dev.
how would I figure out how many cells that is?
Oh, that's pretty simple; just divide the room height and width by the "width" of each cell (usually 32 pixels) to get the number of cells along each dimension

Code:
ds_grid_create(floor(room_width / 32), floor(room_height/32));
Edit: infact, he even goes over this in his tutorial:
upload_2017-1-29_16-46-48.png
 
W

Wild_West

Guest
Oh, that's pretty simple; just divide the room height and width by the "width" of each cell (usually 32 pixels) to get the number of cells along each dimension

Code:
ds_grid_create(floor(room_width / 32), floor(room_height/32));
Edit: infact, he even goes over this in his tutorial:
Oh right, duh. I guess it has been a while since I looked at that one.
Alright so here's another quick question then, how do I draw the grid on screen? I just tried a loop but it just crashed my whole system. I wanted to see how many cells I actually got from the division so I could access the right positions.
 
W

Wild_West

Guest
Oh, that's pretty simple; just divide the room height and width by the "width" of each cell (usually 32 pixels) to get the number of cells along each dimension

Code:
ds_grid_create(floor(room_width / 32), floor(room_height/32));
Edit: infact, he even goes over this in his tutorial:
Nevermind , I really am an idiot. I can just use the room editor grid and count the cross sections to find out the number of cells I'll have for any given size.
 

Nux

GameMaker Staff
GameMaker Dev.
Oh nononono
NEVER draw from your grid. always create a background image or place tiles at the positions on start-up; the time taken to draw all of a grid's cells would increase parabolically.
You're calling a draw cycle a few thousand times!
 
Top