Need Help With Another Game!
Blitz3D Forums/Blitz3D Beginners Area/Need Help With Another Game!
| ||
Hi Everyone, If you wouldn't mind, I could use some help with 2D collisions from an over head perspective. I just can't get it to work very well. You see, I recently decided to do a complete graphical over haul for my Across The Land game, and changed the view to an over head perspective. Things are coming along quite well, except for this collision problem. DownLoad the Heavily Commented File at http://hosted.filefront.com/werdnaworld and if you have any ideas, or suggestions on how to get the collisions working, please tell me. The One Gnome(The Gnomeliest Of All Gnomes) |
| ||
This works pretty well, except it isn't smooth when you are against the tree |
| ||
Hum... Very close KillerX, Certainly better than what I had. Still not quite there yet. If you, or anyone else, can maybe come up with a variation on this, that would probable work. So thanks for your help, and I'll play around with the code myself, and see what I can do. The One Gnome(Whos game is about 50% complete. Most of the coding is done, but I'm completly lacking in graphics) |
| ||
Optimised. Still needs a bit of improvement. |
| ||
If Not ImagesCollide(Player\image,Player\x,Player\y,0,Tree\image,Tree\x,Tree\y) StopRight = 0 endif Clean,and simple. |
| ||
Optimized Indeed, Thanks Killer. This does still need some improvement, but it is certainly good enough so I can continue work on the game and simply come back and perfect it later. And thanks for your help too Cp, but I think Killers way is the way to go. If either of you can come up with an even better version, please post it. And thanks again for the help. The One Gnome(Who traveled across the land) |
| ||
Why not only check for collisions? You don't need to find out whether it's a left collision or not. Record the players x and y co-ords. Check for movement control moving the player along the x-axis. If movement causes collision, restore old x value. Check for movement control moving the player along the y-axis. If movement cause collision, restore old y value. Draw_everything() DONE Just make sure you draw everything last. No movement should be done, or corrected AFTER the drawing is done, as you will see the effects of positions moving due to collisions. |
| ||
The players X and Y coordinates never change for this game, They remain at 400, and 300. I use ScrollX and ScrollY to move things instead. But I get what you mean, and I think that I can apply that to ScrollX and ScrollY. So Thanks for the suggestion Ross C:) The One Gnome(Who will save the land from evil) |
| ||
;Update The above problem has been fixed, so major thanks guys. But LOL, I now have another collision problem. I have begun work on the games first town, and am having some problems with the inhabitants. They can collide with the town walls just fine,(using a slight variation of KillerX's collision code) but they sometimes get stuck on the walls edges and can't get back out. I have commented the new additions to my code, and if someone can help fix it so they stop getting stuck on the walls I would certainly be grateful. Over Mountain, Hill, and lee, Over the desert sand, The one gnome cries out joyfully; "I'm wandering across the land!" |
| ||
You'll want to use Loadanimimage() once for the entire potato(all four sides). |
| ||
Ok, thanks for the tip. Will that help with the collisions? For the evil wizard Bruner DarkHeart, has strecthed his oppressive hand, and sucked all joy and cheerfullness from our once happy land! |
| ||
It might help. |
| ||
Got it, I'll try it out. Thanks again Killer. And the fairie of joy and good cheer has been put into an iron barred cage, the gnomes are all fearful and downcast, because of this odious mage! |