lives update

master
IljaP 2024-04-26 08:59:21 +03:00
parent 36ec1fd077
commit eb504bc7f1
4 changed files with 32 additions and 15 deletions

View File

@ -20,6 +20,7 @@ class Domino(pygame.sprite.Sprite):
self.surf.fill(self.color)
self.rect = self.surf.get_rect(center=(x, y))
self.index = index
self.lives = 3
self.type_pos = "hand"
@ -27,6 +28,8 @@ class Domino(pygame.sprite.Sprite):
self.values = values
self.damage = True
def blit_domino(self, screen, dominos):
movement = self.w + 10
@ -121,6 +124,9 @@ class Domino(pygame.sprite.Sprite):
elif empty.pos == "both":
move = True
# ставим домино на место пустышки, и добавляем в группу объектов игрового стола
if move:
self.surf.fill(self.color)
@ -154,6 +160,11 @@ class Domino(pygame.sprite.Sprite):
empty.kill()
else:
if self.damage:
game.lives -= 1
self.damage = False
# если домино не за пределами руки - возвращаем её на место

View File

@ -158,6 +158,10 @@ while run:
if len(dominos) <= 0 and len(s.DOMINOS) <= 0:
win = True
break
elif game_screen.lives <= 0:
break
print(game_screen.lives)
pygame.display.flip()

View File

@ -108,6 +108,8 @@ class Game_screen(pygame.sprite.Sprite):
self.empty_up = empty_both
self.empty_down = empty_both
self.lives = 3
def blit_g_screen(self, screen, dominos):
# add_empty()

View File

@ -8,14 +8,14 @@ DOMINO_H = 200
DOMINOS = []
# values = range(7)
# for v_up in values:
# for v_down in values:
# if not [v_up, v_down] in DOMINOS and not [v_down, v_up] in DOMINOS:
# DOMINOS.append([v_up, v_down])
values = range(7)
for v_up in values:
for v_down in values:
if not [v_up, v_down] in DOMINOS and not [v_down, v_up] in DOMINOS:
DOMINOS.append([v_up, v_down])
for _ in range(10):
DOMINOS.append([[1, '1'], [1, '1']])
# for _ in range(10):
# DOMINOS.append([[1, '1'], [1, '1']])
# print(DOMINOS)
@ -29,14 +29,14 @@ str_values = {
5: ["10/2", "25^0.5", "2*5/2", "4!-19", "True*10/2", "3+2", "100/20", "4*1.25", "int(5.839)", "5+5-5+5-5", "2.5*2"],
6: ["3!", "2+2*2", "round(pi)*2", "(if 6>1)*6", "10-4", "24/4", "sqrt(12*3)", "3^2-3", "2*(4-1)", "{1,3,6}[2]"]
}
#
# for i in range(len(DOMINOS)):
# v_up = choice(str_values[DOMINOS[i][0]])
# str_values[DOMINOS[i][0]].remove(v_up)
# v_down = choice(str_values[DOMINOS[i][1]])
# str_values[DOMINOS[i][1]].remove(v_down)
#
# DOMINOS[i] = [[DOMINOS[i][0], v_up], [DOMINOS[i][1], v_down]]
for i in range(len(DOMINOS)):
v_up = choice(str_values[DOMINOS[i][0]])
str_values[DOMINOS[i][0]].remove(v_up)
v_down = choice(str_values[DOMINOS[i][1]])
str_values[DOMINOS[i][1]].remove(v_down)
DOMINOS[i] = [[DOMINOS[i][0], v_up], [DOMINOS[i][1], v_down]]
# print(DOMINOS)