Assigning values to variables

The value of a variable can be assigned to another variable after it has been declared, as shown in this example.

defaultPlayerLives as integer = 10
playerLives as integer = 0
playerScore as integer = 0

playerLives = defaultPlayerLives
do print ( defaultPlayerLives ) print ( playerLives ) print ( playerScore )
sync ( ) loop

The first three lines declare and assign default values to the variables. The next line takes the value of defaultPlayerLives and assigns it to the variable playerLives.

playerLives = defaultPlayerLives

Which means at this point playerLives has been assigned a value of 10. When you run the program you will see 10, 10 and 0 displayed on screen.

image-1