i am currently creating this terraria-like game for class, and i want to make the ores generate randomly, or rather, have a random chance of generating. i wanted to achieve this by making a Greenfoot.getRandomNumber() statement inside of a switch case, but it throws an error (required: int; found: int, int)
this is an example switch statement of how i wanted to do this:
i tried making the int = rng outside of the switch statement part, but that resulted in the same error
I cant seem to find a way how to get around this limitation, so if any of you have any idea, please let me know ^^
1 2 3 4 5 6 7 8 9 | switch (a) { case 1 : gras grass = new gras(); int rng = Greenfoot.getRandomNumber( 0 , 10 ); if (rng <= 3 ) { addObject(grass, x, y); } } |