La balle ne rebondis plus sur les bonus
This commit is contained in:
parent
8342157598
commit
24d57d6321
|
@ -16,7 +16,6 @@ from plugins.render import (
|
||||||
TextBundle,
|
TextBundle,
|
||||||
Text,
|
Text,
|
||||||
TextSize,
|
TextSize,
|
||||||
Texture,
|
|
||||||
)
|
)
|
||||||
from plugins.timing import Delta, Time
|
from plugins.timing import Delta, Time
|
||||||
import random
|
import random
|
||||||
|
@ -299,7 +298,6 @@ def __spawn_bonus(world: World):
|
||||||
Vec2(70),
|
Vec2(70),
|
||||||
Vec2(0.5),
|
Vec2(0.5),
|
||||||
),
|
),
|
||||||
physics.Solid(),
|
|
||||||
bonus,
|
bonus,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -336,11 +334,6 @@ def __collision_with_ball(a: Entity, b: Entity):
|
||||||
del player[LastPlayerTurn]
|
del player[LastPlayerTurn]
|
||||||
b.set(LastPlayerTurn())
|
b.set(LastPlayerTurn())
|
||||||
return __bounce_on_player(a, b)
|
return __bounce_on_player(a, b)
|
||||||
elif Bonus in b:
|
|
||||||
if Ball in a:
|
|
||||||
return __bonus_touched(a, b)
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -513,6 +506,34 @@ def _update_bot(world: World):
|
||||||
bot[Position].y += (diff / abs(diff)) * bot[Speed] * world[Delta]
|
bot[Position].y += (diff / abs(diff)) * bot[Speed] * world[Delta]
|
||||||
|
|
||||||
|
|
||||||
|
def __check_bonus_collision(world: World):
|
||||||
|
"""
|
||||||
|
Fonction qui permet de voir si un bonus est entrée en collision avec une entité.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __collision_handler(a: Entity, b: Entity):
|
||||||
|
if Bonus in b:
|
||||||
|
__bonus_touched(a, b)
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
for entity in world.query(Bonus):
|
||||||
|
entity.set(physics.Solid())
|
||||||
|
for entity in world.query(Ball):
|
||||||
|
simulated_ball = world.new_entity()
|
||||||
|
simulated_ball.set(
|
||||||
|
Position(entity[Position]),
|
||||||
|
Scale(entity[Scale]),
|
||||||
|
physics.Velocity(entity[physics.Velocity]),
|
||||||
|
Origin(entity[Origin]),
|
||||||
|
physics.CollisionHandler(__collision_handler),
|
||||||
|
)
|
||||||
|
physics.move_entity(simulated_ball, entity[physics.Velocity] * world[Delta])
|
||||||
|
simulated_ball.destroy()
|
||||||
|
for entity in world.query(Bonus):
|
||||||
|
entity.remove(physics.Solid)
|
||||||
|
|
||||||
|
|
||||||
def __update_scores(world: World, ball: Entity):
|
def __update_scores(world: World, ball: Entity):
|
||||||
"""
|
"""
|
||||||
La fontion permet de mettre a jour les scores.
|
La fontion permet de mettre a jour les scores.
|
||||||
|
@ -580,7 +601,7 @@ def __update_bonus_time(world: World):
|
||||||
|
|
||||||
__SCENE = Scene(
|
__SCENE = Scene(
|
||||||
[__spawn_ellements],
|
[__spawn_ellements],
|
||||||
[__update_move, __update_animation, __update_bonus_time],
|
[__update_move, __check_bonus_collision, __update_animation, __update_bonus_time],
|
||||||
[],
|
[],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue