Ard_Flamingo
(i need to finish my math homework)
1
3 threads actually seems quite doable. Anyway, I need some help with collision.
How?
Quite blunt, but really, how? How do I check for collision between the player, possibly enemies, and the (tile based) map?
Another thing is that one of the tiles, designated as ‘Cap,’ needs to have both wall, and ground logic, depending on if the player hits it at the side, or falls on top.
I can’t stall the collision any longer, seriously, besides the map, this is was always my biggest fear :/
It’s probably going to change by the same you see this though. I think I finally cracked a good system for all the map pointers and what not when I was in the shower, so I’m going to try and add that in right now.
I’m not going to hang around because it’s late, but since I’m here:
It may or may not make much sense.
(Probably less if you don’t know what Entity & means. I can’t remember if I told you about references or not.)
I’m marginally worried about this:
I can think of good reasons to have arrays of pointers, but I’m wondering why you’ve got arrays of pointers that are seemingly something to do with map dimensions.
1 Like
Ard_Flamingo
(i need to finish my math homework)
3
Yeah, you did!
That’s some stuff from earlier before. I decided to just make the map dimensions themselves an array then use a single variable to just select the current map dimensions. Of course, still a pointer for the actual map data.
If they’re boxes then by definition they’re rectangles.
What shapes are you trying to test exactly?
As far as I saw your map was made up entirely of rectangular tiles, hence I showed you some code that deals precisely with a grid of rectangles.
Are you planning to incorporate slopes or something?
Depending on the shape you don’t necessarily need per-pixel collision, e.g. circles are pretty easy to do. It really all depends on what your goal is.
1 Like
Ard_Flamingo
(i need to finish my math homework)
8
I was assuming that the entire map would be one hitbox, that’s what Rect does, right? With Rect you can’t have like . . . idk, organic shapes? Not really organic, but like more complex than a single rectangle because it’s like multiple rectangles protruding from the ground-which is a rectangle too-if you know what I mean.
Given the tile coordinates of a tile (i.e. its row and column index in the array of map data, not its position in the virtual world, or the position at which it is drawn to the screen) you can calculate a rectangle that represents the ‘physical’ space a tile occupies in the virtual world.
Then you need to create a Rect for the player, for which you’ll need the player’s world coordinates (as opposed to the player’s screen coordinates).
That’s only half the battle though. Once you know that a player is colliding with a tile, you need to decide how to resolve that situation.