-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobjects.py
90 lines (76 loc) · 3.64 KB
/
objects.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import pygame
import os
import random
class Object(pygame.sprite.Sprite):
def __init__(self, walkable = 0):
pygame.sprite.Sprite.__init__(self)
self.walkable = walkable # flaga wskazująca czy saper jest w stanie przejsć przez dany obiekt
class Grass(Object):
def __init__(self, pos_x, pos_y, width, height):
super().__init__()
self.image = pygame.image.load(os.path.join('images', 'tile.png'))
self.image_scaled = pygame.transform.scale(self.image, (width, height))
self.rect = self.image_scaled.get_rect(center = (pos_x, pos_y))
self.deley = 0
class Mine(Object):
def __init__(self, pos_x, pos_y, width, height):
super().__init__()
self.time = random.randint(1, 10) # czas do auto-detonacji?
self.reach = random.randint(1, 3)
self.defused = False
# saper w wyborze będzie
# brał pod uwagę jaka mina w jego zasięgu wzroku ma najwyższe te dwie wartości?
self.image = pygame.image.load(os.path.join('images', 'mine.png')).convert_alpha()
self.image_scaled = pygame.transform.scale(self.image, (width, height))
self.rect = self.image_scaled.get_rect(center=(pos_x, pos_y))
self.deley = 0
self.itr = self.set_recon_image()
def defuse(self, width, height):
self.defused = True
self.image = pygame.image.load(os.path.join('images', 'mine_defused.png')).convert_alpha()
self.image_scaled = pygame.transform.scale(self.image, (width, height))
def move_away(self, width, height):
self.defused = True
self.image = pygame.image.load(os.path.join('images', 'mine_moved.png')).convert_alpha()
self.image_scaled = pygame.transform.scale(self.image, (width, height))
def its_rock(self, width, height):
self.defused = True
self.image = pygame.image.load(os.path.join('images', 'rock.png')).convert_alpha()
self.image_scaled = pygame.transform.scale(self.image, (width, height))
def set_recon_image(self):
picker = random.randint(1,10)
if picker == 1:
return "./to_recognition/rock1.jpg"
if picker == 2:
return "./to_recognition/rock2.jpg"
if picker == 3:
return "./to_recognition/rock3.jpg"
if picker == 4:
return "./to_recognition/bomb1.jpg"
if picker == 5:
return "./to_recognition/bomb2.jpg"
if picker == 6:
return "./to_recognition/bomb3.jpg"
if picker == 7:
return "./to_recognition/bomb4.jpg"
if picker == 8:
return "./to_recognition/bomb5.jpg"
if picker == 9:
return "./to_recognition/bomb6.jpg"
if picker == 10:
return "./to_recognition/bomb7.jpg"
class Rock(Object):
def __init__(self, pos_x, pos_y,width, height):
super().__init__(1)
self.image = pygame.image.load(os.path.join('images', 'rock.png')).convert_alpha()
self.image_scaled = pygame.transform.scale(self.image, (width, height))
self.rect = self.image_scaled.get_rect(center=(pos_x, pos_y))
self.deley = 1000
class Puddle(Object):
def __init__(self, pos_x, pos_y, width, height):
super().__init__()
self.depth = random.randint(1, 3) # im większa tym bardziej spowalnia sapera?
self.image = pygame.image.load(os.path.join('images', 'puddle.png')).convert_alpha()
self.image_scaled = pygame.transform.scale(self.image, (width, height))
self.rect = self.image_scaled.get_rect(center=(pos_x, pos_y))
self.deley = 4