message back if did_attack
This commit is contained in:
parent
3ce5e1a02b
commit
557bac2dcf
1 changed files with 18 additions and 9 deletions
27
creeper.py
27
creeper.py
|
|
@ -230,11 +230,15 @@ class DebugMenu(Menu):
|
||||||
|
|
||||||
def _draw(self):
|
def _draw(self):
|
||||||
self.surf.blit(
|
self.surf.blit(
|
||||||
self.font.render(f"x: {self.game.x}", True, (255, 255, 255)),
|
self.font.render(
|
||||||
(10, 30),
|
f"(x, y): ({self.game.x}, {self.game.y})", True, (255, 255, 255)
|
||||||
|
),
|
||||||
|
(10, 35),
|
||||||
)
|
)
|
||||||
self.surf.blit(
|
self.surf.blit(
|
||||||
self.font.render(f"y: {self.game.y}", True, (255, 255, 255)),
|
self.font.render(
|
||||||
|
f"mouse_pos: {pygame.mouse.get_pos()}", True, (255, 255, 255)
|
||||||
|
),
|
||||||
(10, 50),
|
(10, 50),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -357,13 +361,14 @@ class Creeper(Game):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
self.joysticks = {}
|
self.joysticks = {}
|
||||||
self.hotbar_back_debounce = 0
|
self.hotbar_back_debounce = 1
|
||||||
self.hotbar_forward_debounce = 0
|
self.hotbar_forward_debounce = 1
|
||||||
self.inventory_open_debounce = 0
|
self.inventory_open_debounce = 1
|
||||||
self.debug_open_debounce = 0
|
self.debug_open_debounce = 1
|
||||||
self.main_open_debounce = 0
|
self.main_open_debounce = 1
|
||||||
self.inventory_menu = Menu(self, title="inventory")
|
self.inventory_menu = Menu(self, title="inventory")
|
||||||
self.debug_menu = DebugMenu(self)
|
self.debug_menu = DebugMenu(self)
|
||||||
|
self.debug_menu.is_open = True
|
||||||
self.main_menu = Menu(self, title="main menu")
|
self.main_menu = Menu(self, title="main menu")
|
||||||
|
|
||||||
def attack(self):
|
def attack(self):
|
||||||
|
|
@ -371,11 +376,14 @@ class Creeper(Game):
|
||||||
collisions = self.mouse_box.rect.collidedictall(
|
collisions = self.mouse_box.rect.collidedictall(
|
||||||
{tree: tree.rect for tree in self.trees}
|
{tree: tree.rect for tree in self.trees}
|
||||||
)
|
)
|
||||||
|
if not collisions:
|
||||||
|
return False
|
||||||
for collision in collisions:
|
for collision in collisions:
|
||||||
tree = collision[0]
|
tree = collision[0]
|
||||||
tree.health -= 10
|
tree.health -= 10
|
||||||
tree.hit = True
|
tree.hit = True
|
||||||
tree.shake()
|
tree.shake()
|
||||||
|
return True
|
||||||
|
|
||||||
def process_deaths(self):
|
def process_deaths(self):
|
||||||
for i, tree in enumerate(copy(self.trees)):
|
for i, tree in enumerate(copy(self.trees)):
|
||||||
|
|
@ -403,7 +411,8 @@ class Creeper(Game):
|
||||||
if event.type == pygame.MOUSEWHEEL:
|
if event.type == pygame.MOUSEWHEEL:
|
||||||
self.hotbar.next(event.y)
|
self.hotbar.next(event.y)
|
||||||
if event.type == pygame.MOUSEBUTTONDOWN:
|
if event.type == pygame.MOUSEBUTTONDOWN:
|
||||||
self.attack()
|
if pygame.mouse.get_pressed()[0]:
|
||||||
|
did_attack = self.attack()
|
||||||
|
|
||||||
if event.type == pygame.JOYDEVICEADDED:
|
if event.type == pygame.JOYDEVICEADDED:
|
||||||
# This event will be generated when the program starts for every
|
# This event will be generated when the program starts for every
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue