DropManager

Today I reworked the drop system and added a DropManager which will manage the drop spawning.
I made a textfile so that each powerup has a number(their chance) like this:

bigger_pad 1000
smaller_pad 1000
extra_life 200
shield 500

and then I added everything up and that is 1000 + 1000 + 200 + 500 = 2700.
And then I need to calculate a barrier for each drop.

then its like 500 / 2700 = shield barrier
and 1000 / 2700 = bigger_pad and smaller_pad chance.

When I spawn a drop I randomize a float value between 0.0 and 100.0.

I loop the vector which has the barrier property as a member and Im checking if the barrier is higher or equal to the randomized value. if it is,I grab the current key and send it away to createDrop method.

http://pastebin.com/qCSbfteg

About Anthon Fredriksson

2013 Programming