GameMaker Random Level Generation

S

Shawn Hanna

Guest
Hey guys,
I've been following HeartBeast's tutorial on random level generation. Things have been going alright, but I've been stuck for a few days. Whenever I run the game, the player is able to move about halfway into the walls.
upload_2017-8-29_20-13-43.png
I can't figure out if it's the grid that is wrong, or if my move script is wrong. It's worth noting that the grid in his tutorial I think is 32x32, but mine is 64x64. I have a feeling something he did would only work with 32x32. Any help would be greatly appreciated, and if you need me to post a screenshot of the code I will.

My player's move code:
upload_2017-8-31_11-44-40.png
upload_2017-8-31_11-45-35.png

And the Level's create event:
upload_2017-8-31_23-57-34.png
 

Attachments

Last edited by a moderator:
You're going to have to provide more than a single screenshot of the problem for people to be able to help. All your movement and collision code is probably the minimum that will be required.

We also don't know which one of HeartBeasts many tutorials you are actually following, so if you could provide a link it may be that some other people have used it and know what problems it may cause.
 
S

Shawn Hanna

Guest
You're going to have to provide more than a single screenshot of the problem for people to be able to help. All your movement and collision code is probably the minimum that will be required.

We also don't know which one of HeartBeasts many tutorials you are actually following, so if you could provide a link it may be that some other people have used it and know what problems it may cause.
This is my first post so I can't add any links to the video. It's episode 2 of his random level generation series. And thanks for letting me know, I'll add some more screenshots right now.
 
S

Shawn Hanna

Guest
So I'm assuming you're doing grid-based collisions. Is the GRID 64x64 or are the sprites 64x64?
That's what's weird to me. I made the grid 64x64, and the player's sprites 64x64.
 

NightFrost

Member
Sounds like the code is still expecting the player to be 32 pixels instead of 64. Does that happen only when moving down and right into the walls, or also when moving up and left?
 
S

Shawn Hanna

Guest
Sounds like the code is still expecting the player to be 32 pixels instead of 64. Does that happen only when moving down and right into the walls, or also when moving up and left?
It's also up and left.
 

Gamebot

Member
Is it something simple like your crosshair (x, y) origin in the sprite. Centered needs to be 0,0 or 0,0 needs to be centered ect...
Is there a collision mask with this one?
 
S

Snayff

Guest
Difficult to know with the info provided so here are a few suggestions:
  • Ensure origin set to middle centre on sprites
  • Check your collision mask is the same size as the sprite
  • Check the cell width and height macros are defined as expected (64)
Whilst it isn't solving this issue I would also suggest moving on to gmwolf's tile collision method as I think it is easier to follow. There is a tutorial on his YouTube or on the tutorial forum here on GMC.
 

Gamebot

Member
Is your MACROS correct. In the video I believe he uses CELL_WIDTH and CELL_HEIGHT both set to 32. Yours needs to be 64.
 
Z

zendraw

Guest
you cant set a grid to 64x64, you can calculate in a manner that checks 64x64 cells or 32x32 cells or w/e sizes. check if you use the macros everywhere and the sprite`s mask. if you change sprites youd want to set it in its create event and use one mask.
 
S

Shawn Hanna

Guest
Ok I got it to work. For anyone else who runs into a problem like this, this is what I did. My character did not have a collision mask before, so all I did is make one. For some reason having a collision mask fixed the problem, although it was the player's sprite. Thank you guys for the help.
 
Top