it is now possible to see the opponent move on our board
This commit is contained in:
parent
9c8e0f87ce
commit
db21bf5e04
6 changed files with 16 additions and 2 deletions
1
NOTE.md
1
NOTE.md
|
@ -10,7 +10,6 @@ A faire :
|
||||||
|
|
||||||
- Ecran de victoire
|
- Ecran de victoire
|
||||||
- Affichage des coups de l'opposant
|
- Affichage des coups de l'opposant
|
||||||
- Faire marcher le score
|
|
||||||
- Faire marcher le tchat
|
- Faire marcher le tchat
|
||||||
- Sauvegarde / Quitter
|
- Sauvegarde / Quitter
|
||||||
|
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 892 B |
|
@ -46,12 +46,14 @@ class Game(Scene):
|
||||||
|
|
||||||
grid_style=texture.Grid.Style1,
|
grid_style=texture.Grid.Style1,
|
||||||
boat_style=texture.Grid.Boat.Style1,
|
boat_style=texture.Grid.Boat.Style1,
|
||||||
|
bomb_style=texture.Grid.Bomb.Style1,
|
||||||
rows=8, columns=8,
|
rows=8, columns=8,
|
||||||
|
|
||||||
background_batch=self.batch_grid_background,
|
background_batch=self.batch_grid_background,
|
||||||
line_batch=self.batch_grid_line,
|
line_batch=self.batch_grid_line,
|
||||||
cursor_batch=self.batch_grid_cursor,
|
cursor_batch=self.batch_grid_cursor,
|
||||||
boat_batch=self.batch_grid_boat,
|
boat_batch=self.batch_grid_boat,
|
||||||
|
bomb_batch=self.batch_grid_bomb
|
||||||
)
|
)
|
||||||
|
|
||||||
def board_ally_ready():
|
def board_ally_ready():
|
||||||
|
|
|
@ -14,7 +14,6 @@ class Grid:
|
||||||
class Style1(Style):
|
class Style1(Style):
|
||||||
body = path_boat / "body.png"
|
body = path_boat / "body.png"
|
||||||
edge = path_boat / "edge.png"
|
edge = path_boat / "edge.png"
|
||||||
broken = path_boat / "broken.png"
|
|
||||||
solo = path_boat / "solo.png"
|
solo = path_boat / "solo.png"
|
||||||
|
|
||||||
class Bomb:
|
class Bomb:
|
||||||
|
|
|
@ -29,6 +29,7 @@ class GameGridAlly(GameGrid):
|
||||||
|
|
||||||
grid_style: Type[Style],
|
grid_style: Type[Style],
|
||||||
boat_style: Type[Style],
|
boat_style: Type[Style],
|
||||||
|
bomb_style: Type[Style],
|
||||||
|
|
||||||
boats_length: list[int],
|
boats_length: list[int],
|
||||||
preview_color: ColorRGB = (150, 255, 150),
|
preview_color: ColorRGB = (150, 255, 150),
|
||||||
|
@ -45,7 +46,9 @@ class GameGridAlly(GameGrid):
|
||||||
self.orientation: Orientation = Orientation.HORIZONTAL
|
self.orientation: Orientation = Orientation.HORIZONTAL
|
||||||
|
|
||||||
self._boat_kwargs = dict_filter_prefix("boat_", kwargs)
|
self._boat_kwargs = dict_filter_prefix("boat_", kwargs)
|
||||||
|
self._bomb_kwargs = dict_filter_prefix("bomb_", kwargs)
|
||||||
self.boat_style = boat_style
|
self.boat_style = boat_style
|
||||||
|
self.bomb_style = bomb_style
|
||||||
|
|
||||||
self.add_listener("on_click_release", self.on_click_release)
|
self.add_listener("on_click_release", self.on_click_release)
|
||||||
self.add_listener("on_hover", lambda rel_x, rel_y: self.preview_boat(self.get_cell_from_rel(rel_x, rel_y)))
|
self.add_listener("on_hover", lambda rel_x, rel_y: self.preview_boat(self.get_cell_from_rel(rel_x, rel_y)))
|
||||||
|
@ -147,6 +150,15 @@ class GameGridAlly(GameGrid):
|
||||||
except InvalidBoatPosition: self.display_board(self.board) # if the boat can't be placed, ignore
|
except InvalidBoatPosition: self.display_board(self.board) # if the boat can't be placed, ignore
|
||||||
else: self.display_board(preview_board, preview=True)
|
else: self.display_board(preview_board, preview=True)
|
||||||
|
|
||||||
|
def place_bomb(self, cell: Point2D, touched: bool):
|
||||||
|
|
||||||
|
self.cell_sprites[cell] = Sprite(
|
||||||
|
img=self.bomb_style.get("touched" if touched else "missed"),
|
||||||
|
**self._bomb_kwargs
|
||||||
|
)
|
||||||
|
|
||||||
|
self._refresh_size()
|
||||||
|
|
||||||
def on_click_release(self, rel_x: int, rel_y: int, button: int, modifiers: int):
|
def on_click_release(self, rel_x: int, rel_y: int, button: int, modifiers: int):
|
||||||
cell = self.get_cell_from_rel(rel_x, rel_y)
|
cell = self.get_cell_from_rel(rel_x, rel_y)
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,8 @@ def game_network(thread: "StoppableThread", window: "Window", connection: socket
|
||||||
|
|
||||||
touched = bomb_state in [BombState.TOUCHED, BombState.SUNKEN, BombState.WON]
|
touched = bomb_state in [BombState.TOUCHED, BombState.SUNKEN, BombState.WON]
|
||||||
|
|
||||||
|
in_pyglet_context(game_scene.grid_ally.place_bomb, data.position, touched)
|
||||||
|
|
||||||
if touched:
|
if touched:
|
||||||
in_pyglet_context(game_scene.boat_broken_enemy)
|
in_pyglet_context(game_scene.boat_broken_enemy)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue