Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
I don't mean like random(50), I random two values. Like 1 and 5. Each tick the value would be 1 or 5. Not in between.
Try this -
random(2) * 4 + 1
Random(2) gives you either 0 or 1.
Granted, this only works for the given example. A fancier method would use the conditional operator as such -
(random(2) = 0 ? numA : numB)
This acts like an if statement. numA is returned if the condition -- random(2) = 0 -- is true, and numB returns if false.
Develop games in your browser. Powerful, performant & highly capable.
Another method not mentioned is using an array expression:
{1, 5} at (random(2)+1)
Some other examples:
{"spring", "summer", "fall", "winter"} at (random(4)+1)
{1, 1, 2, 3, 5, 7, 12} at (random(7)+1)
Thanks for the idea rojo, I should use array expressions more often.
Thanks guys.