-
Notifications
You must be signed in to change notification settings - Fork 0
/
Map.py
53 lines (41 loc) · 1.4 KB
/
Map.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from Cube import Cube
from FallingCube import FallingCube
from Pyramid import Pyramid
from FallingPyramid import FallingPyramid
from Floor import Floor
from Slope import Slope
from Stairs import Stairs
'''
Class that hold all the map data, built from other models
'''
class Map:
def __init__(self):
self.objects = []
self.faces = []
self.colors = []
for i in range(-5, 6):
for j in range(-5, 5):
self.objects.append(Floor(i, 0, j, 1, 'black'))
self.objects.append(Cube(-3, 0, 0, 1, 'pink'))
self.objects.append(Slope(-1, 0, 0, 1, 'purple'))
self.objects.append(Stairs(1, 0, 0, 1, 'green'))
self.objects.append(FallingPyramid(3, 20, 0, 1, 'red'))
def render(self):
# Need to be disabled if using falling objects
# if len(self.faces) > 0:
# return (self.faces, self.colors)
faces = []
colors = []
for obj in self.objects:
(f, c) = obj.render()
faces += f
colors += c
# little hack to remove duplicate faces (~20% performance improvement), incompatible with colors
# faces = [tuple(face) for face in faces]
# faces = list(set(faces))
# faces = [list(face) for face in faces]
self.faces = faces
self.colors = colors
return (faces, colors)