Just as the title says, I'm having some issues with collision in my game. I'm able to set the flags for collision in the yellow version of the map to work with no problem, but for some reason, when I load the blue version of the map by pressing the "B button" the game behaves as if the objects in the yellow version were still there and doesn't allow the cat to move freely.
The blue version of the map is tied to a game state called "night" and the yellow one is tied to one called "day". I really don't know where I'm messing up here. can somebody help me figure it out?
I'm new to programming in general so forgive the spaghetti code.
since you're looking at a different part of the map, your calls to mget will need an offset equal to that in your map() call to be checking map data at that location instead of the region around 0,0
In _draw you check if it's the day, in witch case you draw the day background with map(0,0) or the night with map(0,16) .
This is visually what you want, but when you test for collisions in
_update / collide() , you check cat.x and cat.y against the map. The collision code doesn't care if it's day or night, the cat's coordinates are currently always in the day part of the map.
You can fix this either by changing the cat's coordinates when the time of day changes (use camera so the night part of the map is onscreen in that case), or incorporate the day/night state into the collision logic.
Thanks to both of you guys! You rock. Ultimately I realized my error was the way I was calling for the map as it was just too convoluted considering the only changes are the color and the text on screen, so I ultimately decided to play around with mset() and pal() to accomplish the same results and avoid the headache
[Please log in to post a comment]