fix mypy... error
This commit is contained in:
parent
56a4de653d
commit
c79f1ab345
|
@ -23,7 +23,6 @@ class HoverPlugin(Plugin):
|
||||||
textures = world[TextureManager]
|
textures = world[TextureManager]
|
||||||
mouse_pos = world[Mouse].position
|
mouse_pos = world[Mouse].position
|
||||||
for entity in entities:
|
for entity in entities:
|
||||||
|
|
||||||
# Récupération de la position et de la taille de l'entité
|
# Récupération de la position et de la taille de l'entité
|
||||||
entity_pos: Vec2 = entity[Position]
|
entity_pos: Vec2 = entity[Position]
|
||||||
if Offset in entity:
|
if Offset in entity:
|
||||||
|
@ -65,18 +64,18 @@ class Hover:
|
||||||
Un composant qui marque une entitée comme etant survolée.
|
Un composant qui marque une entitée comme etant survolée.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
class Hoverable:
|
class Hoverable:
|
||||||
"""
|
"""
|
||||||
Un composant qui marque une entitée comme pouvant etre survolée.
|
Un composant qui marque une entitée comme pouvant etre survolée.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(
|
||||||
entry_callback: Callable[[World, Entity], None] = lambda _a,_b : (),
|
self,
|
||||||
update_callback: Callable[[World, Entity], None] = lambda _a,_b : (),
|
entry_callback: Callable[[World, Entity], None] = lambda _a, _b: None,
|
||||||
exit_callback: Callable[[World, Entity], None] = lambda _a,_b : (),
|
update_callback: Callable[[World, Entity], None] = lambda _a, _b: None,
|
||||||
) -> None:
|
exit_callback: Callable[[World, Entity], None] = lambda _a, _b: None,
|
||||||
|
) -> None:
|
||||||
self.update_callback = update_callback
|
self.update_callback = update_callback
|
||||||
self.entry_callback = entry_callback
|
self.entry_callback = entry_callback
|
||||||
self.exit_callback = exit_callback
|
self.exit_callback = exit_callback
|
||||||
|
|
||||||
|
|
27
src/main.py
27
src/main.py
|
@ -5,8 +5,8 @@ Ceci est un exemple de comment l'on peut utiliser le moteur du jeu.
|
||||||
|
|
||||||
from engine import *
|
from engine import *
|
||||||
from engine.math import Vec2
|
from engine.math import Vec2
|
||||||
from engine.plugins.animation import AnimatedSprite, AnimationPlugin
|
from engine.plugins.animation import AnimationPlugin
|
||||||
from engine.plugins.clickable import Clickable, ClickablePlugin
|
from engine.plugins.clickable import ClickablePlugin
|
||||||
from engine.plugins.hover import HoverPlugin, Hoverable
|
from engine.plugins.hover import HoverPlugin, Hoverable
|
||||||
from engine.plugins.render import (
|
from engine.plugins.render import (
|
||||||
Order,
|
Order,
|
||||||
|
@ -16,7 +16,6 @@ from engine.plugins.render import (
|
||||||
)
|
)
|
||||||
from engine.plugins.timing import Delta, TimePlugin
|
from engine.plugins.timing import Delta, TimePlugin
|
||||||
from engine.plugins.pygame import Display, Keyboard, PygamePlugin
|
from engine.plugins.pygame import Display, Keyboard, PygamePlugin
|
||||||
from random import random
|
|
||||||
|
|
||||||
|
|
||||||
# Initialisation
|
# Initialisation
|
||||||
|
@ -38,15 +37,19 @@ def spawn_sprites(world: World) -> None:
|
||||||
|
|
||||||
def new_button(position: Vec2, file_name: str) -> None:
|
def new_button(position: Vec2, file_name: str) -> None:
|
||||||
world.create_entity(
|
world.create_entity(
|
||||||
Position(position),
|
Position(position),
|
||||||
Order(0),
|
Order(0),
|
||||||
Texture( file_name+ ".png"),
|
Texture(file_name + ".png"),
|
||||||
Hoverable(entry_callback= lambda _world, entity: entity.set(
|
Hoverable(
|
||||||
Texture(file_name+ "_hover.png"),
|
entry_callback=lambda _world, entity: entity.set(
|
||||||
|
Texture(file_name + "_hover.png"),
|
||||||
),
|
),
|
||||||
exit_callback= lambda _world, entity: entity.set(
|
exit_callback=lambda _world, entity: entity.set(
|
||||||
Texture( file_name+ ".png"),
|
Texture(file_name + ".png"),
|
||||||
)),)
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
file_name = "button_classique"
|
file_name = "button_classique"
|
||||||
|
@ -54,7 +57,7 @@ def spawn_sprites(world: World) -> None:
|
||||||
file_name = "button_histoire"
|
file_name = "button_histoire"
|
||||||
else:
|
else:
|
||||||
file_name = "button_tricheur"
|
file_name = "button_tricheur"
|
||||||
new_button(Vec2(Display.WIDTH/3*i, 20),file_name)
|
new_button(Vec2(Display.WIDTH / 3 * i, 20), file_name)
|
||||||
|
|
||||||
|
|
||||||
# On ajoutant la tache
|
# On ajoutant la tache
|
||||||
|
|
Loading…
Reference in a new issue