Redesigned project architecture to be a little bit more modular #12

Merged
s473555 merged 10 commits from sandbox into main 2023-03-30 18:29:26 +02:00
Showing only changes of commit 047ef87bab - Show all commits

18
main.py
View File

@ -2,7 +2,6 @@ from random import randint
import pygame
from Interface.vacuum_render import initial_draw
from domain.commands.random_cat_move_command import RandomCatMoveCommand
from domain.commands.vacuum_move_command import VacuumMoveCommand
from domain.entities.cat import Cat
@ -14,6 +13,7 @@ from view.renderer import Renderer
# initial_draw(500, 10)
class Main:
def __init__(self):
tiles_x = 10
@ -44,13 +44,21 @@ class Main:
self.running = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
self.commands.append(VacuumMoveCommand(self.world, self.world.vacuum, (-1, 0)))
self.commands.append(
VacuumMoveCommand(self.world, self.world.vacuum, (-1, 0))
)
if event.key == pygame.K_RIGHT:
self.commands.append(VacuumMoveCommand(self.world, self.world.vacuum, (1, 0)))
self.commands.append(
VacuumMoveCommand(self.world, self.world.vacuum, (1, 0))
)
if event.key == pygame.K_UP:
self.commands.append(VacuumMoveCommand(self.world, self.world.vacuum, (0, -1)))
self.commands.append(
VacuumMoveCommand(self.world, self.world.vacuum, (0, -1))
)
if event.key == pygame.K_DOWN:
self.commands.append(VacuumMoveCommand(self.world, self.world.vacuum, (0, 1)))
self.commands.append(
VacuumMoveCommand(self.world, self.world.vacuum, (0, 1))
)
def update(self):
self.commands.append(RandomCatMoveCommand(self.world, self.world.cat))