Jump to content
  • Advertisement
Sign in to follow this  
99g9man

Handling cars emitting in 2d highway game

This topic is 2306 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

Hello,

I'm doing for fun a little game with a 2d top view, where player have to overtake other cars on a highway (those other cars moves slower than the player).

I'm wondering how to handle cars emitting. As far as I know the simplest way to do this is to choose pseudorandomly number of lane and position (how far from the player). But after testing, it appears, that this approach doesn't work - sometimes some lanes are empty, and sometimes all lanes are blocked by cars and player must crash and generaly everything looks quite messy. While problem with cars blocking all the lines can be easily solved - by making cars at different lanes driving with a different speed, I wonder how to make this work nice and smooth. I've read about Perlin Noise, and I think, that this noise could solve this problem, but maybe someone has a better solution?

I hope this post is not too confusingly written.

Thanks for any help! Edited by 99g9man

Share this post


Link to post
Share on other sites
Advertisement
I think it's best to start with the easiest solution. For each lane:
- Generate a pseudo-random number which is the gap to the next car
- Check for interactions with previously generated lanes, e.g. if the chosen gap is likely to make it impossible, increase the gap by 1 car length, repeat

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!