Python Reference:  Blender 3D Game Engine




 

Numbers

Integer
 

An integer is a whole number.   1, 2, 3 and 4012 are integers.

Note: 
No fractions.  1 / 2 = 0 

Declaring a variable as an integer 

# 3 is an integer.  x is automatically declared an integer
x = 3

Forcing python to change a float number to an integer number

# 3.6 is a float.  x is automatically declared a float
x = 3.6

# x is forced to be an integer number.  x = 3
x = int(x)

-----   or  -----

# 3.6 is forced to be an integer number.  x = 3
x = int(3.6)

Float
 
A float is a number that can have fractions.  0.2, 3.14 and 100.25 are floats.

Declaring a variable as a float number

# 3.6 is a float.  x is automatically declared as a float
x = 3.6

Forcing python to change an integer number to a float number

# 3 is an integer.  x is automatically declared an integer
x = 3

# x is forced to be a float number.  x = 3.0
x = float(x)

-----   or  -----

# 3 is forced to be a float number.  x = 3.0
x = float(3)
   





The Blender 3D and Blender 3D game engine tutorials were created as a series of step by step instructions to help you create computer games. Casual video games, First Person Shooter, role playing games, racing simulations and more. Use the Blender 3D tutorials to model and program your own three-dimensional world and then play on your computer.