48

Functions

This sketch is an example of how to make your own function in Processing.

48.1

In rollDice(20); 20 is the parameter being 'passed' to your function. In this case 20 is the number of sides on the die. What happens if you change 20 to 20.0 or 20.1? Read the error message carefully.

48.2

Why is int d = 1 + int(random(numSides)); used and not

int d = int(random(numSides));?

48.3

Why do the numbers change each time you refresh this page?