This repository has been archived on 2019-12-09. You can view files and clone it, but cannot push or open issues or pull requests.
pacman/livrables/1/physic_engine.py

21 lines
823 B
Python
Executable File

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()