Add explosion stage 1 PNG assets for all directions
- Added BMP_1_EXPLOSION_DOWN.png to original and preview directories. - Added BMP_1_EXPLOSION_LEFT.png to original and preview directories. - Added BMP_1_EXPLOSION_RIGHT.png to original and preview directories. - Added BMP_1_EXPLOSION_UP.png to original and preview directories. These assets are part of the explosion animation for the game, enhancing visual effects during gameplay.
This commit is contained in:
@@ -43,6 +43,9 @@ class Bomb(Unit):
|
||||
|
||||
x_pos = self.position_before[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2 + partial_x
|
||||
y_pos = self.position_before[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2 + partial_y
|
||||
|
||||
if self.is_hidden_in_tunnel(image_size):
|
||||
return
|
||||
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
|
||||
@@ -131,6 +134,9 @@ class Explosion(Bomb):
|
||||
|
||||
x_pos = self.position_before[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2 + partial_x
|
||||
y_pos = self.position_before[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2 + partial_y
|
||||
|
||||
if self.is_hidden_in_tunnel(image_size):
|
||||
return
|
||||
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
|
||||
@@ -186,4 +192,7 @@ class NuclearBomb(Unit):
|
||||
x_pos = self.position[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2
|
||||
y_pos = self.position[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2
|
||||
|
||||
if self.is_hidden_in_tunnel(image_size, position=self.position):
|
||||
return
|
||||
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
+4
-2
@@ -79,8 +79,10 @@ class Gas(Unit):
|
||||
|
||||
x_pos = self.position_before[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2 + partial_x
|
||||
y_pos = self.position_before[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2 + partial_y
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
if not self.is_hidden_in_tunnel(image_size):
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
for cell in self.spreading_cells:
|
||||
x_pos = cell[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2 + partial_x
|
||||
y_pos = cell[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2 + partial_y
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
if not self.is_hidden_in_tunnel(image_size, position=cell):
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
|
||||
@@ -55,6 +55,9 @@ class Mine(Unit):
|
||||
# Center the mine in the cell
|
||||
x_pos = self.position[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2
|
||||
y_pos = self.position[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2
|
||||
|
||||
if self.is_hidden_in_tunnel(image_size, position=self.position):
|
||||
return
|
||||
|
||||
self.game.render_engine.draw_image(x_pos, y_pos, image, anchor="nw", tag="unit")
|
||||
|
||||
|
||||
@@ -67,6 +67,22 @@ class Unit(ABC):
|
||||
"""Handle collisions with other units. Default implementation does nothing."""
|
||||
pass
|
||||
|
||||
def is_hidden_in_tunnel(self, image_size, position=None):
|
||||
"""Return True when the sprite center falls inside a tunnel cell."""
|
||||
if position is None:
|
||||
position = self.position_before
|
||||
|
||||
x_pos = position[0] * self.game.cell_size + (self.game.cell_size - image_size[0]) // 2
|
||||
y_pos = position[1] * self.game.cell_size + (self.game.cell_size - image_size[1]) // 2
|
||||
center_x = int(x_pos + image_size[0] / 2)
|
||||
center_y = int(y_pos + image_size[1] / 2)
|
||||
cell_x = center_x // self.game.cell_size
|
||||
cell_y = center_y // self.game.cell_size
|
||||
|
||||
if not self.game.map.in_bounds(cell_x, cell_y):
|
||||
return False
|
||||
return self.game.map.is_tunnel(cell_x, cell_y)
|
||||
|
||||
def die(self, score=None):
|
||||
"""Remove unit from game and handle basic cleanup."""
|
||||
if self.id in self.game.units:
|
||||
|
||||
Reference in New Issue
Block a user