# Material – colored labyrinth¶

## Objectives¶

 So far, our objects are unique grey. Now lets make the new world a little bit colorful. Therefor we are using materials and/or textures.

## Instructions¶

1. Construct your own new level as shown in the last station.

## Create a new material¶

Materials in Blender are distinguished by name and exists independent from objects. Therefor it is possible to put one material to different objects.

MATERIAL_RED = bpy.data.materials.new('Red Material')


## Save object¶

The new object is allocated to a variable named »obj«.

    for row in range(rows):
for i in range(cols):
if level[row][i] == '#':
obj = bpy.context.object
setColor(obj, MATERIAL_RED, (1, 0, 0))


## Function: setColor¶

The function setColor needs tree parameters: object, material and color.

                setColor(obj, MATERIAL_RED, (1, 0, 0))


## Allocate material¶

Within setColor the parameters are used to change the given object.

def setColor(obj, material, color):
material.diffuse_color = color
material.specular_hardness = 200
obj.data.materials.append(material)