Aggiornamenti al codice: modifiche ai file Python, aggiunta di file audio e miglioramenti alla GUI.
This commit is contained in:
Binary file not shown.
+13
-2
@@ -39,12 +39,23 @@ class Knight:
|
||||
screen_y += (screen_y_dest - screen_y) * self.partial_move
|
||||
else:
|
||||
screen_x, screen_y = self.engine.iso_transform(*self.destination)
|
||||
self.visited = self.visited[-4:]
|
||||
neighbors_list = self.engine.find_neighbors(self.destination) # Get the neighbors of the destination cell
|
||||
neighbors_list = [cell for cell in neighbors_list if cell not in self.visited]
|
||||
|
||||
# Remove any neighbors that are not walkable
|
||||
self.best_next = self.engine.get_closest_neighbor(neighbors_list,self.target)
|
||||
#if best next is not walkable, find the closest walkable cell to best next
|
||||
neighbors_list = [cell for cell in neighbors_list if self.engine.battlefield[cell[1]][cell[0]].walkable]
|
||||
if self.engine.battlefield[self.best_next[1]][self.best_next[0]].walkable == False:
|
||||
self.best_next = self.engine.get_closest_neighbor(neighbors_list,self.best_next)
|
||||
if not self.best_next:
|
||||
self.target = self.destination
|
||||
self.best_next = self.destination
|
||||
self.position = self.destination
|
||||
self.destination = self.engine.get_closest_neighbor(neighbors_list,self.target)
|
||||
self.destination = self.best_next
|
||||
self.partial_move = 0
|
||||
self.visited.append(self.destination)
|
||||
print(self.partial_move)
|
||||
|
||||
|
||||
@@ -57,6 +68,6 @@ class Knight:
|
||||
self.state = "Walk"
|
||||
|
||||
def run_to(self, target):
|
||||
self.speed = .15
|
||||
self.speed = .13
|
||||
self.target = target
|
||||
self.state = "Run"
|
||||
Reference in New Issue
Block a user