Jump to content
  • Advertisement
Sign in to follow this  
mlady

2d racing game barriers

This topic is 3610 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I am making a 2d racing game from top view for a mobile device. I am stuck for 2 weeks on how to make good barriers. The best I got is an sorted array of coordinates of where the barrier should be (about 6000 items). And what I'll do is that I have for(i=0;i<6000;i++) { here I test position of a car wiv each barrier coordinate and then do some action like change car's speed and angle} I there any simplier way? Because it gets significantly slower if the racing map is bigger and the barriers are longer (about 10 000 items). and of course there will be opponents so I am afraid this is not good solution. it must also be very precise because the graphics are in high detail. thanks for any advice. if you don't understand my system, that's probably because it's crap. :)

Share this post


Link to post
Share on other sites
Advertisement
hello,
i'm thinking of...
1. Make the sprites "collidable" i.e. those that act as barriers have that special property
2. Make a collision map (perhaps similar of what you're doing) but more like a map of 0's and 1's that represent your actual map of tiles, 0's are not collidable objects and 1's are.

cheers.

Share this post


Link to post
Share on other sites
Create a grid system based on the car's position in the world. For example, every 5 units is one grid, then only perform your collision tests on barriers that are 'attached' to grids around the car's grid or within the car's grid, this will mean that the rest of the barriers are ignored as the car is not close to them.

You can then have pretty complex barrier collision if you wanted.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!