Amélioration du bot pour qu'il tire dans la zone la plus éloigné du joueur #4
|
@ -210,7 +210,7 @@ def __angle_to_vec2(angle_degrees: float, magnitude: float):
|
||||||
x = magnitude * math.cos(angle_radians)
|
x = magnitude * math.cos(angle_radians)
|
||||||
y = magnitude * math.sin(angle_radians)
|
y = magnitude * math.sin(angle_radians)
|
||||||
|
|
||||||
return x, y
|
return Vec2(x, y)
|
||||||
|
|
||||||
|
|
||||||
def __spawn_ball(world: World):
|
def __spawn_ball(world: World):
|
||||||
|
@ -218,6 +218,10 @@ def __spawn_ball(world: World):
|
||||||
angle = random.randint(0, 360)
|
angle = random.randint(0, 360)
|
||||||
velocity = __angle_to_vec2(angle, 200)
|
velocity = __angle_to_vec2(angle, 200)
|
||||||
|
|
||||||
|
# mouvement a droite ou a gauche
|
||||||
|
if random.randint(0, 1) == 0:
|
||||||
|
velocity.x = -velocity.x
|
||||||
|
|
||||||
# Balle
|
# Balle
|
||||||
world.new_entity().set(
|
world.new_entity().set(
|
||||||
SpriteBundle(
|
SpriteBundle(
|
||||||
|
@ -229,7 +233,7 @@ def __spawn_ball(world: World):
|
||||||
),
|
),
|
||||||
Ball(),
|
Ball(),
|
||||||
#
|
#
|
||||||
physics.Velocity(Vec2(velocity)),
|
physics.Velocity(velocity),
|
||||||
physics.CollisionHandler(__bounce_on_player),
|
physics.CollisionHandler(__bounce_on_player),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue