21 lines
823 B
Python
21 lines
823 B
Python
|
from pacmap import *
|
||
|
from pacman import *
|
||
|
|
||
|
class PhysicEngine:
|
||
|
def __init__(self, c_pacmap: Map, c_pacman: Pacman):
|
||
|
self.pacmap = c_pacmap
|
||
|
self.pacman = c_pacman
|
||
|
self.entities = [] # ghosts
|
||
|
|
||
|
def move_all(self):
|
||
|
# pacman movement
|
||
|
next_pac_tile = self.pacman.next_matrix_position()
|
||
|
pac_res = self.pacman.resolution
|
||
|
if self.pacman.is_at_center_tile():
|
||
|
if self.pacman.next_direction != direction.none and self.pacmap.get_tile(*self.pacman.get_next_dir_tile()) in (PhysTile.GRD, PhysTile.TPT):
|
||
|
self.pacman.change_to_next_dir()
|
||
|
self.pacman.move()
|
||
|
elif self.pacmap.get_tile(*next_pac_tile) in (PhysTile.GRD, PhysTile.TPT):
|
||
|
self.pacman.move()
|
||
|
else:
|
||
|
self.pacman.move()
|