-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbutton.py
36 lines (27 loc) · 888 Bytes
/
button.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
import pygame
from door import Door
class Button(pygame.sprite.Sprite):
def __init__(self, pos, id):
super().__init__()
self.image = pygame.Surface((32,32))
self.image.fill((255,0,0))
self.rect = self.image.get_rect(topleft=pos)
self.id = id
self.is_active_now = False
self.is_active_prev = False
def activate(self, door:Door):
self.is_active_now = True
if self.is_active_now == self.is_active_prev:
pass
else:
self.is_active_prev = True
self.image.fill((0, 255, 0))
door.open()
def deactivate(self, door: Door):
self.is_active_now = False
if self.is_active_now == self.is_active_prev:
pass
else:
self.is_active_prev = False
self.image.fill((255, 0, 0))
door.close()