починил все баги

начал доставать всё из базы
сделал новую игру
This commit is contained in:
2023-01-26 17:01:39 +07:00
parent d86f87f64f
commit a877b80606
6 changed files with 257 additions and 29 deletions
+10 -6
View File
@@ -1,5 +1,5 @@
import pygame as pg
from modules import Book, GameOver, Mathematics
from modules import Book, GameOver, Mathematics, DB
from modules.RewardWindow import RewardWindow
@@ -50,7 +50,8 @@ class Swamp:
(self.x, self.y, self.cell_size, self.cell_size), 1)
font = pg.font.Font(None, 50)
text_string = "Ваш баланс мух составляет: 1000"
db = DB.UseDB("game")
text_string = f"Ваш баланс мух составляет: {db.find_document({})[0]['money']}"
text = font.render(text_string, True, (255, 255, 255))
size = font.size(text_string)
screen.blit(text, (350 - (size[0] / 2.), 50))
@@ -87,12 +88,15 @@ class Swamp:
def get_cell(self, mouse_pos):
board_width = self.width * self.cell_size
board_height = self.height * self.cell_size
if self.left_area < mouse_pos[0] < self.left_area + board_width:
if self.top_area < mouse_pos[1] < self.top_area + board_height:
if self.left_area <= mouse_pos[0] <= self.left_area + board_width:
if self.top_area <= mouse_pos[1] <= self.top_area + board_height:
cell_coords = (mouse_pos[0] - self.top_area) // self.cell_size + 1, \
(mouse_pos[1] - self.left_area) // self.cell_size - 1
self.cell_info = self.board[cell_coords[1]][cell_coords[0]]
self.time_to_close = 100
try:
self.cell_info = self.board[cell_coords[1]][cell_coords[0]]
except IndexError:
self.cell_info = self.board[-1][cell_coords[0]]
self.time_to_close = 10
return cell_coords
elif self.left_book < mouse_pos[0] < self.right_book:
if self.top_book < mouse_pos[1] < self.down_book and self.book_use is False: