diff --git a/assets/error.mp3 b/assets/error.mp3 deleted file mode 100644 index a3679b4..0000000 Binary files a/assets/error.mp3 and /dev/null differ diff --git a/assets/loaded.png b/assets/loaded.png deleted file mode 100644 index 6fcb6f3..0000000 Binary files a/assets/loaded.png and /dev/null differ diff --git a/assets/unloaded.png b/assets/unloaded.png deleted file mode 100644 index 9072760..0000000 Binary files a/assets/unloaded.png and /dev/null differ diff --git a/assets/waiting.mp3 b/assets/waiting.mp3 deleted file mode 100644 index f80c643..0000000 Binary files a/assets/waiting.mp3 and /dev/null differ diff --git a/src/scenes/game.py b/src/scenes/game.py index b31033c..5a1c14f 100644 --- a/src/scenes/game.py +++ b/src/scenes/game.py @@ -6,7 +6,8 @@ from enum import Enum from engine import Plugin, Scene from engine.ecs import Entity, World from engine.math import Vec2 -from plugins import physics, render +from plugins import render +from plugins import physics from plugins.inputs import Held from plugins.render import ( Origin, @@ -19,6 +20,7 @@ from plugins.render import ( ) from plugins.timing import Delta, Time import random +from plugins.physics import CollisionHandler, Solid, Velocity class GameMode(Enum): @@ -204,9 +206,9 @@ def __spawn_ellements(world: World): Origin(Vec2(1, 0)), Scale(Vec2(10, render.HEIGHT)), Position(Vec2(70, 0)), - physics.Solid(), + Solid(), LeftWall(), - physics.CollisionHandler(__bounce_on_left_wall), + CollisionHandler(__bounce_on_left_wall), ) # Mon mur du RN @@ -214,9 +216,9 @@ def __spawn_ellements(world: World): Origin(Vec2(0, 0)), Scale(Vec2(10, render.HEIGHT)), Position(Vec2(render.WIDTH - 70, 0)), - physics.Solid(), + Solid(), RightWall(), - physics.CollisionHandler(__bounce_on_right_wall), + CollisionHandler(__bounce_on_right_wall), ) # Mon mur du bas @@ -224,7 +226,7 @@ def __spawn_ellements(world: World): Origin(Vec2(0, 0)), Scale(Vec2(render.WIDTH, 10)), Position(Vec2(0, render.HEIGHT)), - physics.Solid(), + Solid(), ) # Mon mur du haut @@ -232,7 +234,7 @@ def __spawn_ellements(world: World): Origin(Vec2(0, 1)), Scale(Vec2(render.WIDTH, 10)), Position(Vec2(0, 0)), - physics.Solid(), + Solid(), ) # Joueur 1 @@ -244,7 +246,7 @@ def __spawn_ellements(world: World): Vec2(44, 250), Vec2(0.5), ), - physics.Solid(), + Solid(), Player1(), UpKey("z"), DownKey("s"), @@ -261,7 +263,7 @@ def __spawn_ellements(world: World): Vec2(44, 250), Vec2(0.5), ), - physics.Solid(), + Solid(), Player2(), (UpKey("up"), DownKey("down"), Speed(1000)) if world[GameMode] == GameMode.TWO @@ -323,8 +325,8 @@ def __spawn_ball(world: World): Vec2(0.5), ), Ball(), - physics.Velocity(velocity), - physics.CollisionHandler(__collision_with_ball), + Velocity(velocity), + CollisionHandler(__collision_with_ball), ) @@ -367,12 +369,10 @@ def __bounce_on_player(a: Entity, b: Entity): Fonction qui decrit se qui se passe lorque la ball entre en collision avec un joueur """ if Player1 in b or Player2 in b: - speed = a[physics.Velocity].length - a[physics.Velocity] = a[physics.Velocity].normalized - a[physics.Velocity].y = (a[Position].y - b[Position].y) * 0.005 - a[physics.Velocity] = a[physics.Velocity].normalized * min( - (speed * 1.1), 1000.0 - ) + speed = a[Velocity].length + a[Velocity] = a[Velocity].normalized + a[Velocity].y = (a[Position].y - b[Position].y) * 0.005 + a[Velocity] = a[Velocity].normalized * min((speed * 1.1), 1000.0) return True @@ -441,17 +441,17 @@ def __simulate_wall_position(entity: Entity, component_type: type): simulation_entity = entity.world.new_entity() def __collision_handler(a: Entity, b: Entity): - entity[physics.CollisionHandler].callback(a, b) + entity[CollisionHandler].callback(a, b) return component_type not in b simulation_entity.set( Position(entity[Position]), Scale(entity[Scale]), - physics.Velocity(entity[physics.Velocity]), + Velocity(entity[Velocity]), Origin(entity[Origin]), - physics.CollisionHandler(__collision_handler), + CollisionHandler(__collision_handler), ) - physics.move_entity(simulation_entity, entity[physics.Velocity] * 500) + physics.move_entity(simulation_entity, entity[Velocity] * 500) return simulation_entity @@ -460,7 +460,7 @@ def _update_bot(world: World): Fonction qui update les mouvement du bot """ # On récupère la balle la plus proche du bot - ball_query = world.query(Position, physics.Velocity, physics.CollisionHandler) + ball_query = world.query(Position, Velocity, CollisionHandler) if ball_query == set(): return None ball = max(ball_query, key=lambda entity: entity[Position].y) @@ -470,24 +470,24 @@ def _update_bot(world: World): player = world.query(Player1).pop() # On trouve l'endroit ou la balle va arriver sur le mur de droite - bot.remove(physics.Solid) + bot.remove(Solid) right_wall_ball = __simulate_wall_position(ball, RightWall) right_touch_height = right_wall_ball[Position].y right_wall_ball.destroy() - bot.set(physics.Solid()) + bot.set(Solid()) # 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 # de gauche sans intervention du bot - if ball[physics.Velocity].x > 0: + if ball[Velocity].x > 0: bot_base_y = bot[Position].y target: float = right_touch_height better_distance = None for offset in [-100, -50, 0, 50, 100]: bot[Position].y = right_touch_height + offset - player.remove(physics.Solid) + player.remove(Solid) left_wall_ball = __simulate_wall_position(ball, LeftWall) - player.set(physics.Solid()) + player.set(Solid()) left_touch_height = left_wall_ball[Position].y left_wall_ball.destroy() if ( @@ -518,20 +518,20 @@ def __check_bonus_collision(world: World): return True for entity in world.query(Bonus): - entity.set(physics.Solid()) + entity.set(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]), + Velocity(entity[Velocity]), Origin(entity[Origin]), - physics.CollisionHandler(__collision_handler), + CollisionHandler(__collision_handler), ) - physics.move_entity(simulated_ball, entity[physics.Velocity] * world[Delta]) + physics.move_entity(simulated_ball, entity[Velocity] * world[Delta]) simulated_ball.destroy() for entity in world.query(Bonus): - entity.remove(physics.Solid) + entity.remove(Solid) def __update_scores(world: World, ball: Entity):