My first maze game

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
BobsklimIV
Posts: 1
Joined: October 6th, 2020, 9:14 pm

My first maze game

Post by BobsklimIV » October 6th, 2020, 9:27 pm

Sooo...

I'm a complete beginner and have so far navigated my way through to tutorial 10 of Chili's erotic home movies. I've made a few clones of the classic poo game as well as some other nonsense that has culminated in the greatest idea for a game ever (see attached). However I fear I may have flown to close to the sun with this one as cannot figure out how to make the walls of the maze impassable once drawn.

In the poo tutorials we used an if statement to establish if the player had left the bounds of the screen, but extrapolating this if statement approach to defining the movable area of the maze on x,y coordinates is a bastard, and there's got to be a simpler way.

Would welcome any advice or clues on how to proceed - would also accept an answer of "wait until you watch tutorial X before attempting" if there's some fancy way I haven't yet seen.
Maze game.png
(11.64 KiB) Not downloaded yet

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: My first maze game

Post by albinopapa » October 7th, 2020, 3:05 am

Actually, if you look through his old intermediate series, he sets up a platformer game with some tile collision. This is what I did for a maze game I started but never finished.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

Re: My first maze game

Post by albinopapa » October 7th, 2020, 3:16 am

I'll give you the steps which should give you a reasonable idea.

if jumping up ( standing still ) check cells above from left to right of player
if jumping to the right, check cells from left to right top to bottom of player
if jumping left, check cells from right to left bottom to top of player
if falling straight down, check cells from left to right beneath player
if falling left, check cells from right to left and top to bottom of player
if falling right, check cells from left to right and bottom to top of player

If your game has gravity, then consider yourself always falling if you're running or standing still.

If you look closely, you notice there's an order in which to check and correct collisions based on this strategy. The reason is because if you're moving left and you check the collisions from left to right, you're going to collide with the side of a tile in front ( remember, you're always falling if you have gravity ) which prevents you from sliding by. However, if you are traveling left and search from the right then you get pushed up before colliding with the tile in front and won't be colliding anymore.

As for collision correction, determine the speed you're player object is traveling and the direction as well as how much overlap or penetration between a tile and a bounding rect around the player has.

If you multiply the X velocity by the penetration in the Y direction and the Y velocity by the penetration in the X direction, you get a ratio. This ratio determines which way to push the player so that it is not overlapping a tile.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com

ernie_avina
Posts: 8
Joined: September 5th, 2020, 1:01 am

Re: My first maze game

Post by ernie_avina » September 6th, 2021, 4:07 pm

hi! did you ever figure out houw to do it? im having the same problem im a beginner and cant read OOP as well but i dont care i want to learn exactly what your asking. but every tutorial out there has OOP implemented in their code and i just cant understand it. if you found a way without OOP would you mind sharing it with me? im desperate.been looking for almost a year.

Post Reply