Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Block Collision?

Author
Message
Brandon Heat
15
Years of Service
User Offline
Joined: 28th Nov 2008
Location:
Posted: 8th Jan 2009 23:46
What is block collision exactly?

I making a 2d game and doing collision like this.

What i'm doing is say there is a 4 walls in the shape of a box some where in the maze, what i am doing is basically getting the position of those walls and writting a few if statements for it such as if(player_x >= start_of_wall && player_x <= end_of_wall && player_y >= top_of_wall ect...)

Its just that this method is taking a long time and i was wondering if there is a better way of doing it. Also seeing as though its just one maze per level i didn't see the need for tiles was that a bad idea? Should i have used tiles?

What i was thinking is that if block collision is easier how do you do it?
OceanJeff
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: Ocean Shores, WA
Posted: 9th Jan 2009 09:18
That is a fine way to detect collision.

Perhaps an easier way though, is to make each of your images, sprites. dbSprite() will allow you to make your images sprites, and then you can use the dbSpriteCollision() and other related functions to determine if there was a collision. Once you know there's a collision, you can change direction or destroy items accordingly.

Hope this helps,

later,

jeff

OceanJeff
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: Ocean Shores, WA
Posted: 9th Jan 2009 09:22
Also, if you don't want to put all your images onto one sprite, for example if your center block in your maze, has more than one image overlapping it...or inside it...

then you could make an empty sprite block, and put that on the screen first, then overwrite the sprite block with your images. This allows you to still use the sprite block for accurate and easy collision detection, and still have multiple graphics in the center block of your maze.

Hope this helps too,

jeff



Sorry for posting two separate posts, but i'm still new here, and my posts are screened, so I can't go back and edit something I just posted two minutes ago...lol

Have fun,

jeff



P.S. What other projects are you working on?? Just curious. I'm working on a space colonization game.
Brandon Heat
15
Years of Service
User Offline
Joined: 28th Nov 2008
Location:
Posted: 9th Jan 2009 23:39 Edited at: 10th Jan 2009 00:15
Thankyou so much!

Spilting it up now! Its gonna be a huge time saver thankyou!

Edit: Hmm i can't get the accuarcy that i want with dbSpirte collision. Any tips?

Also could please explain this to me again?

Also, if you don't want to put all your images onto one sprite, for example if your center block in your maze, has more than one image overlapping it...or inside it...

then you could make an empty sprite block, and put that on the screen first, then overwrite the sprite block with your images. This allows you to still use the sprite block for accurate and easy collision detection, and still have multiple graphics in the center block of your maze.

I didn't quite get it thanks so much!
OceanJeff
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: Ocean Shores, WA
Posted: 11th Jan 2009 09:42
Well, I've checked it out and dbSpriteCollision works awesome with rectangles and squares, for circles you could use the distance formula, compute the distance between the objects, and when it is less than a certain amount, bingo, you've got a collision.

What shapes are you working with?

later,

jeff

Login to post a reply

Server time is: 2024-09-30 15:32:32
Your offset time is: 2024-09-30 15:32:32