Réglage du suicide de l'IA #24
|
@ -173,7 +173,7 @@ def move_entity(entity: Entity, movement: Vec2, disable_callback: bool = False):
|
||||||
if normal.y != 0:
|
if normal.y != 0:
|
||||||
movement.y *= -1
|
movement.y *= -1
|
||||||
entity[Velocity].y *= -1
|
entity[Velocity].y *= -1
|
||||||
movement /= entity[Velocity]
|
# movement /= entity.get(Velocity, Vec2(1))
|
||||||
if obstacle is not None and not disable_callback:
|
if obstacle is not None and not disable_callback:
|
||||||
if not entity.get(
|
if not entity.get(
|
||||||
CollisionHandler, CollisionHandler(lambda e, o: True)
|
CollisionHandler, CollisionHandler(lambda e, o: True)
|
||||||
|
@ -183,7 +183,7 @@ def move_entity(entity: Entity, movement: Vec2, disable_callback: bool = False):
|
||||||
CollisionHandler, CollisionHandler(lambda e, o: True)
|
CollisionHandler, CollisionHandler(lambda e, o: True)
|
||||||
).callback(obstacle, entity):
|
).callback(obstacle, entity):
|
||||||
break
|
break
|
||||||
movement *= entity[Velocity]
|
# movement *= entity[Velocity]
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -537,11 +537,19 @@ def _update_bot(world: World):
|
||||||
player = world.query(Player1).pop()
|
player = world.query(Player1).pop()
|
||||||
|
|
||||||
# On trouve l'endroit ou la balle va arriver sur le mur de droite
|
# On trouve l'endroit ou la balle va arriver sur le mur de droite
|
||||||
|
for entity in world.query(RightWall):
|
||||||
|
entity[Position].x -= 122
|
||||||
|
for entity in world.query(LeftWall):
|
||||||
|
entity[Position].x += 122
|
||||||
bot.remove(Solid)
|
bot.remove(Solid)
|
||||||
right_wall_ball = __simulate_wall_position(ball, RightWall)
|
right_wall_ball = __simulate_wall_position(ball, RightWall)
|
||||||
right_touch_height = right_wall_ball[Position].y
|
right_touch_height = right_wall_ball[Position].y
|
||||||
right_wall_ball.destroy()
|
right_wall_ball.destroy()
|
||||||
bot.set(Solid())
|
bot.set(Solid())
|
||||||
|
for entity in world.query(RightWall):
|
||||||
|
entity[Position].x += 122
|
||||||
|
for entity in world.query(LeftWall):
|
||||||
|
entity[Position].x -= 122
|
||||||
|
|
||||||
# On teste différentes possitions pour voir laquelle la plus éloigné du joueur
|
# On teste différentes possitions pour voir laquelle la plus éloigné du joueur
|
||||||
# Mais seulement si la balle vas vers la droite car sinon elle touchera le mur
|
# Mais seulement si la balle vas vers la droite car sinon elle touchera le mur
|
||||||
|
@ -550,7 +558,10 @@ def _update_bot(world: World):
|
||||||
bot_base_y = bot[Position].y
|
bot_base_y = bot[Position].y
|
||||||
target: float = right_touch_height
|
target: float = right_touch_height
|
||||||
better_distance = None
|
better_distance = None
|
||||||
for offset in [-100, -50, 0, 50, 100]:
|
offsets = [-100, -50, 0, 50, 100]
|
||||||
|
if bot[Scale].y > 250:
|
||||||
|
offsets = [-200, -100, -50, 0, 50, 100, 200]
|
||||||
|
for offset in offsets:
|
||||||
bot[Position].y = right_touch_height + offset
|
bot[Position].y = right_touch_height + offset
|
||||||
__restrict_to_scene(world)
|
__restrict_to_scene(world)
|
||||||
player.remove(Solid)
|
player.remove(Solid)
|
||||||
|
|
Loading…
Reference in a new issue