
(If you didn't notice, the shoot considers the diagonal wall as a square block, in other words the collision isn't precise)
Looks terrible, doesn't it?
And well, I've decided that I have to recode the whole engine. I started it yesterday, and got quite much already, while I found another, unsolvable this time, problem.
But first of all:
I was wondering what will be the best method. I decided, that Player collision with walls will be Grid-Then-Pixel based. I couldn't think of any better name. How does it work?
Basically, whole level is divided into 32x30 blocks. This is the main grid. Every block is a Square with a 25 Pixels long edge. And every Block type has its code, like:
G_Block_Code[5,0] ="x " G_Block_Code[5,1] ="xx " G_Block_Code[5,2] ="xxx " G_Block_Code[5,3] ="xxxx " G_Block_Code[5,4] ="xxxxx " G_Block_Code[5,5] ="xxxxxx " G_Block_Code[5,6] ="xxxxxxx " G_Block_Code[5,7] ="xxxxxxxx " G_Block_Code[5,8] ="xxxxxxxxx " G_Block_Code[5,9] ="xxxxxxxxxx " G_Block_Code[5,10] ="xxxxxxxxxxx " G_Block_Code[5,11] ="xxxxxxxxxxxx " G_Block_Code[5,12] ="xxxxxxxxxxxxx " G_Block_Code[5,13] ="xxxxxxxxxxxxxx " G_Block_Code[5,14] ="xxxxxxxxxxxxxxx " G_Block_Code[5,15] ="xxxxxxxxxxxxxxxx " G_Block_Code[5,16] ="xxxxxxxxxxxxxxxxx " G_Block_Code[5,17] ="xxxxxxxxxxxxxxxxxx " G_Block_Code[5,18] ="xxxxxxxxxxxxxxxxxxx " G_Block_Code[5,19] ="xxxxxxxxxxxxxxxxxxxx " G_Block_Code[5,20] ="xxxxxxxxxxxxxxxxxxxxx " G_Block_Code[5,21] ="xxxxxxxxxxxxxxxxxxxxxx " G_Block_Code[5,22] ="xxxxxxxxxxxxxxxxxxxxxxx " G_Block_Code[5,23] ="xxxxxxxxxxxxxxxxxxxxxxxx " G_Block_Code[5,24] ="xxxxxxxxxxxxxxxxxxxxxxxxx"I have to explain how collision detection for player works, before I can continue.
Player has 4 collision points, in every corner one. So when I go left, It detects for collision in positions (X,Y) and (X,Y+10) (11 is player height). When I fall, pixels at (X,Y+10) and (X+10,Y+10). In other words, only those corners which should be are tested for collision.
So, how the whole checking collision looks:
First I determine in which grid position lies needed pixel (Floor(corner_x/25),Floor(corner_y/25)). If that thing is an empty space, nothing changes. But if there is a wall, it did further checking. It returned position IN TILE (The position relative to current grid square's X and Y position) which is "Something Mod 25". Then the position was compared with code we have above, and determined the ending position. Sounds a bit complicated, but I'm not able to describe it better.
Anyway, this algorithm led to two mayor problems:

A - Here we have situation where player falls too fast and lands too low. In first step player will be pushed to the level as if the diagonal didn't exist. Then in second step it will "Notice" the DiagWall and end up in proper place. This can be quite easily fixed with few loops. But in the end it will be too slow to be acceptable. I think.
B - The player falls on a wall so that the Collision Points don't detect the wall and it looks bad, and works bad. I have no solution for this.
So, I was wondering if you have any good advice about it.
I also though it would be nice and fast to use N's engine, but understanding how it works is too hard for me (If it was better documented then maybe).
And last thing, if you know links to some good Platformer Engines (Not bare code, unless well commented) or some articles/ideas on how to make it good.
Thanks in advance!


Sign In
Create Account


Back to top









