Add initial game structure with entity, player, and screen management

This commit is contained in:
2026-06-22 15:37:48 +02:00
parent 8990579e06
commit 04a83c5cc2
6 changed files with 109 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
"""Entité générique comme le joueur ou la balle"""
import pygame
from typing import Tuple
from dataclasses import dataclass
from screen import Screen
@dataclass
class Pos:
x: int
y: int
@dataclass
class Velocity:
x: float
y: float
@dataclass
class Entity:
name: str
pos: Pos
velocity: Velocity
image: pygame.Surface
screen_manager: Screen
screen: pygame.Surface
def __init__(self, name:str, origin:Tuple[int, int], image:pygame.Surface, screen_manager:Screen):
self.name:str = name
self.pos = Pos(*origin)
self.velocity = Velocity(0, 0)
self.image: pygame.Surface = image
self.screen_manager = screen_manager
self.screen: pygame.Surface = screen_manager.get_screen()
def apply_move(self):
self.pos.x += int(self.velocity.x)
self.pos.y += int(self.velocity.y)
def draw(self):...
def move(self, event:pygame.event.Event):...