Author |
Message |
Bored
|
Posted: Thu Dec 15, 2005 10:10 pm Post subject: Problem with my collision |
|
|
Ok so i'm creating a top-down 2-d engine and i'm using whatdotcolour and drawing lines for my collision. Currently my problem is that when a player turns they sometimes turn so that they can move through walls so i decided that i would have a boolean variable to tell me if the player had turned left and one for right as well. The first thing the run procedure for the plyer class would do when run was called is to then check if it's touching a wall if it is it would undo any turns and end the procedure there (beacause the collision isn't draw correctly for the now unturned player). I figure if I unturn the player the player then don't let them move that run I'd know they weren't in a wall because they wouldn't have moved into one without turning. I don't know why but this logic is not working and i've tried everthing but no matter what there always seems to be a way to turn and either get stuck on the wall of break through it. I've attached my code so far and it may have some errors depending on the version of turning you have but I trust that anyone who could follow the code and fix this problem has the knowledge to deal with these errors. Oh ya before I forget you must edit Engine.DAT in the /system directory and change the game direcetory to the main folder (not the system folder but the one containing the system folder)
Description: |
|
Download |
Filename: |
The Bored Engine 0.2.zip |
Filesize: |
27.45 KB |
Downloaded: |
99 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Albrecd
|
Posted: Tue Dec 20, 2005 9:48 am Post subject: (No subject) |
|
|
I think you have the right Idea with the direction booleans, but maybe instead of undoing the turn, just move them the same distance back in the opposite direction if they hit a wall.
|
|
|
|
|
|
Tony
|
Posted: Tue Dec 20, 2005 10:03 am Post subject: (No subject) |
|
|
should be checking if you can move in that direction before moving, not walk into a ball and bounce out of it. This is just asking for problems.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Albrecd
|
Posted: Tue Dec 20, 2005 12:30 pm Post subject: (No subject) |
|
|
But if you move it back after it hits the wall, but before the View.Update, It won't appear to have moved.
|
|
|
|
|
|
Bored
|
Posted: Tue Dec 20, 2005 9:03 pm Post subject: (No subject) |
|
|
First off in response to Tony it does check to see if it can move there before moving the problem is that it can move hit a wall and then turn so that it's technically in the wall. I think i figured out the problem though. Even though I have it so that if it senses it turned into a wall it turns back it now sometimes turns so that it moves to the otherside of the black line (i.e. the black line it sees for colision moves two spaces jumping to the other side of the object) thus not sensing that it turned into the wall. So now I'm trying to find a solution to this problem. If you have any suggestions please post them but i think if I add in some drawfills and colouring in the areas where between the inside and outside of the wall it will then always sense when it's turned into the wall thus fixing the problem. I'll post if If this works, thx for the help anyways and sorry for not really documenting it well.
|
|
|
|
|
|
Bored
|
Posted: Tue Dec 20, 2005 9:27 pm Post subject: (No subject) |
|
|
OMG I'm dumb, I just forgot to change turnedLeft and TurnedRight back to false so when you tried to turn one way it worked and would turn you back but when you then attempted to turn the other way you'd hit black and turn both ways leaving you stuck just turning 4 degrees one way and then 4 the other each round leaving you unmoved. Wow how did I not notice that It was so simple and I spent hours on end trying to fix it.
|
|
|
|
|
|
|