You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.6 KiB

import random
from Entities.entity import Entity
class Marine(Entity):
next_cell = (1,1)
movement = 0
def update(self):
self.move()
super().update()
def select_unit(self):
self.selected = True
# Play a random voice response when selected
sound_file = f"marine/tmawht0{random.randint(0, 4)}.wav"
print(f"Playing sound: {sound_file}")
self.graphics.play_sound(sound_file)
def move(self):
if (self.x, self.y) != self.next_cell:
# Set walking animation and direction
self.action = "walk"
self.direction = self.graphics.get_direction((self.x, self.y), self.next_cell)
self.moving = True
# Calculate target coordinates
target_x, target_y = self.graphics.iso_transform(self.next_cell[0], self.next_cell[1])
# Increment movement counter
self.movement += 0.01
# Calculate how far we've moved (0.0 to 1.0)
move_progress = min(self.movement, 1.0)
# Calculate new position based on progress between cells
self.iso_x = self.iso_x + (target_x - self.iso_x) * move_progress
self.iso_y = self.iso_y + (target_y - self.iso_y) * move_progress
print(f"Moving to {self.iso_x}, {self.iso_y} with progress {move_progress}")
if self.movement >= 1.0:
# Reset movement and set to idle
self.movement = 0
self.iso_x, self.iso_y = self.graphics.iso_transform(self.x, self.y)