Okay, so I'm trying to do the collision more efficiently than how I did it in the first game. The first game's approach was rather... well... silly and very assumption-based. Timmy would ALWAYS move at a speed of 2, so this worked. I'm still amazed that it did work to be honest.
The problem with BK2 is I want the complicated tiles that could move you at speeds that are not 2, so I need something better. Anyway...
What I'm basically doing is this:
-There's a hitbox naturally. 4 points which basically constitute top, bottom, left, right. These points are combined these into a value to lookup the tile on the grid. So if you were at left $7F and top $40, for instance, that'd be tile number $47 to look at.
-If you request to move horizontally, you are permitted to do so and the box updates with the acceleration you move in. Then comes a series of checks if the box is within something solid...
-What I do is see if either your top left or bottom left points is within something solid and if so, "push the player right" so that you are touching the solid object to your left. Similar behavior of course happens for the right points and "pushing left" in that case.
The main problems I am seeing with this are what'll happen for disappearing blocks? Something could instantly become solid and push you away. I've done memory altering tests and you do get pushed out, but that may not be the desired effect... Interestingly, if all 4 points are in the box, you don't get pushed.
Another issue I'm seeing would be with jumping or falling and trying to "squeeze into" something that's only 1 tile high. Your jump height is variable and if you get "pushed out" then going into something 1 unit high might not work as easily. I remember doing what felt like VERY hackish code to make this work in BK1.
I don't know. Is there a better way?
The problem with BK2 is I want the complicated tiles that could move you at speeds that are not 2, so I need something better. Anyway...
What I'm basically doing is this:
-There's a hitbox naturally. 4 points which basically constitute top, bottom, left, right. These points are combined these into a value to lookup the tile on the grid. So if you were at left $7F and top $40, for instance, that'd be tile number $47 to look at.
-If you request to move horizontally, you are permitted to do so and the box updates with the acceleration you move in. Then comes a series of checks if the box is within something solid...
-What I do is see if either your top left or bottom left points is within something solid and if so, "push the player right" so that you are touching the solid object to your left. Similar behavior of course happens for the right points and "pushing left" in that case.
The main problems I am seeing with this are what'll happen for disappearing blocks? Something could instantly become solid and push you away. I've done memory altering tests and you do get pushed out, but that may not be the desired effect... Interestingly, if all 4 points are in the box, you don't get pushed.
Another issue I'm seeing would be with jumping or falling and trying to "squeeze into" something that's only 1 tile high. Your jump height is variable and if you get "pushed out" then going into something 1 unit high might not work as easily. I remember doing what felt like VERY hackish code to make this work in BK1.
I don't know. Is there a better way?