-
Notifications
You must be signed in to change notification settings - Fork 0
/
gate.py
29 lines (22 loc) · 1.17 KB
/
gate.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
from color import mix_colors
import pygame
import os
animation_scale = 3
def load_gate( color, position, phase ):
return pygame.image.load(os.path.join("Art","Gates","gate_" + str(color) + "_" + str(position) + str(phase) + ".png"))
models_left = [[load_gate(color, "L", phase) for phase in range(1,4)] for color in range(0,12,2) ]
models_right = [[load_gate(color, "R", phase) for phase in range(1,4)] for color in range(0,12,2) ]
models_up = [[pygame.transform.rotate( load_gate(color, "L", phase), -90 ) for phase in range(1,4)] for color in range(0,12,2) ]
models_down = [[pygame.transform.rotate( load_gate(color, "R", phase), -90 ) for phase in range(1,4)] for color in range(0,12,2) ]
models = [models_left, models_up, models_right, models_down]
class Gate( object ):
def __init__( self, position, color, orientation ):
self.position = position
self.color = color
self.phase = 0
self.model = models[orientation][color / 2]
def check_color( self, color ):
return mix_colors( self.color, color ) == color
def draw( self, screen ):
screen.blit( self.model[self.phase/animation_scale], self.position )
self.phase = (self.phase + 1) % (3*animation_scale)