tags:

views:

44

answers:

1

Hi all,

I've got a problem: i need to add a powerup to a racegame, using collision detection. so i drawed the powerup, but the problem is: It has to be drawn after every 5 rounds and it needs to be placed ramdomly on the track.

Someone with any good advice?

Thanks.

+1  A: 

Thats a bit vague. So here is my best shot at an answer.

You would want to use the c# Random class, here are the docs

For a simple game, using rectangular collision should be all you need (I assume thats what you are using) - If you want to randomly generate the power-up position, you will want to create a new Vector2 (the powerups position) with the random generator.

You can use the Next function, to pass in a low, and high variable - which you would need to configure the the bounds you wish the powerup to appear.

My advice as a game designer on the other hand, tells me that randomly located power-ups aren't always the go. It makes it harder to control the games flow and balance, and can very easily result in a flawed final product.

So my advice is a hard coded set of possible weapon spawn points - using a random generator to pick one to place.

Tim
Bounding-circle collision detection would be even easier than rectangular.
Andrew Russell