Classique #35
BIN
assets/krita/search_bar.kra
Normal file
BIN
assets/krita/search_bar.kra
Normal file
Binary file not shown.
BIN
assets/krita/valider.kra
Normal file
BIN
assets/krita/valider.kra
Normal file
Binary file not shown.
BIN
assets/textures/classique/search_bar.png
Normal file
BIN
assets/textures/classique/search_bar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7 KiB |
BIN
assets/textures/classique/valider.png
Normal file
BIN
assets/textures/classique/valider.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
assets/textures/classique/valider_hover.png
Normal file
BIN
assets/textures/classique/valider_hover.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
|
@ -4,12 +4,13 @@ Example de l'utilisation du moteur de jeu.
|
||||||
|
|
||||||
|
|
||||||
from engine import start_game
|
from engine import start_game
|
||||||
from scenes import menu
|
from scenes import classique, menu
|
||||||
|
|
||||||
|
|
||||||
start_game(
|
start_game(
|
||||||
{
|
{
|
||||||
"menu": menu.SCENE,
|
"menu": menu.SCENE,
|
||||||
|
"classique": classique.SCENE
|
||||||
},
|
},
|
||||||
"menu",
|
"menu",
|
||||||
title="Guess The Number",
|
title="Guess The Number",
|
||||||
|
|
29
src/plugins/typing.py
Normal file
29
src/plugins/typing.py
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
"""
|
||||||
|
Definit un plugin qui crée un texte avec les touches frappées
|
||||||
|
"""
|
||||||
|
|
||||||
|
from engine import Keyboard, Scene, Text, World
|
||||||
|
|
||||||
|
|
||||||
|
class Typing:
|
||||||
|
"""
|
||||||
|
Marque une entité comme un texte qui s'ecrit en fonction du clavier
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def __update(world: World):
|
||||||
|
"""
|
||||||
|
Met a jour les entitées contenant le composant Typing
|
||||||
|
"""
|
||||||
|
keyboard = world[Keyboard]
|
||||||
|
for entity in world.query(Typing, Text):
|
||||||
|
text = entity[Text]
|
||||||
|
pressed = keyboard.pressed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PLUGIN = Scene(
|
||||||
|
[],
|
||||||
|
[__update],
|
||||||
|
[],
|
||||||
|
)
|
|
@ -0,0 +1,51 @@
|
||||||
|
"""
|
||||||
|
Définis la scène du jeu classique, sans variante.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from plugins import typing
|
||||||
|
from engine import (
|
||||||
|
Centered,
|
||||||
|
HoveredTexture,
|
||||||
|
Order,
|
||||||
|
Position,
|
||||||
|
Scene,
|
||||||
|
Text,
|
||||||
|
TextSize,
|
||||||
|
Texture,
|
||||||
|
World,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def __initialize_world(world: World):
|
||||||
|
"""
|
||||||
|
Initialise le monde du menu.
|
||||||
|
"""
|
||||||
|
world.create_entity(
|
||||||
|
Position(1215, 964),
|
||||||
|
Order(1),
|
||||||
|
Centered(),
|
||||||
|
Texture("classique/valider.png"),
|
||||||
|
HoveredTexture("classique/valider_hover.png"),
|
||||||
|
)
|
||||||
|
world.create_entity(
|
||||||
|
Position(519, 964),
|
||||||
|
Order(1),
|
||||||
|
Centered(),
|
||||||
|
Texture("classique/search_bar.png"),
|
||||||
|
)
|
||||||
|
world.create_entity(
|
||||||
|
Position(50, 750),
|
||||||
|
Order(2),
|
||||||
|
Text("Salut"),
|
||||||
|
TextSize(150),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
SCENE = (
|
||||||
|
Scene(
|
||||||
|
[__initialize_world],
|
||||||
|
[],
|
||||||
|
[],
|
||||||
|
)
|
||||||
|
+ typing.PLUGIN
|
||||||
|
)
|
Loading…
Reference in a new issue