46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
"""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
|
|
max: float = 50
|
|
|
|
@dataclass
|
|
class Friction: # les forces de frottement
|
|
x: float
|
|
y: float
|
|
|
|
@dataclass
|
|
class Entity:
|
|
name: str
|
|
pos: Pos
|
|
velocity: Velocity
|
|
friction: Friction
|
|
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.friction = Friction(0, 0) # Par defaut on est dans le vide
|
|
|
|
self.image: pygame.Surface = image
|
|
self.screen_manager = screen_manager
|
|
self.screen: pygame.Surface = screen_manager.get_screen()
|
|
|
|
def draw(self):...
|
|
def move(self, deltatime: float):...
|
|
def apply_friction(self, deltatime: float):... |