45 lines
2.1 KiB
Python
Executable File
45 lines
2.1 KiB
Python
Executable File
from pacmap import *
|
|
from pacman import *
|
|
|
|
class PhysicMotor:
|
|
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
|
|
print(self.pacman.position)
|
|
# pac_x, pac_y = self.pacman.matrix_position()
|
|
next_pac_tile = self.pacman.next_matrix_position()
|
|
pac_res = self.pacman.resolution
|
|
# print(pac_x, pac_y, self.pacmap.get_tile(pac_x, pac_y))
|
|
# print("next:", self.pacmap.get_tile(pac_x + self.pacman.direction[0], pac_y + self.pacman.direction[1]))
|
|
|
|
# if self.pacman.direction in (direction.up, direction.down):
|
|
# if self.pacman.position[1] % pac_res == pac_res / 2:
|
|
# if 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()
|
|
# else:
|
|
# if self.pacman.position[0] % pac_res == pac_res / 2:
|
|
# if 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()
|
|
|
|
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() |