thanks for commenting.. nice mini game this one.. how did you go about with collision detection?? did you do that by comparing the pointers of each objects??? eg.. if wall pointer is == player pointer, then collide??
I store the maze in a vector of strings, Therefore is split into rows and columns, I then have a function that takes the players location and divides by the block size, that gets me the row and column location of where the player is within the maze, I can then just do simple if statements checking the surrounding spaces to see if they are walls.
thanks for commenting.. nice mini game this one.. how did you go about with collision detection?? did you do that by comparing the pointers of each objects??? eg.. if wall pointer is == player pointer, then collide??
punitnapuruntong 3 years ago
I store the maze in a vector of strings, Therefore is split into rows and columns, I then have a function that takes the players location and divides by the block size, that gets me the row and column location of where the player is within the maze, I can then just do simple if statements checking the surrounding spaces to see if they are walls.
limited06 3 years ago
@limited06
One question:
You get the tile position by didviding the Position of Player with the block size
Example:
Block Size: 32px
PlayerX: 64
64/32=2;
So in this example the tilepos will be 2?
DoNotHackMyAccount 2 years ago
Yes thats right, you do it for both the X and Y so you can work out which grid space the player is on.
limited06 2 years ago