Save unfinished work
This commit is contained in:
parent
ee0fe070f8
commit
b55e7d7ec8
|
@ -173,6 +173,11 @@ 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
|
||||||
|
if entity[Velocity].x == 0:
|
||||||
|
entity[Velocity].x = 0.01
|
||||||
|
if entity[Velocity].y == 0:
|
||||||
|
entity[Velocity].y = 0.01
|
||||||
|
movement /= entity[Velocity]
|
||||||
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)
|
||||||
|
@ -182,6 +187,11 @@ 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
|
||||||
|
if entity[Velocity].x == 0:
|
||||||
|
entity[Velocity].x = 0.01
|
||||||
|
if entity[Velocity].y == 0:
|
||||||
|
entity[Velocity].y = 0.01
|
||||||
|
movement *= entity[Velocity]
|
||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -263,9 +263,9 @@ def __spawn_ellements(world: World):
|
||||||
SpriteBundle(
|
SpriteBundle(
|
||||||
"player_1.png",
|
"player_1.png",
|
||||||
0,
|
0,
|
||||||
Vec2(100, render.HEIGHT / 2),
|
Vec2(125, render.HEIGHT / 2),
|
||||||
Vec2(44, 250),
|
Vec2(44, 250),
|
||||||
Vec2(0.5),
|
Vec2(1, 0.5),
|
||||||
),
|
),
|
||||||
Solid(),
|
Solid(),
|
||||||
Player1(),
|
Player1(),
|
||||||
|
@ -281,9 +281,9 @@ def __spawn_ellements(world: World):
|
||||||
SpriteBundle(
|
SpriteBundle(
|
||||||
"player_2.png",
|
"player_2.png",
|
||||||
0,
|
0,
|
||||||
Vec2(render.WIDTH - 100, render.HEIGHT / 2),
|
Vec2(render.WIDTH - 125, render.HEIGHT / 2),
|
||||||
Vec2(44, 250),
|
Vec2(44, 250),
|
||||||
Vec2(0.5),
|
Vec2(0, 0.5),
|
||||||
),
|
),
|
||||||
Solid(),
|
Solid(),
|
||||||
Player2(),
|
Player2(),
|
||||||
|
@ -538,18 +538,18 @@ def _update_bot(world: World):
|
||||||
|
|
||||||
# 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):
|
for entity in world.query(RightWall):
|
||||||
entity[Position].x -= 122
|
entity[Position].x -= 125
|
||||||
for entity in world.query(LeftWall):
|
for entity in world.query(LeftWall):
|
||||||
entity[Position].x += 122
|
entity[Position].x += 125
|
||||||
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):
|
for entity in world.query(RightWall):
|
||||||
entity[Position].x += 122
|
entity[Position].x += 125
|
||||||
for entity in world.query(LeftWall):
|
for entity in world.query(LeftWall):
|
||||||
entity[Position].x -= 122
|
entity[Position].x -= 125
|
||||||
|
|
||||||
# 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
|
||||||
|
|
Loading…
Reference in a new issue