Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit)

Because the loop can repeat an unknown number of times, you get random times spent to roll the dice.

For 4, you could do 'if $Roll > 4, $Roll = $Roll - 4'

For 6, you can use 24 and subtract 6 from it repeatedly until it's 6 or less (or, if it's >12 you subtract 12, and if >18 subtract 18, I'm not sure which ends up more efficient in the end). For 12 you can use 24 again, but just subtract 12. 

For 10 and 20, 40's your best bet, I suppose.

Assuming generating a number between 1 and 40 doesn't take terribly long, this is basically just using "mod" but by way of subtraction so you don't need to do any division on a GameBoy.

While you're still doing a bit of looping, you're at least guaranteed to never do the loop more than a fixed number of times.

ah that's such a good idea!

I've actually implemented the rolling graphic somewhat for the purpose of time consistency although I was having the opposite problem. it always performs the loop so fast I had to add the "rolling..." to obscure the result because if you got the same number again there was no way to tell if you had even rolled! 


I imagine this may be because the numbers are so small its unlikely to loop for too long and the Gameboys an actual beast of a machine! So the time differential from start to finish is currently not really perceivable but the potential is certainly there.

Honestly, really smart thinking that I'm eager to implement!