Random item from a set only once?
Hunnenkoenig
Member Posts: 1,173
For my wallbreaker game i need bricks, which drop random bonuses.
That is not the problem. I managed that.
But now, some bonuses are coming more than once and if the situation is unlucky, they come next to eachother, which is not good for me.
For example I have a bonus, which increases the racket's width for a few seconds, but if it comes two times within this ammount of time, my racket gets too big, what I don't want.
So I need something, where I can control that the same bonus don't comes again in the same level.
I made a game boolean attribute, which will be checked, when the bonus shows up the first time, but then my random generator turns to useless.
Now it looks like this:
game.bonusX = 0
if ball hits brick, self.randombonus = random(1,5)
if self.randombonus = 3, spawn bonus X, change game.bonusX to 1
Now the problem is, I have 5 bonuses and I can't exclude bonusX and reroll for another bonus on the same brick, because the random function is not working anymore without AND or OR operators.
I have to do this with all bonuses of course and I don't want to set the bonuses fix to certain bricks due to replayability and new experience at replay.
I could make crazy long and complex rulesets, which I don't want to, so I need a simple solution.
Any idea?
That is not the problem. I managed that.
But now, some bonuses are coming more than once and if the situation is unlucky, they come next to eachother, which is not good for me.
For example I have a bonus, which increases the racket's width for a few seconds, but if it comes two times within this ammount of time, my racket gets too big, what I don't want.
So I need something, where I can control that the same bonus don't comes again in the same level.
I made a game boolean attribute, which will be checked, when the bonus shows up the first time, but then my random generator turns to useless.
Now it looks like this:
game.bonusX = 0
if ball hits brick, self.randombonus = random(1,5)
if self.randombonus = 3, spawn bonus X, change game.bonusX to 1
Now the problem is, I have 5 bonuses and I can't exclude bonusX and reroll for another bonus on the same brick, because the random function is not working anymore without AND or OR operators.
I have to do this with all bonuses of course and I don't want to set the bonuses fix to certain bricks due to replayability and new experience at replay.
I could make crazy long and complex rulesets, which I don't want to, so I need a simple solution.
Any idea?
Comments
I just found Thshirtboot's tutorial on a similar thing, with the exclusion on random.
http://gamesalad.com/game/play/26735
I will study it, maybe it is helpful.