I need a little help with my game. I am making a game that is an over head map scroller. You walk around the city and do whatever. I was having trouble with thinking of a way to make a collision between two images, and have a different collision for each wall.
What was happening before is I would collide with the top wall, and stop movie, collide with the bottom, and get pushed all the way through the building to the top.
Now i believe i solved this, but i am not sure it is all that efficient of a collision system.
Some times when i am testing it, i will walk into a building, stop, try to turn around, and not be able to walk away. In which case i sit and flail for a while until the building lets me out. Obviously i dont like that much.
Here is a sample of my code.
This isnt exact code, I am at school right now, in computer class, and decided to ask about it. This is basically what my code is. As you can see, if the images overlap, and the key is being pressed up, then move everything back to simulate collision.
I make each key press move the entire background, and every building in my game. Im not so sure if that is very efficient or not, but could not get a straight answer on my last question about it, so decided to just go with it.
Any way, if someone could answer my question that would really help me. Thank you very much everyone.
-Kevin
What was happening before is I would collide with the top wall, and stop movie, collide with the bottom, and get pushed all the way through the building to the top.
Now i believe i solved this, but i am not sure it is all that efficient of a collision system.
Some times when i am testing it, i will walk into a building, stop, try to turn around, and not be able to walk away. In which case i sit and flail for a while until the building lets me out. Obviously i dont like that much.
Here is a sample of my code.
If imagescollide(playerimage,player\x,player\y,0,Buildingimage, building\x,building\y,0) and Keydown(UpKey) then building\x=building\x - humanspeed back\x=back\x - humanspeed endif
This isnt exact code, I am at school right now, in computer class, and decided to ask about it. This is basically what my code is. As you can see, if the images overlap, and the key is being pressed up, then move everything back to simulate collision.
I make each key press move the entire background, and every building in my game. Im not so sure if that is very efficient or not, but could not get a straight answer on my last question about it, so decided to just go with it.
Any way, if someone could answer my question that would really help me. Thank you very much everyone.
-Kevin