Save unfinished work
This commit is contained in:
parent
ea70c297b2
commit
9f31ea2e0f
|
@ -25,6 +25,12 @@ from plugins.physics import CollisionHandler, Solid, Velocity
|
||||||
from scenes import game_over
|
from scenes import game_over
|
||||||
|
|
||||||
|
|
||||||
|
class RestrictToScene:
|
||||||
|
"""
|
||||||
|
Composant marquant une entitée comme ne pouvant pas sortir de la scène.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class GameMode(Enum):
|
class GameMode(Enum):
|
||||||
"""
|
"""
|
||||||
Ressource qui definit le game mode choisi par l'utilisateur.
|
Ressource qui definit le game mode choisi par l'utilisateur.
|
||||||
|
@ -266,6 +272,7 @@ def __spawn_ellements(world: World):
|
||||||
DownKey("s"),
|
DownKey("s"),
|
||||||
Speed(1000),
|
Speed(1000),
|
||||||
LastPlayerTurn(),
|
LastPlayerTurn(),
|
||||||
|
RestrictToScene(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Joueur 2
|
# Joueur 2
|
||||||
|
@ -282,6 +289,7 @@ def __spawn_ellements(world: World):
|
||||||
(UpKey("up"), DownKey("down"), Speed(1000))
|
(UpKey("up"), DownKey("down"), Speed(1000))
|
||||||
if world[GameMode] == GameMode.TWO
|
if world[GameMode] == GameMode.TWO
|
||||||
else Speed(300),
|
else Speed(300),
|
||||||
|
RestrictToScene(),
|
||||||
)
|
)
|
||||||
|
|
||||||
__spawn_ball(world)
|
__spawn_ball(world)
|
||||||
|
@ -541,6 +549,7 @@ def _update_bot(world: World):
|
||||||
better_distance = None
|
better_distance = None
|
||||||
for offset in [-100, -50, 0, 50, 100]:
|
for offset in [-100, -50, 0, 50, 100]:
|
||||||
bot[Position].y = right_touch_height + offset
|
bot[Position].y = right_touch_height + offset
|
||||||
|
__restrict_to_scene(world)
|
||||||
player.remove(Solid)
|
player.remove(Solid)
|
||||||
left_wall_ball = __simulate_wall_position(ball, LeftWall)
|
left_wall_ball = __simulate_wall_position(ball, LeftWall)
|
||||||
player.set(Solid())
|
player.set(Solid())
|
||||||
|
@ -561,6 +570,23 @@ def _update_bot(world: World):
|
||||||
if abs(diff) > 10:
|
if abs(diff) > 10:
|
||||||
bot[Position].y += (diff / abs(diff)) * bot[Speed] * world[Delta]
|
bot[Position].y += (diff / abs(diff)) * bot[Speed] * world[Delta]
|
||||||
|
|
||||||
|
# On restrict l'entité a la scène
|
||||||
|
__restrict_to_scene(world)
|
||||||
|
|
||||||
|
|
||||||
|
def __restrict_to_scene(world: World):
|
||||||
|
"""
|
||||||
|
Restrinct dans la scène toutes les entitées ayant le composant RestrictToScene.
|
||||||
|
"""
|
||||||
|
for entity in world.query(RestrictToScene):
|
||||||
|
y = entity[Position].y - (entity[Origin].y * entity[Scale].y)
|
||||||
|
if y < 0:
|
||||||
|
entity[Position].y = entity[Origin].y * entity[Scale].y
|
||||||
|
if y + entity[Scale].y > render.HEIGHT:
|
||||||
|
entity[Position].y = (
|
||||||
|
render.HEIGHT - entity[Scale].y + (entity[Origin].y * entity[Scale].y)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def __check_bonus_collision(world: World):
|
def __check_bonus_collision(world: World):
|
||||||
"""
|
"""
|
||||||
|
@ -663,7 +689,13 @@ def __update_bonus_time(world: World):
|
||||||
|
|
||||||
__SCENE = Scene(
|
__SCENE = Scene(
|
||||||
[__spawn_ellements],
|
[__spawn_ellements],
|
||||||
[__update_move, __check_bonus_collision, __update_animation, __update_bonus_time],
|
[
|
||||||
|
__update_move,
|
||||||
|
__check_bonus_collision,
|
||||||
|
__update_animation,
|
||||||
|
__update_bonus_time,
|
||||||
|
__restrict_to_scene,
|
||||||
|
],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue