diff --git a/CMakeLists.txt b/CMakeLists.txt index f0c68f78..73293abe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,8 @@ set(SOURCES sources/Runner/Runner.hpp sources/Map/Map.cpp sources/Map/Map.hpp + sources/Items/Bonus.cpp + sources/Items/Bonus.hpp sources/Component/Position/PositionComponent.cpp sources/Component/Position/PositionComponent.hpp sources/Component/Movable/MovableComponent.cpp @@ -80,12 +82,22 @@ set(SOURCES sources/Component/Button/ButtonComponent.hpp sources/System/MenuControllable/MenuControllableSystem.cpp sources/System/MenuControllable/MenuControllableSystem.hpp + sources/System/Levitate/LevitateSystem.hpp + sources/System/Levitate/LevitateSystem.cpp + sources/Component/Levitate/LevitateComponent.cpp + sources/Component/Levitate/LevitateComponent.cpp sources/Component/Animator/AnimatorComponent.cpp sources/Component/Animator/AnimatorComponent.hpp sources/System/Animator/AnimatorSystem.cpp sources/System/Animator/AnimatorSystem.hpp sources/Component/Shaders/ShaderComponent.cpp sources/Component/Shaders/ShaderComponent.hpp + sources/Component/Bomb/BasicBombComponent.cpp + sources/Component/Bomb/BasicBombComponent.hpp + sources/Component/Bonus/PlayerBonusComponent.hpp + sources/Component/Bonus/PlayerBonusComponent.cpp + sources/System/Bonus/PlayerBonusSystem.hpp + sources/System/Bonus/PlayerBonusSystem.cpp sources/Component/Tag/TagComponent.hpp sources/Component/Music/MusicComponent.cpp sources/Component/Music/MusicComponent.hpp @@ -101,8 +113,20 @@ set(SOURCES sources/System/Lobby/LobbySystem.hpp sources/Component/Lobby/LobbyComponent.cpp sources/Component/Lobby/LobbyComponent.hpp -) - + sources/System/Bomb/BombSystem.cpp + sources/System/Bomb/BombSystem.hpp + sources/Component/IntroAnimation/IntroAnimationComponent.hpp + sources/Component/IntroAnimation/IntroAnimationComponent.cpp + sources/System/IntroAnimation/IntroAnimationSystem.hpp + sources/System/IntroAnimation/IntroAnimationSystem.cpp + sources/Runner/SplashScreenScene.cpp + sources/Runner/TitleScreenScene.cpp + sources/Runner/MainMenuScene.cpp + sources/Runner/GameScene.cpp + sources/Runner/PauseMenuScene.cpp + sources/Runner/SettingsMenuScene.cpp + sources/Runner/CreditScene.cpp + sources/Runner/LobbyScene.cpp) add_executable(bomberman sources/main.cpp ${SOURCES} diff --git a/assets/bombs/explosion/blast.png b/assets/bombs/explosion/blast.png new file mode 100644 index 00000000..037212f6 Binary files /dev/null and b/assets/bombs/explosion/blast.png differ diff --git a/assets/bombs/explosion/explosion.glb b/assets/bombs/explosion/explosion.glb new file mode 100644 index 00000000..065ed85c Binary files /dev/null and b/assets/bombs/explosion/explosion.glb differ diff --git a/assets/items/bombup.mtl b/assets/items/bombup.mtl index d2a7d74f..f00fb7b5 100644 --- a/assets/items/bombup.mtl +++ b/assets/items/bombup.mtl @@ -1,7 +1,7 @@ # Blender MTL File: 'None' # Material Count: 1 -newmtl mat_map_ob000_item_007 +newmtl mat_map_ob000_item_007.004 Ns 323.999994 Ka 1.000000 1.000000 1.000000 Kd 0.800000 0.800000 0.800000 diff --git a/assets/items/bombup.obj b/assets/items/bombup.obj index ab9d47d4..898ade23 100644 --- a/assets/items/bombup.obj +++ b/assets/items/bombup.obj @@ -1,31 +1,31 @@ -# Blender v2.92.0 OBJ File: '' +# Blender v2.93.0 OBJ File: '' # www.blender.org mtllib bombup.mtl -o map_ob000_item_02_bombup -v 0.400000 -0.335876 0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.335876 -0.229810 -v -0.400000 -0.229810 0.335876 -v 0.400000 -0.229810 0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 -0.229810 0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 -0.335876 0.229810 -v -0.400000 -0.229810 0.335876 -v -0.400000 -0.229810 0.335876 -v -0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v 0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v 0.400000 -0.229810 0.335876 +o map_ob000_item_02_bombup.002 +v -0.406274 -0.087688 0.390996 +v -0.393549 -0.062236 -0.408499 +v 0.393625 -0.087688 0.403727 +v 0.406350 -0.062236 -0.395768 +v -0.406350 0.062236 0.395768 +v -0.406274 -0.087688 0.390996 +v 0.393549 0.062236 0.408499 +v 0.393625 -0.087688 0.403727 +v -0.393625 0.087688 -0.403727 +v -0.406350 0.062236 0.395768 +v 0.406274 0.087688 -0.390996 +v 0.393549 0.062236 0.408499 +v -0.393549 -0.062236 -0.408499 +v -0.393625 0.087688 -0.403727 +v 0.406350 -0.062236 -0.395768 +v 0.406274 0.087688 -0.390996 +v 0.406350 -0.062236 -0.395768 +v 0.406274 0.087688 -0.390996 +v 0.393625 -0.087688 0.403727 +v 0.393549 0.062236 0.408499 +v -0.406274 -0.087688 0.390996 +v -0.406350 0.062236 0.395768 +v -0.393549 -0.062236 -0.408499 +v -0.393625 0.087688 -0.403727 vt 0.001000 0.498000 vt 0.001000 0.252000 vt 0.124000 0.498000 @@ -50,23 +50,23 @@ vt 0.648280 0.996259 vt 0.632244 0.996259 vt 0.648280 0.754140 vt 0.632244 0.754140 -vn 0.0000 -0.7071 -0.7071 -vn 0.0000 0.7071 -0.7071 -vn 0.0000 0.7071 0.7071 -vn 0.0000 -0.7071 0.7071 -vn -1.0000 0.0000 0.0000 -vn 1.0000 0.0000 0.0000 -usemtl mat_map_ob000_item_007 -s off -f 3/1/1 1/2/1 2/3/1 -f 2/3/1 1/2/1 4/4/1 -f 7/5/2 5/6/2 6/7/2 -f 6/7/2 5/6/2 8/8/2 -f 11/9/3 9/10/3 10/11/3 -f 10/11/3 9/10/3 12/12/3 -f 15/13/4 13/14/4 14/15/4 -f 14/15/4 13/14/4 16/16/4 -f 19/17/5 17/18/5 18/19/5 -f 18/19/5 17/18/5 20/20/5 -f 23/21/6 21/22/6 22/23/6 -f 22/23/6 21/22/6 24/24/6 +vn 0.0005 -0.9995 -0.0318 +vn -0.0159 -0.0318 0.9994 +vn -0.0005 0.9995 0.0318 +vn 0.0159 0.0318 -0.9994 +vn 0.9999 0.0000 0.0159 +vn -0.9999 -0.0000 -0.0159 +usemtl mat_map_ob000_item_007.004 +s 1 +f 1/1/1 2/2/1 3/3/1 +f 3/3/1 2/2/1 4/4/1 +f 5/5/2 6/6/2 7/7/2 +f 7/7/2 6/6/2 8/8/2 +f 9/9/3 10/10/3 11/11/3 +f 11/11/3 10/10/3 12/12/3 +f 13/13/4 14/14/4 15/15/4 +f 15/15/4 14/14/4 16/16/4 +f 17/17/5 18/18/5 19/19/5 +f 19/19/5 18/18/5 20/20/5 +f 21/21/6 22/22/6 23/23/6 +f 23/23/6 22/22/6 24/24/6 diff --git a/assets/items/fireup.mtl b/assets/items/fireup.mtl index 2445bb45..a90b6641 100644 --- a/assets/items/fireup.mtl +++ b/assets/items/fireup.mtl @@ -1,7 +1,7 @@ # Blender MTL File: 'None' # Material Count: 1 -newmtl mat_map_ob000_item_007.001 +newmtl mat_map_ob000_item_007.005 Ns 323.999994 Ka 1.000000 1.000000 1.000000 Kd 0.800000 0.800000 0.800000 diff --git a/assets/items/fireup.obj b/assets/items/fireup.obj index 664c62c4..8aefa489 100644 --- a/assets/items/fireup.obj +++ b/assets/items/fireup.obj @@ -1,72 +1,72 @@ -# Blender v2.92.0 OBJ File: '' +# Blender v2.93.0 OBJ File: '' # www.blender.org mtllib fireup.mtl -o map_ob000_item_01_fireup -v 0.400000 -0.335876 0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.335876 -0.229810 -v -0.400000 -0.229810 0.335876 -v 0.400000 -0.229810 0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 -0.229810 0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 -0.335876 0.229810 -v -0.400000 -0.229810 0.335876 -v -0.400000 -0.229810 0.335876 -v -0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v 0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v 0.400000 -0.229810 0.335876 -vt 0.000000 0.250000 -vt 0.000000 0.000000 -vt 0.125000 0.250000 -vt 0.125000 0.000000 -vt 0.125000 0.237500 -vt 0.125000 0.250000 -vt 0.000000 0.237500 -vt 0.000000 0.250000 -vt 0.125000 0.000000 -vt 0.125000 0.250000 -vt 0.000000 0.000000 -vt 0.000000 0.250000 -vt 0.000000 0.250000 -vt 0.000000 0.237500 -vt 0.125000 0.250000 -vt 0.125000 0.237500 -vt 0.000000 0.250000 -vt 0.000000 0.237500 -vt 0.125000 0.250000 -vt 0.125000 0.237500 -vt 0.000000 0.250000 -vt 0.000000 0.237500 -vt 0.125000 0.250000 -vt 0.125000 0.237500 -vn 0.0000 -0.7071 -0.7071 -vn 0.0000 0.7071 -0.7071 -vn 0.0000 0.7071 0.7071 -vn 0.0000 -0.7071 0.7071 -vn -1.0000 0.0000 0.0000 -vn 1.0000 0.0000 0.0000 -usemtl mat_map_ob000_item_007.001 -s off -f 3/1/1 1/2/1 2/3/1 -f 2/3/1 1/2/1 4/4/1 -f 7/5/2 5/6/2 6/7/2 -f 6/7/2 5/6/2 8/8/2 -f 11/9/3 9/10/3 10/11/3 -f 10/11/3 9/10/3 12/12/3 -f 15/13/4 13/14/4 14/15/4 -f 14/15/4 13/14/4 16/16/4 -f 19/17/5 17/18/5 18/19/5 -f 18/19/5 17/18/5 20/20/5 -f 23/21/6 21/22/6 22/23/6 -f 22/23/6 21/22/6 24/24/6 +o map_ob000_item_02_bombup.003 +v -0.401008 -0.084798 0.397024 +v -0.398980 -0.065157 -0.402734 +v 0.398990 -0.084798 0.399052 +v 0.401017 -0.065157 -0.400706 +v -0.401017 0.065157 0.400706 +v -0.401008 -0.084798 0.397024 +v 0.398980 0.065157 0.402734 +v 0.398990 -0.084798 0.399052 +v -0.398990 0.084798 -0.399052 +v -0.401017 0.065157 0.400706 +v 0.401008 0.084798 -0.397024 +v 0.398980 0.065157 0.402734 +v -0.398980 -0.065157 -0.402734 +v -0.398990 0.084798 -0.399052 +v 0.401017 -0.065157 -0.400706 +v 0.401008 0.084798 -0.397024 +v 0.401017 -0.065157 -0.400706 +v 0.401008 0.084798 -0.397024 +v 0.398990 -0.084798 0.399052 +v 0.398980 0.065157 0.402734 +v -0.401008 -0.084798 0.397024 +v -0.401017 0.065157 0.400706 +v -0.398980 -0.065157 -0.402734 +v -0.398990 0.084798 -0.399052 +vt 0.001000 0.498000 +vt 0.001000 0.252000 +vt 0.124000 0.498000 +vt 0.124000 0.252000 +vt 0.632244 0.754140 +vt 0.648280 0.754140 +vt 0.632244 0.996259 +vt 0.648280 0.996259 +vt 0.124000 0.252000 +vt 0.124000 0.498000 +vt 0.001000 0.252000 +vt 0.001000 0.498000 +vt 0.648280 0.996259 +vt 0.632244 0.996259 +vt 0.648280 0.754140 +vt 0.632244 0.754140 +vt 0.648280 0.996259 +vt 0.632244 0.996259 +vt 0.648280 0.754140 +vt 0.632244 0.754140 +vt 0.648280 0.996259 +vt 0.632244 0.996259 +vt 0.648280 0.754140 +vt 0.632244 0.754140 +vn 0.0001 -0.9997 -0.0246 +vn -0.0025 -0.0245 0.9997 +vn -0.0001 0.9997 0.0246 +vn 0.0025 0.0245 -0.9997 +vn 1.0000 0.0000 0.0025 +vn -1.0000 0.0000 -0.0025 +usemtl mat_map_ob000_item_007.005 +s 1 +f 1/1/1 2/2/1 3/3/1 +f 3/3/1 2/2/1 4/4/1 +f 5/5/2 6/6/2 7/7/2 +f 7/7/2 6/6/2 8/8/2 +f 9/9/3 10/10/3 11/11/3 +f 11/11/3 10/10/3 12/12/3 +f 13/13/4 14/14/4 15/15/4 +f 15/15/4 14/14/4 16/16/4 +f 17/17/5 18/18/5 19/19/5 +f 19/19/5 18/18/5 20/20/5 +f 21/21/6 22/22/6 23/23/6 +f 23/23/6 22/22/6 24/24/6 diff --git a/assets/items/speedup.mtl b/assets/items/speedup.mtl index e2209d22..2bbe0a75 100644 --- a/assets/items/speedup.mtl +++ b/assets/items/speedup.mtl @@ -1,12 +1,12 @@ # Blender MTL File: 'None' # Material Count: 1 -newmtl mat_map_ob000_item_007.002 -Ns 323.999994 +newmtl mat_map_ob000_item_007.006 +Ns 225.000000 Ka 1.000000 1.000000 1.000000 Kd 0.800000 0.800000 0.800000 Ks 0.500000 0.500000 0.500000 Ke 0.000000 0.000000 0.000000 -Ni 1.000000 +Ni 1.450000 d 1.000000 illum 2 diff --git a/assets/items/speedup.obj b/assets/items/speedup.obj index 9b8292cc..514403db 100644 --- a/assets/items/speedup.obj +++ b/assets/items/speedup.obj @@ -1,31 +1,31 @@ -# Blender v2.92.0 OBJ File: '' +# Blender v2.93.0 OBJ File: '' # www.blender.org mtllib speedup.mtl -o map_ob000_item_03_speedup -v 0.400000 -0.335876 0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.335876 -0.229810 -v -0.400000 -0.229810 0.335876 -v 0.400000 -0.229810 0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 -0.229810 0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 -0.335876 0.229810 -v -0.400000 -0.229810 0.335876 -v -0.400000 -0.229810 0.335876 -v -0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v 0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v 0.400000 -0.229810 0.335876 +o map_ob000_item_03_speedup.001 +v -0.403210 -0.086631 0.394388 +v -0.396728 -0.063305 -0.405246 +v 0.396764 -0.086631 0.400873 +v 0.403246 -0.063305 -0.398762 +v -0.403246 0.063305 0.398762 +v -0.403210 -0.086631 0.394388 +v 0.396728 0.063305 0.405246 +v 0.396764 -0.086631 0.400873 +v -0.396764 0.086631 -0.400873 +v -0.403246 0.063305 0.398762 +v 0.403210 0.086631 -0.394388 +v 0.396728 0.063305 0.405246 +v -0.396728 -0.063305 -0.405246 +v -0.396764 0.086631 -0.400873 +v 0.403246 -0.063305 -0.398762 +v 0.403210 0.086631 -0.394388 +v 0.403246 -0.063305 -0.398762 +v 0.403210 0.086631 -0.394388 +v 0.396764 -0.086631 0.400873 +v 0.396728 0.063305 0.405246 +v -0.403210 -0.086631 0.394388 +v -0.403246 0.063305 0.398762 +v -0.396728 -0.063305 -0.405246 +v -0.396764 0.086631 -0.400873 vt 0.001000 0.748000 vt 0.001000 0.502000 vt 0.124000 0.748000 @@ -50,23 +50,23 @@ vt 0.648280 0.996259 vt 0.632244 0.996259 vt 0.648280 0.754140 vt 0.632244 0.754140 -vn 0.0000 -0.7071 -0.7071 -vn 0.0000 0.7071 -0.7071 -vn 0.0000 0.7071 0.7071 -vn 0.0000 -0.7071 0.7071 -vn -1.0000 0.0000 0.0000 -vn 1.0000 0.0000 0.0000 -usemtl mat_map_ob000_item_007.002 -s off -f 3/1/1 1/2/1 2/3/1 -f 2/3/1 1/2/1 4/4/1 -f 7/5/2 5/6/2 6/7/2 -f 6/7/2 5/6/2 8/8/2 -f 11/9/3 9/10/3 10/11/3 -f 10/11/3 9/10/3 12/12/3 -f 15/13/4 13/14/4 14/15/4 -f 14/15/4 13/14/4 16/16/4 -f 19/17/5 17/18/5 18/19/5 -f 18/19/5 17/18/5 20/20/5 -f 23/21/6 21/22/6 22/23/6 -f 22/23/6 21/22/6 24/24/6 +vn 0.0002 -0.9996 -0.0292 +vn -0.0081 -0.0292 0.9995 +vn -0.0002 0.9996 0.0292 +vn 0.0081 0.0292 -0.9995 +vn 1.0000 0.0000 0.0081 +vn -1.0000 0.0000 -0.0081 +usemtl mat_map_ob000_item_007.006 +s 1 +f 1/1/1 2/2/1 3/3/1 +f 3/3/1 2/2/1 4/4/1 +f 5/5/2 6/6/2 7/7/2 +f 7/7/2 6/6/2 8/8/2 +f 9/9/3 10/10/3 11/11/3 +f 11/11/3 10/10/3 12/12/3 +f 13/13/4 14/14/4 15/15/4 +f 15/15/4 14/14/4 16/16/4 +f 17/17/5 18/18/5 19/19/5 +f 19/19/5 18/18/5 20/20/5 +f 21/21/6 22/22/6 23/23/6 +f 23/23/6 22/22/6 24/24/6 diff --git a/assets/items/wallpass.mtl b/assets/items/wallpass.mtl index 26ba44df..99cdab02 100644 --- a/assets/items/wallpass.mtl +++ b/assets/items/wallpass.mtl @@ -1,7 +1,7 @@ # Blender MTL File: 'None' # Material Count: 1 -newmtl mat_map_ob000_item_007.003 +newmtl mat_map_ob000_item_007.007 Ns 323.999994 Ka 1.000000 1.000000 1.000000 Kd 0.800000 0.800000 0.800000 diff --git a/assets/items/wallpass.obj b/assets/items/wallpass.obj index 44360fc0..bb67337a 100644 --- a/assets/items/wallpass.obj +++ b/assets/items/wallpass.obj @@ -1,31 +1,31 @@ -# Blender v2.92.0 OBJ File: '' +# Blender v2.93.0 OBJ File: '' # www.blender.org mtllib wallpass.mtl -o map_ob000_item_14_wallthrough -v 0.400000 -0.335876 0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v -0.400000 0.229810 -0.335876 -v 0.400000 0.335876 -0.229810 -v -0.400000 -0.229810 0.335876 -v 0.400000 -0.229810 0.335876 -v -0.400000 0.335876 -0.229810 -v 0.400000 -0.229810 0.335876 -v -0.400000 -0.335876 0.229810 -v 0.400000 -0.335876 0.229810 -v -0.400000 -0.229810 0.335876 -v -0.400000 -0.229810 0.335876 -v -0.400000 0.229810 -0.335876 -v -0.400000 -0.335876 0.229810 -v -0.400000 0.335876 -0.229810 -v 0.400000 0.335876 -0.229810 -v 0.400000 -0.335876 0.229810 -v 0.400000 0.229810 -0.335876 -v 0.400000 -0.229810 0.335876 +o map_ob000_item_14_wallthrough.001 +v -0.406589 -0.098369 0.388116 +v -0.393149 -0.051371 -0.410391 +v 0.393297 -0.098369 0.401580 +v 0.406738 -0.051371 -0.396927 +v -0.406738 0.051371 0.396927 +v -0.406589 -0.098369 0.388116 +v 0.393149 0.051371 0.410391 +v 0.393297 -0.098369 0.401580 +v -0.393297 0.098369 -0.401580 +v -0.406738 0.051371 0.396927 +v 0.406589 0.098369 -0.388116 +v 0.393149 0.051371 0.410391 +v -0.393149 -0.051371 -0.410391 +v -0.393297 0.098369 -0.401580 +v 0.406738 -0.051371 -0.396927 +v 0.406589 0.098369 -0.388116 +v 0.406738 -0.051371 -0.396927 +v 0.406589 0.098369 -0.388116 +v 0.393297 -0.098369 0.401580 +v 0.393149 0.051371 0.410391 +v -0.406589 -0.098369 0.388116 +v -0.406738 0.051371 0.396927 +v -0.393149 -0.051371 -0.410391 +v -0.393297 0.098369 -0.401580 vt 0.501000 0.998000 vt 0.501000 0.752000 vt 0.624000 0.998000 @@ -50,23 +50,23 @@ vt 0.648280 0.996259 vt 0.632244 0.996259 vt 0.648280 0.754140 vt 0.632244 0.754140 -vn 0.0000 -0.7071 -0.7071 -vn 0.0000 0.7071 -0.7071 -vn 0.0000 0.7071 0.7071 -vn 0.0000 -0.7071 0.7071 -vn -1.0000 0.0000 0.0000 -vn 1.0000 0.0000 0.0000 -usemtl mat_map_ob000_item_007.003 -s off -f 3/1/1 1/2/1 2/3/1 -f 2/3/1 1/2/1 4/4/1 -f 7/5/2 5/6/2 6/7/2 -f 6/7/2 5/6/2 8/8/2 -f 11/9/3 9/10/3 10/11/3 -f 10/11/3 9/10/3 12/12/3 -f 15/13/4 13/14/4 14/15/4 -f 14/15/4 13/14/4 16/16/4 -f 19/17/5 17/18/5 18/19/5 -f 18/19/5 17/18/5 20/20/5 -f 23/21/6 21/22/6 22/23/6 -f 22/23/6 21/22/6 24/24/6 +vn 0.0010 -0.9983 -0.0587 +vn -0.0168 -0.0587 0.9981 +vn -0.0010 0.9983 0.0587 +vn 0.0168 0.0587 -0.9981 +vn 0.9999 -0.0000 0.0168 +vn -0.9999 0.0000 -0.0168 +usemtl mat_map_ob000_item_007.007 +s 1 +f 1/1/1 2/2/1 3/3/1 +f 3/3/1 2/2/1 4/4/1 +f 5/5/2 6/6/2 7/7/2 +f 7/7/2 6/6/2 8/8/2 +f 9/9/3 10/10/3 11/11/3 +f 11/11/3 10/10/3 12/12/3 +f 13/13/4 14/14/4 15/15/4 +f 15/15/4 14/14/4 16/16/4 +f 17/17/5 18/18/5 19/19/5 +f 19/19/5 18/18/5 20/20/5 +f 21/21/6 22/22/6 23/23/6 +f 23/23/6 22/22/6 24/24/6 diff --git a/assets/sounds/splash_sound.ogg b/assets/sounds/splash_sound.ogg new file mode 100644 index 00000000..d9092e53 Binary files /dev/null and b/assets/sounds/splash_sound.ogg differ diff --git a/lib/Ray/sources/Drawables/2D/Rectangle.cpp b/lib/Ray/sources/Drawables/2D/Rectangle.cpp index 9f623bee..284e9b27 100644 --- a/lib/Ray/sources/Drawables/2D/Rectangle.cpp +++ b/lib/Ray/sources/Drawables/2D/Rectangle.cpp @@ -33,13 +33,47 @@ namespace RAY::Drawables::Drawables2D return *this; } - Rectangle &Rectangle::setDimensions(int x, int y) + Rectangle &Rectangle::setDimensions(float x, float y) { this->_dimensions.x = x; this->_dimensions.y = y; return *this; } + float Rectangle::getHeight(void) const + { + return this->_dimensions.y; + } + + float Rectangle::getWidth(void) const + { + return this->_dimensions.x; + } + + Rectangle &Rectangle::incrementWidth(float width) + { + this->_dimensions.x += width; + return *this; + } + + Rectangle &Rectangle::incrementHeight(float height) + { + this->_dimensions.y += height; + return *this; + } + + Rectangle &Rectangle::setWidth(float width) + { + this->_dimensions.x = width; + return *this; + } + + Rectangle &Rectangle::setHeight(float height) + { + this->_dimensions.y = height; + return *this; + } + void Rectangle::drawOn(RAY::Window &) { DrawRectangleV(this->_position, this->_dimensions, this->_color); diff --git a/lib/Ray/sources/Drawables/2D/Rectangle.hpp b/lib/Ray/sources/Drawables/2D/Rectangle.hpp index 79663e5a..1a829ea2 100644 --- a/lib/Ray/sources/Drawables/2D/Rectangle.hpp +++ b/lib/Ray/sources/Drawables/2D/Rectangle.hpp @@ -42,11 +42,33 @@ namespace RAY::Drawables::Drawables2D { //! @return the dimensions of the rectangle const Vector2 &getDimensions(void); + //! @return the width of the rectangle + float getWidth(void) const; + + //! @return the height of the rectangle + float getHeight(void) const; + //! @brief set dimensions Rectangle &setDimensions(const Vector2 &dimensions); + //! @brief increment width of the rectangle + //! @param width incrementer + Rectangle &incrementWidth(float width); + + //! @brief increment height of the rectangle + //! @param height incrementer + Rectangle &incrementHeight(float height); + + //! @brief set rectangle's height + //! @param height height of the rectangle + Rectangle &setHeight(float height); + + //! @brief set rectangle's width + //! @param width width of the rectangle + Rectangle &setWidth(float width); + //! @brief set dimensions - Rectangle &setDimensions(int x, int y); + Rectangle &setDimensions(float x, float y); //! @brief Draw point on window virtual void drawOn(RAY::Window &) override; diff --git a/lib/Ray/sources/Model/Model.cpp b/lib/Ray/sources/Model/Model.cpp index 62046b15..9fd5b31e 100644 --- a/lib/Ray/sources/Model/Model.cpp +++ b/lib/Ray/sources/Model/Model.cpp @@ -82,9 +82,9 @@ namespace RAY::Drawables::Drawables3D return this->_rotationAngle; } - Model &Model::setRotationAxis(const RAY::Vector3 &scale) + Model &Model::setRotationAxis(const RAY::Vector3 &rotationAxis) { - this->_scale = scale; + this->_rotationAxis = rotationAxis; return *this; } diff --git a/lib/Ray/sources/Model/Model.hpp b/lib/Ray/sources/Model/Model.hpp index a7d8d89b..d67706be 100644 --- a/lib/Ray/sources/Model/Model.hpp +++ b/lib/Ray/sources/Model/Model.hpp @@ -68,7 +68,7 @@ namespace RAY::Drawables::Drawables3D { float getRotationAngle(void); //! @brief Set Rotation Axis - Model &setRotationAxis(const RAY::Vector3 &scale); + Model &setRotationAxis(const RAY::Vector3 &rotationAxis); //! @return rotation axis const RAY::Vector3 & getRotationAxis(void); diff --git a/sources/Component/Bomb/BasicBombComponent.cpp b/sources/Component/Bomb/BasicBombComponent.cpp new file mode 100644 index 00000000..97cbb70d --- /dev/null +++ b/sources/Component/Bomb/BasicBombComponent.cpp @@ -0,0 +1,20 @@ +// +// Created by Utilisateur on 08/06/2021. +// + +#include "BasicBombComponent.hpp" + +namespace BBM +{ + BasicBombComponent::BasicBombComponent(WAL::Entity &entity, int damage, int explosionRadius, unsigned ownerID) + : WAL::Component(entity), + damage(damage), + explosionRadius(explosionRadius), + ownerID(ownerID) + {} + + WAL::Component *BasicBombComponent::clone(WAL::Entity &entity) const + { + return new BasicBombComponent(entity, this->damage, this->explosionRadius, this->ownerID); + } +} \ No newline at end of file diff --git a/sources/Component/Bomb/BasicBombComponent.hpp b/sources/Component/Bomb/BasicBombComponent.hpp new file mode 100644 index 00000000..1b9b46bf --- /dev/null +++ b/sources/Component/Bomb/BasicBombComponent.hpp @@ -0,0 +1,42 @@ +// +// Created by Utilisateur on 08/06/2021. +// + +#pragma once + +#include "Component/Component.hpp" +#include "Entity/Entity.hpp" +#include + +using namespace std::chrono_literals; + +namespace BBM +{ + class BasicBombComponent : public WAL::Component + { + public: + //! @brief The radius of the explosion. + const int explosionRadius = 3; + //! @brief The damage made by the explosion on an entity + const int damage = 1; + //! @brief The ID of the owner. + unsigned ownerID; + //! @brief Should collisions with the owner be disabled.² + bool ignoreOwner = true; + + //! @inherit + WAL::Component *clone(WAL::Entity &entity) const override; + + //! @brief A component can't be instantiated, it should be derived. + explicit BasicBombComponent(WAL::Entity &entity, int damage, int explosionRadius, unsigned ownerID); + + //! @brief A component can't be instantiated, it should be derived. + BasicBombComponent(const BasicBombComponent &) = default; + + //! @brief default destructor + ~BasicBombComponent() override = default; + + //! @brief A component can't be assigned + BasicBombComponent &operator=(const BasicBombComponent &) = delete; + }; +} \ No newline at end of file diff --git a/sources/Component/BombHolder/BombHolderComponent.hpp b/sources/Component/BombHolder/BombHolderComponent.hpp index 03906e84..43242338 100644 --- a/sources/Component/BombHolder/BombHolderComponent.hpp +++ b/sources/Component/BombHolder/BombHolderComponent.hpp @@ -22,9 +22,13 @@ namespace BBM //! @brief The max number of bomb that this entity can have. unsigned int maxBombCount = 3; //! @brief The number of seconds of each refill. This variable is used to reset the nextBombRefill value. - std::chrono::nanoseconds refillRate = 5000ms; + std::chrono::nanoseconds refillRate = 1s; //! @brief The number of nanosecond before the next bomb refill. std::chrono::nanoseconds nextBombRefill = refillRate; + //! @brief The radius of the explosion. + float explosionRadius = 3; + //! @brief The damage made by the explosion on an entity + int damage = 1; //! @inherit WAL::Component *clone(WAL::Entity &entity) const override; diff --git a/sources/Component/Bonus/PlayerBonusComponent.cpp b/sources/Component/Bonus/PlayerBonusComponent.cpp new file mode 100644 index 00000000..1c1d1d31 --- /dev/null +++ b/sources/Component/Bonus/PlayerBonusComponent.cpp @@ -0,0 +1,16 @@ +// +// Created by hbenjamin on 09/06/2021. +// + +#include "PlayerBonusComponent.hpp" + +namespace BBM { + PlayerBonusComponent::PlayerBonusComponent(WAL::Entity &entity) + : WAL::Component(entity) + {} + + WAL::Component *PlayerBonusComponent::clone(WAL::Entity &entity) const + { + return new PlayerBonusComponent(entity); + } +} diff --git a/sources/Component/Bonus/PlayerBonusComponent.hpp b/sources/Component/Bonus/PlayerBonusComponent.hpp new file mode 100644 index 00000000..c6a10056 --- /dev/null +++ b/sources/Component/Bonus/PlayerBonusComponent.hpp @@ -0,0 +1,43 @@ +// +// Created by hbenjamin on 09/06/2021. +// + +#pragma once + +#include "Component/Component.hpp" +#include "Entity/Entity.hpp" +#include + +using namespace std::chrono_literals; + +namespace BBM +{ + class PlayerBonusComponent : public WAL::Component + { + public: + + //! @brief The number of seconds before a speed bonus expire. This variable is used to reset the nextSpeedBonusRate value. + std::chrono::nanoseconds speedBonusRate = 15s; + //! @brief The number of nanosecond before the expiration of a speed bonus. + std::chrono::nanoseconds nextSpeedBonusRate = speedBonusRate; + //! @brief The number of seconds before a range bonus expire. This variable is used to reset the nextRangeBonusRate value. + std::chrono::nanoseconds rangeBonusRate = 10s; + //! @brief The number of nanosecond before the expiration of a range bonus. + std::chrono::nanoseconds nextRangeBonusRate = rangeBonusRate; + + //! @inherit + WAL::Component *clone(WAL::Entity &entity) const override; + + //! @brief A Bonus component can't be instantiated, it should be derived. + explicit PlayerBonusComponent(WAL::Entity &entity); + + //! @brief A Bonus component can't be instantiated, it should be derived. + PlayerBonusComponent(const PlayerBonusComponent &) = default; + + //! @brief default destructor + ~PlayerBonusComponent() override = default; + + //! @brief A Bonus component can't be assigned + PlayerBonusComponent &operator=(const PlayerBonusComponent &) = delete; + }; +} \ No newline at end of file diff --git a/sources/Component/Collision/CollisionComponent.hpp b/sources/Component/Collision/CollisionComponent.hpp index 06878a76..e4244a7a 100644 --- a/sources/Component/Collision/CollisionComponent.hpp +++ b/sources/Component/Collision/CollisionComponent.hpp @@ -23,8 +23,14 @@ namespace BBM }; //! @brief onCollide functions to be called + //! @param first self + //! @param second the entity you collided + //! @param third the collision axis (to know which axis collided) WAL::Callback onCollide; //! @brief onCollided functions to be called + //! @param first the entity that collided you + //! @param second self + //! @param third the collision axis (to know which axis collided) WAL::Callback onCollided; //! @brief Bound size on all axis Vector3f bound; diff --git a/sources/Component/Controllable/ControllableComponent.hpp b/sources/Component/Controllable/ControllableComponent.hpp index 89110cee..5b7d39ad 100644 --- a/sources/Component/Controllable/ControllableComponent.hpp +++ b/sources/Component/Controllable/ControllableComponent.hpp @@ -8,6 +8,9 @@ #include #include "Component/Component.hpp" #include "Entity/Entity.hpp" +#include + +using namespace std::chrono_literals; namespace BBM { @@ -33,6 +36,8 @@ namespace BBM bool bomb = false; //! @brief input value for pause bool pause = false; + //! @brief The speed applied to every controllable entities. + float speed = .25f; //! @brief The layout used for this controllable. Layout layout = NONE; diff --git a/sources/Component/Health/HealthComponent.cpp b/sources/Component/Health/HealthComponent.cpp index 8901ab31..9063520b 100644 --- a/sources/Component/Health/HealthComponent.cpp +++ b/sources/Component/Health/HealthComponent.cpp @@ -10,7 +10,7 @@ namespace BBM { - HealthComponent::HealthComponent(WAL::Entity &entity, unsigned int healthPoint, const WAL::Callback &onDeath) + HealthComponent::HealthComponent(WAL::Entity &entity, unsigned int healthPoint, const WAL::Callback &onDeath) : WAL::Component(entity), _healthPoint(healthPoint), onDeath(onDeath) diff --git a/sources/Component/Health/HealthComponent.hpp b/sources/Component/Health/HealthComponent.hpp index 29c202d4..3be3c979 100644 --- a/sources/Component/Health/HealthComponent.hpp +++ b/sources/Component/Health/HealthComponent.hpp @@ -9,6 +9,7 @@ #include #include "Component/Component.hpp" #include "Entity/Entity.hpp" +#include "Wal.hpp" namespace BBM { @@ -21,7 +22,7 @@ namespace BBM public: //! @brief The callback invoked on this entity's death. - WAL::Callback onDeath; + WAL::Callback onDeath; //! @brief add health to the entity void addHealthPoint(unsigned int healthPoint); @@ -36,7 +37,7 @@ namespace BBM WAL::Component *clone(WAL::Entity &entity) const override; //! @brief Constructor - HealthComponent(WAL::Entity &entity, unsigned int healthPoint, const WAL::Callback &onDeath = WAL::Callback()); + HealthComponent(WAL::Entity &entity, unsigned int healthPoint, const WAL::Callback &onDeath = WAL::Callback()); //! @brief A Health component can't be instantiated, it should be derived. HealthComponent(const HealthComponent &) = default; diff --git a/sources/Component/IntroAnimation/IntroAnimationComponent.cpp b/sources/Component/IntroAnimation/IntroAnimationComponent.cpp new file mode 100644 index 00000000..261a168e --- /dev/null +++ b/sources/Component/IntroAnimation/IntroAnimationComponent.cpp @@ -0,0 +1,17 @@ +// +// Created by Zoe Roux on 5/24/21. +// + +#include "IntroAnimationComponent.hpp" + +namespace BBM +{ + IntroAnimationComponent::IntroAnimationComponent(WAL::Entity &entity) + : WAL::Component(entity) + {} + + WAL::Component *IntroAnimationComponent::clone(WAL::Entity &entity) const + { + return new IntroAnimationComponent(entity); + } +} \ No newline at end of file diff --git a/sources/Component/IntroAnimation/IntroAnimationComponent.hpp b/sources/Component/IntroAnimation/IntroAnimationComponent.hpp new file mode 100644 index 00000000..0def3a25 --- /dev/null +++ b/sources/Component/IntroAnimation/IntroAnimationComponent.hpp @@ -0,0 +1,39 @@ +#pragma once + +#include + +namespace BBM +{ + //! @brief A component to slowly center entities to the middle of their current block. + //! This allow flexibility in their movement will preventing them from getting stuck at every corner. + class IntroAnimationComponent : public WAL::Component + { + public: + unsigned int frameCounter = 0; + + enum animationSteps { + boxBlinking, + topLeftgrowing, + bottomRightGrowing, + lettersTyping, + fading, + prompt, + }; + + enum animationSteps currentStep = boxBlinking; + + //! @inherit + Component *clone(WAL::Entity &entity) const override; + + //! @brief Create a new, default IntroAnimationComponent. + //! @param entity The entity attached to this component. + explicit IntroAnimationComponent(WAL::Entity &entity); + //! @brief A IntroAnimationComponent is copy constructable + //! @param other The other IntroAnimationComponent to copy. + IntroAnimationComponent(const IntroAnimationComponent &other) = default; + //! @brief A default destructor + ~IntroAnimationComponent() override = default; + //! @brief A IntroAnimationComponent is not assignable + IntroAnimationComponent &operator=(const IntroAnimationComponent &) = delete; + }; +} diff --git a/sources/Component/Levitate/LevitateComponent.cpp b/sources/Component/Levitate/LevitateComponent.cpp new file mode 100644 index 00000000..1e6f3c5f --- /dev/null +++ b/sources/Component/Levitate/LevitateComponent.cpp @@ -0,0 +1,24 @@ +// +// Created by hbenjamin on 07/06/2021. +// + +#include "LevitateComponent.hpp" + +namespace BBM +{ + LevitateComponent::LevitateComponent(WAL::Entity &entity) + : WAL::Component(entity), + y() + {} + + LevitateComponent::LevitateComponent(WAL::Entity &entity, float y) + : WAL::Component(entity), + y(y) + {} + + WAL::Component *LevitateComponent::clone(WAL::Entity &entity) const + { + return new LevitateComponent(entity); + } + +} // namespace BMM \ No newline at end of file diff --git a/sources/Component/Levitate/LevitateComponent.hpp b/sources/Component/Levitate/LevitateComponent.hpp new file mode 100644 index 00000000..d2868956 --- /dev/null +++ b/sources/Component/Levitate/LevitateComponent.hpp @@ -0,0 +1,38 @@ +// +// Created by hbenjamin on 07/06/2021. +// + +#pragma once + +#include "Component/Component.hpp" +#include "Entity/Entity.hpp" +#include "Models/Vector3.hpp" + +namespace BBM { + class LevitateComponent : public WAL::Component { + public: + + //! @brief Go down or up + bool up = true; + //! @brief Original y of the entity + float y; + + //! @inherit + WAL::Component *clone(WAL::Entity &entity) const override; + + //! @brief Create a new levitate component. + explicit LevitateComponent(WAL::Entity &entity); + + //! @brief Create a new levitate component. + LevitateComponent(WAL::Entity &entity, float y); + + //! @brief A Levitate component is copy constructable. + LevitateComponent(const LevitateComponent &) = default; + + //! @brief default destructor + ~LevitateComponent() override = default; + + //! @brief A Levitate component can't be assigned + LevitateComponent &operator=(const LevitateComponent &) = delete; + }; +} \ No newline at end of file diff --git a/sources/Items/Bonus.cpp b/sources/Items/Bonus.cpp new file mode 100644 index 00000000..47a5c2ba --- /dev/null +++ b/sources/Items/Bonus.cpp @@ -0,0 +1,56 @@ +// +// Created by HENRY Benjamin on 02/06/2021. +// + +#include +#include +#include +#include "Component/Movable/MovableComponent.hpp" +#include "Bonus.hpp" +#include "Component/BombHolder/BombHolderComponent.hpp" + +namespace BBM { + void Bonus::BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) + { + if (bonus.shouldDelete() || axis != 7) + return; + auto *bombHolder = player.tryGetComponent(); + if (!bombHolder) + return; + bombHolder->maxBombCount++; + } + + void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) + { + if (bonus.shouldDelete() || axis != 7) + return; + auto *bombHolder = player.tryGetComponent(); + auto *playerBonus = player.tryGetComponent(); + if (!bombHolder || !playerBonus) + return; + if (bombHolder->explosionRadius <= 6) + bombHolder->explosionRadius++; + playerBonus->nextRangeBonusRate = playerBonus->rangeBonusRate; + } + + void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis) + { + if (bonus.shouldDelete() || axis != 7) + return; + auto *controllable = player.tryGetComponent(); + auto *playerBonus = player.tryGetComponent(); + if (!controllable || !playerBonus) + return; + controllable->speed = 0.35f; + playerBonus->nextSpeedBonusRate = playerBonus->speedBonusRate; + } + + Bonus::BonusType Bonus::getRandomBonusType() + { + double rnd = static_cast(std::rand()) / RAND_MAX; + + if (rnd < 0.8) + return (static_cast(std::rand() % (EXPLOSIONINC - 1) + 1)); + return (NOTHING); + } +} \ No newline at end of file diff --git a/sources/Items/Bonus.hpp b/sources/Items/Bonus.hpp new file mode 100644 index 00000000..6c15efd4 --- /dev/null +++ b/sources/Items/Bonus.hpp @@ -0,0 +1,42 @@ +// +// Created by HENRY Benjamin on 02/06/2021. +// Edited by AUGIER Tom on 02/06/2021. +// + +#pragma once + +#include "Entity/Entity.hpp" + +namespace BBM { + class Bonus { + public: + //! @param bonus bonus + //! @param player the entity on which the effect will be applied + //! @brief Apply bonus effect that allows players to carry one more bomb than before + static void BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis); + + //! @param bonus bonus + //! @param player the entity on which the effect will be applied + //! @brief Apply bonus effect who increased the bomb damage + static void DamageIncreasedBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis); + + //! @param bonus bonus + //! @param player the entity on which the effect will be applied + //! @brief Apply bonus effect that expend the explosion range of the bomb + static void ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis); + + //! @param bonus bonus + //! @param player the entity on which the effect will be applied + //! @brief Apply bonus effect that allows to run faster + static void SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis); + + enum BonusType { + NOTHING, + BOMBSTOCK, + SPEEDUP, + EXPLOSIONINC + }; + + static BonusType getRandomBonusType(); + }; +} \ No newline at end of file diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp index d3c53906..9bdc22ae 100644 --- a/sources/Map/Map.cpp +++ b/sources/Map/Map.cpp @@ -6,15 +6,20 @@ #include "Component/Collision/CollisionComponent.hpp" #include "System/Collision/CollisionSystem.hpp" #include "Map.hpp" +#include +#include +#include +#include #include namespace RAY3D = RAY::Drawables::Drawables3D; +using namespace std::chrono_literals; namespace BBM { - void MapGenerator::wallCollide(WAL::Entity &entity, - const WAL::Entity &wall, - CollisionComponent::CollidedAxis collidedAxis) + void MapGenerator::wallCollided(WAL::Entity &entity, + const WAL::Entity &wall, + CollisionComponent::CollidedAxis collidedAxis) { auto *mov = entity.tryGetComponent(); @@ -28,9 +33,38 @@ namespace BBM mov->_velocity.z = 0; } - void MapGenerator::wallDestroyed(WAL::Entity &entity) + void MapGenerator::wallDestroyed(WAL::Entity &entity, WAL::Wal &wal) { entity.scheduleDeletion(); + auto &position = entity.getComponent().position; + static std::map map = { + {Bonus::BonusType::BOMBSTOCK, "assets/items/bombup"}, + {Bonus::BonusType::SPEEDUP, "assets/items/speedup"}, + {Bonus::BonusType::EXPLOSIONINC, "assets/items/fireup"} + }; + static std::vector> func = { + &Bonus::BombUpBonus, &Bonus::SpeedUpBonus, &Bonus::ExplosionRangeBonus + }; + auto bonusType = Bonus::getRandomBonusType(); + + if (bonusType == Bonus::BonusType::NOTHING) + return; + if (!map.contains(bonusType)) + return; + wal.getScene()->scheduleNewEntity("Bonus") + .addComponent(position) + .addComponent(1, [](WAL::Entity &entity, WAL::Wal &wal) { + entity.scheduleDeletion(); + }) + .addComponent(position.y) + .addComponent([](WAL::Entity &bonus, const WAL::Entity &player, CollisionComponent::CollidedAxis axis) { + bonus.scheduleDeletion(); + }, func[bonusType - 1], 0.5, .5) + .addComponent(5s, [](WAL::Entity &bonus, WAL::Wal &wal){ + bonus.scheduleDeletion(); + }) + .addComponent(map.at(bonusType) + ".obj", false, + std::make_pair(MAP_DIFFUSE, "assets/items/items.png")); } const std::string MapGenerator::assetsPath = "./assets/"; @@ -59,7 +93,7 @@ namespace BBM .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, 0.25, .75) + &MapGenerator::wallCollided, 0.25, .75) .addComponent(unbreakableObj, false, std::make_pair(MAP_DIFFUSE, unbreakablePng)); } @@ -72,39 +106,53 @@ namespace BBM static const std::string unbreakableObj = unbreakableWallPath + objExtension; static const std::string unbreakablePnj = unbreakableWallPath + imageExtension; + for (int i = 0; i < height; i++) { + scene->addEntity("Bomb stopper") + .addComponent(-1, 0, i) + .addComponent>(); + scene->addEntity("Bomb stopper") + .addComponent(width + 1, 0, i) + .addComponent>(); + } + for (int i = 0; i < width; i++) { + scene->addEntity("Bomb stopper") + .addComponent(i, 0, -1) + .addComponent>(); + scene->addEntity("Bomb stopper") + .addComponent(i, 0, height + 1) + .addComponent>(); + } + scene->addEntity("Bottom Wall") .addComponent(Vector3f((width + 1) / 2, 0, -1)) - .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) + &MapGenerator::wallCollided, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) .addComponent(unbreakableObj, false, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1)); scene->addEntity("Upper Wall") .addComponent(Vector3f((width + 1) / 2, 0, height + 1)) - .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) - .addComponent(unbreakableObj, false, + &MapGenerator::wallCollided, Vector3f(-(width + 1) / 2 , 0.25, 0.25), Vector3f(width + 1, 2, 0.75)) + .addComponent(unbreakableObj, false, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1)); scene->addEntity("Left Wall") .addComponent(Vector3f(width + 1, 0, height / 2)) - .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) - .addComponent(unbreakableObj, false, + &MapGenerator::wallCollided, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) + .addComponent(unbreakableObj, false, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 1)); scene->addEntity("Right Wall") .addComponent(Vector3f(-1, 0, height / 2)) .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) - .addComponent(unbreakableObj, false, + &MapGenerator::wallCollided, Vector3f(0.25, 0.25, -(height + 1) / 2 ), Vector3f(0.75, 2, height + 1)) + .addComponent(unbreakableObj, false, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 1)); } @@ -153,7 +201,7 @@ namespace BBM .addComponent(1, &MapGenerator::wallDestroyed) .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, 0.25, .75) + &MapGenerator::wallCollided, 0.25, .75) .addComponent(breakableObj, false, std::make_pair(MAP_DIFFUSE, breakablePng)); } @@ -189,7 +237,7 @@ namespace BBM .addComponent>() .addComponent( WAL::Callback(), - &MapGenerator::wallCollide, 0.25, .75) + &MapGenerator::wallCollided, 0.25, .75) .addComponent(UnbreakableObj, false, std::make_pair(MAP_DIFFUSE, UnbreakablePng)); } diff --git a/sources/Map/Map.hpp b/sources/Map/Map.hpp index f99fd550..8fb6da1c 100644 --- a/sources/Map/Map.hpp +++ b/sources/Map/Map.hpp @@ -21,6 +21,9 @@ #include "Component/Health/HealthComponent.hpp" #include "Component/Collision/CollisionComponent.hpp" #include "Component/Movable/MovableComponent.hpp" +#include + + namespace BBM { @@ -152,10 +155,10 @@ namespace BBM static const std::string secondFloorHolePath; public: - static void wallCollide(WAL::Entity &entity, - const WAL::Entity &wall, - CollisionComponent::CollidedAxis collidedAxis); - static void wallDestroyed(WAL::Entity &entity); + static void wallCollided(WAL::Entity &entity, + const WAL::Entity &wall, + CollisionComponent::CollidedAxis collidedAxis); + static void wallDestroyed(WAL::Entity &entity, WAL::Wal &wal); //! @param width Width of the map diff --git a/sources/Models/GameState.hpp b/sources/Models/GameState.hpp index 61f7f309..4bb271b5 100644 --- a/sources/Models/GameState.hpp +++ b/sources/Models/GameState.hpp @@ -18,6 +18,7 @@ namespace BBM //! @brief The list of scenes available. enum SceneID { + SplashScreen, MainMenuScene, GameScene, SettingsScene, @@ -29,10 +30,10 @@ namespace BBM //! @brief The currently loaded scene - SceneID currentScene = TitleScreenScene; + SceneID currentScene = SplashScreen; //! @brief The next scene to load (if smae as currentScene, nothing to do) - SceneID nextScene = TitleScreenScene; + SceneID nextScene = SplashScreen; //! @brief The list of loaded scenes. std::unordered_map> _loadedScenes = {}; diff --git a/sources/Runner/CreditScene.cpp b/sources/Runner/CreditScene.cpp new file mode 100644 index 00000000..d87e47be --- /dev/null +++ b/sources/Runner/CreditScene.cpp @@ -0,0 +1,72 @@ + +#include +#include +#include "Runner.hpp" +#include +#include "Component/Music/MusicComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Keyboard/KeyboardComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Button/ButtonComponent.hpp" +#include "Drawables/2D/Text.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadCreditScene() + { + auto scene = std::make_shared(); + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + + addMenuControl(*scene); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + + scene->addEntity("Control entity") + .addComponent("assets/musics/music_title.ogg") + .addComponent(sounds); + + auto &raylibLogo = scene->addEntity("raylib logo") + .addComponent(1920 / 4, 1080 / 1.75, 0) + .addComponent("assets/raylib.png"); + auto &raylibText = scene->addEntity("raylib text") + .addComponent(1920 / 4, 1080 / 2, 0) + .addComponent("Powered by:", 35, RAY::Vector2(), BLACK); + auto &otherRepoText = scene->addEntity("other repo text") + .addComponent(1920 / 4, 1080 / 4, 0) + .addComponent("Many Thanks to:", 35, RAY::Vector2(), BLACK); + auto &BriansRepo = scene->addEntity("thx brian") + .addComponent(1920 / 3.5, 1080 / 3.5, 0) + .addComponent("Brian Guitteny (and his team)", 35, RAY::Vector2(), BLACK); + auto &team = scene->addEntity("team") + .addComponent(1920 / 1.5, 1080 / 3.5, 0) + .addComponent("Team:\n Zoe Roux\n Clément Le Bihan\n Arthur Jamet\n Louis Auzuret\n Benjamin Henry\n Tom Augier", 35, RAY::Vector2(), BLACK); + auto &back = scene->addEntity("back to menu") + .addComponent(10, 1080 - 85, 0) + .addComponent("assets/buttons/button_back.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back_hovered.png"); + }); + return scene; + } + +} \ No newline at end of file diff --git a/sources/Runner/GameScene.cpp b/sources/Runner/GameScene.cpp new file mode 100644 index 00000000..dda31514 --- /dev/null +++ b/sources/Runner/GameScene.cpp @@ -0,0 +1,64 @@ +#include +#include +#include "Runner.hpp" +#include +#include "Component/Music/MusicComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Animator/AnimatorComponent.hpp" +#include "Component/Animation/AnimationsComponent.hpp" +#include "Component/Health/HealthComponent.hpp" +#include "Component/Renderer/CameraComponent.hpp" +#include "Component/Collision/CollisionComponent.hpp" +#include "Component/Movable/MovableComponent.hpp" +#include "Component/BombHolder/BombHolderComponent.hpp" +#include "Component/Shaders/ShaderComponent.hpp" +#include "Component/Tag/TagComponent.hpp" +#include "Component/Renderer/Drawable3DComponent.hpp" +#include "Drawables/2D/Text.hpp" +#include "Model/Model.hpp" +#include "Map/Map.hpp" + +namespace RAY3D = RAY::Drawables::Drawables3D; + +namespace BBM +{ + std::shared_ptr Runner::loadGameScene() + { + auto scene = std::make_shared(); + scene->addEntity("camera") + .addComponent(8, 20, 7) + .addComponent(Vector3f(8, 0, 8)); + MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); + return scene; + } + + WAL::Entity &Runner::createPlayer(WAL::Scene &scene) + { + std::map soundPath ={ + {SoundComponent::JUMP, "assets/sounds/jump.wav"}, + {SoundComponent::MOVE, "assets/sounds/move.ogg"}, + {SoundComponent::BOMB, "assets/sounds/bomb_drop.ogg"}, + //{SoundComponent::DEATH, "assets/sounds/death.ogg"} + }; + + return scene.addEntity("player") + .addComponent() + .addComponent("assets/player/player.iqm", true, std::make_pair(MAP_DIFFUSE, "assets/player/textures/blue.png")) + .addComponent() + .addComponent() + .addComponent("assets/shaders/glsl330/predator.fs") + .addComponent>() + .addComponent(RAY::ModelAnimations("assets/player/player.iqm"), 3) + .addComponent(BBM::Vector3f{0.25, 0, 0.25}, BBM::Vector3f{.75, 2, .75}) + .addComponent() + .addComponent(soundPath) + .addComponent("assets/musics/music_battle.ogg") + .addComponent() + .addComponent(1, [](WAL::Entity &entity, WAL::Wal &) { + auto &animation = entity.getComponent(); + animation.setAnimIndex(5); + }); + } +} \ No newline at end of file diff --git a/sources/Runner/LobbyScene.cpp b/sources/Runner/LobbyScene.cpp new file mode 100644 index 00000000..a133a35f --- /dev/null +++ b/sources/Runner/LobbyScene.cpp @@ -0,0 +1,158 @@ +// +// Created by Zoe Roux on 2021-06-14. +// + +#include +#include "System/Movable/MovableSystem.hpp" +#include +#include +#include +#include +#include "Component/Button/ButtonComponent.hpp" +#include "Component/Renderer/CameraComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Runner.hpp" +#include "Models/GameState.hpp" +#include +#include +#include +#include "System/Sound/PlayerSoundManagerSystem.hpp" +#include "System/Music/MusicSystem.hpp" +#include "System/Lobby/LobbySystem.hpp" +#include "Component/Lobby/LobbyComponent.hpp" + +namespace RAY3D = RAY::Drawables::Drawables3D; +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadLobbyScene() + { + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + auto scene = std::make_shared(); + + addMenuControl(*scene); + scene->addEntity("Control entity") + .addComponent("assets/musics/music_player_select.ogg") + .addComponent(sounds); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("lobby text") + .addComponent(1920 / 2.75, 100, 0) + .addComponent("Get Ready", 120, RAY::Vector2(), ORANGE); + auto &play = scene->addEntity("play button") + .addComponent(1920 / 2.5, 1080 - 180, 0) + .addComponent("assets/buttons/button_new_game.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + auto *texture = dynamic_cast(entity.getComponent().drawable.get()); + texture->use("assets/buttons/button_new_game.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + auto *texture = dynamic_cast(entity.getComponent().drawable.get()); + texture->use("assets/buttons/button_new_game_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + if (Runner::gameState.currentScene != GameState::LobbyScene + || !LobbySystem::playersAreReady(*wal.getScene())) + return; + LobbySystem::switchToGame(wal); + }) + .addComponent>(); + + + auto &back = scene->addEntity("back to menu") + .addComponent(10, 1080 - 85, 0) + .addComponent("assets/buttons/button_back.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back_hovered.png"); + }); + auto &lavaOption = scene->addEntity("lava option text") + .addComponent(1920 / 6, 2 * 1080 / 3, 0) + .addComponent("Lava: Off", 70, RAY::Vector2(), BLACK) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + + if (text->getString().find("Off") != std::string::npos) { + text->setText("Lava: On"); + //do + } else { + text->setText("Lava: Off"); + //do + } + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(ORANGE); + }); + + auto &heightOption = scene->addEntity("Height option text") + .addComponent(1920 / 1.75, 2 * 1080 / 3, 0) + .addComponent("2nd Level: Off", 70, RAY::Vector2(), BLACK) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + + if (text->getString().find("Off") != std::string::npos) { + text->setText("2nd Level: On"); + //do + } else { + text->setText("2nd Level: Off"); + //do + } + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(ORANGE); + }); + + static const std::vector colors = { BLUE, RED, GREEN, YELLOW }; + for (int i = 0; i < 4; i++) { + auto &playerTile = scene->addEntity("player tile") + .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) + .addComponent(RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3), RAY::Vector2(200, 200), colors[i]); + auto &player = scene->addEntity("player") + .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) + .addComponent("assets/player/icons/none.png"); + auto &ready = scene->addEntity("ready") + .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) + .addComponent(); + player.addComponent(i, ready); + } + scene->addEntity("camera") + .addComponent(8, 20, 7) + .addComponent(Vector3f(8, 0, 8)); + play.getComponent().setButtonLinks(&lavaOption, &back, &back, nullptr); + back.getComponent().setButtonLinks(&play, nullptr, nullptr, &play); + lavaOption.getComponent().setButtonLinks(nullptr, &play, nullptr, &heightOption); + heightOption.getComponent().setButtonLinks(nullptr, &play, &lavaOption, nullptr); + return scene; + } +} \ No newline at end of file diff --git a/sources/Runner/MainMenuScene.cpp b/sources/Runner/MainMenuScene.cpp new file mode 100644 index 00000000..42067222 --- /dev/null +++ b/sources/Runner/MainMenuScene.cpp @@ -0,0 +1,118 @@ + +#include +#include +#include "Runner.hpp" +#include +#include "Component/Music/MusicComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Keyboard/KeyboardComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Button/ButtonComponent.hpp" +#include "Drawables/2D/Text.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadMainMenuScene() + { + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + auto scene = std::make_shared(); + + addMenuControl(*scene); + scene->addEntity("Control entity") + .addComponent("assets/musics/music_title.ogg") + .addComponent(sounds); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("logo") + .addComponent(1920 / 3, 180, 0) + .addComponent("assets/logo_small.png"); + auto &play = scene->addEntity("play button") + .addComponent(1920 / 2.5, 1080 - 540, 0) + .addComponent("assets/buttons/button_new_game.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_new_game.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_new_game_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::LobbyScene; + }); + auto &settings = scene->addEntity("settings button") + .addComponent(1920 / 2.5, 1080 - 360, 0) + .addComponent("assets/buttons/button_settings.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_settings.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_settings_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::SettingsScene; + }); + auto &exit = scene->addEntity("exit button") + .addComponent(1920 / 2.5, 1080 - 180, 0) + .addComponent("assets/buttons/button_exit.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_exit.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_exit_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + wal.shouldClose = true; + }); + auto &credits = scene->addEntity("credit button") + .addComponent(1920 - 100, 1080 - 30, 0) + .addComponent("Credits", 20, RAY::Vector2(), BLACK) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + + text->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + + text->setColor(ORANGE); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + gameState.nextScene = BBM::GameState::SceneID::CreditScene; + }); + play.getComponent().setButtonLinks(nullptr, &settings); + settings.getComponent().setButtonLinks(&play, &exit); + exit.getComponent().setButtonLinks(&settings, &credits, nullptr, &credits); + credits.getComponent().setButtonLinks(&exit, nullptr, &exit); + return scene; + } +} \ No newline at end of file diff --git a/sources/Runner/PauseMenuScene.cpp b/sources/Runner/PauseMenuScene.cpp new file mode 100644 index 00000000..cf7d66c6 --- /dev/null +++ b/sources/Runner/PauseMenuScene.cpp @@ -0,0 +1,100 @@ + +#include +#include +#include "Runner.hpp" +#include +#include "Component/Music/MusicComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Keyboard/KeyboardComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Button/ButtonComponent.hpp" +#include "Drawables/2D/Text.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadPauseMenuScene() + { + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + auto scene = std::make_shared(); + + addMenuControl(*scene); + scene->addEntity("Control entity") + .addComponent("assets/musics/music_player_select.ogg") + .addComponent(sounds); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("pause text") + .addComponent(1920 / 2.5, 180, 0) + .addComponent("PAUSE", 120, RAY::Vector2(), ORANGE); + auto &play = scene->addEntity("play button") + .addComponent(1920 / 6.5, 1080 - 360, 0) + .addComponent("assets/buttons/button_back.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::GameScene; + }); + auto &settings = scene->addEntity("settings button") + .addComponent(1920 / 2.5, 1080 - 360, 0) + .addComponent("assets/buttons/button_settings.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_settings.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_settings_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::SettingsScene; + }); + auto &exit = scene->addEntity("exit button") + .addComponent(1920 / 1.5, 1080 - 360, 0) + .addComponent("assets/buttons/button_exit.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_exit.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_exit_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }); + //needed material + //music + play.getComponent().setButtonLinks(nullptr, nullptr, nullptr, &settings); + settings.getComponent().setButtonLinks(nullptr, nullptr, &play, &exit); + exit.getComponent().setButtonLinks(nullptr, nullptr, &settings, nullptr); + return scene; + } +} \ No newline at end of file diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 480193fd..98164ecf 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -6,49 +6,34 @@ #include #include "System/Movable/MovableSystem.hpp" #include "System/Renderer/RenderSystem.hpp" -#include #include -#include #include #include "System/Keyboard/KeyboardSystem.hpp" #include "System/Controllable/ControllableSystem.hpp" -#include "Component/Movable/MovableComponent.hpp" -#include "Component/Controllable/ControllableComponent.hpp" -#include "Component/Keyboard/KeyboardComponent.hpp" #include "System/Gamepad/GamepadSystem.hpp" #include -#include "Component/Button/ButtonComponent.hpp" -#include -#include "Component/Renderer/CameraComponent.hpp" -#include "Component/Renderer/Drawable3DComponent.hpp" #include "Component/Renderer/Drawable2DComponent.hpp" #include "Runner.hpp" #include "Models/GameState.hpp" -#include #include #include #include #include #include -#include #include -#include "Component/Animation/AnimationsComponent.hpp" +#include +#include +#include #include "System/Animation/AnimationsSystem.hpp" -#include "Component/Shaders/ShaderComponent.hpp" #include "Map/Map.hpp" #include "System/MenuControllable/MenuControllableSystem.hpp" -#include -#include "Component/Music/MusicComponent.hpp" -#include "Component/Sound/SoundComponent.hpp" +#include #include "System/Sound/PlayerSoundManagerSystem.hpp" #include "System/Sound/MenuSoundManagerSystem.hpp" #include "System/Music/MusicSystem.hpp" #include "System/Lobby/LobbySystem.hpp" #include "Component/Lobby/LobbyComponent.hpp" -namespace RAY3D = RAY::Drawables::Drawables3D; -namespace RAY2D = RAY::Drawables::Drawables2D; - namespace BBM { GameState Runner::gameState; @@ -58,11 +43,14 @@ namespace BBM auto &view = engine.getScene()->view(); if (RAY::Window::getInstance().shouldClose()) engine.shouldClose = true; - if (gameState.currentScene == GameState::SceneID::GameScene) { - for (auto &[_, component]: view) { - if (component.pause) { + if (gameState.currentScene == GameState::SceneID::GameScene || gameState.currentScene == GameState::SceneID::SplashScreen) { + for (auto &[_, component]: engine.getScene()->view()) { + if (component.pause && gameState.currentScene == GameState::SceneID::GameScene) { gameState.nextScene = GameState::SceneID::PauseMenuScene; break; + } else if (gameState.currentScene == GameState::SceneID::SplashScreen && component.jump) { + gameState.nextScene = GameState::SceneID::TitleScreenScene; + break; } } } @@ -85,9 +73,13 @@ namespace BBM .addSystem() .addSystem() .addSystem() + .addSystem() + .addSystem() .addSystem() + .addSystem() .addSystem() .addSystem() + .addSystem() .addSystem(); } @@ -100,631 +92,6 @@ namespace BBM .addSystem(window); } - std::shared_ptr Runner::loadTitleScreenScene() - { - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - auto scene = std::make_shared(); - addMenuControl(*scene); - scene->addEntity("control") - .addComponent(sounds) - .addComponent("assets/musics/music_title.ogg"); - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - scene->addEntity("logo") - .addComponent(320, 180, 0) - .addComponent("assets/logo_big.png"); - scene->addEntity("text_prompt") - .addComponent(1920 / 2.5, 1080 - 130, 0) - .addComponent("Press space", 70, RAY::Vector2(), BLACK) - .addComponent() - .addComponent() - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; - }); - return scene; - } - - std::shared_ptr Runner::loadMainMenuScene() - { - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - auto scene = std::make_shared(); - - addMenuControl(*scene); - scene->addEntity("Control entity") - .addComponent("assets/musics/music_title.ogg") - .addComponent(sounds); - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - scene->addEntity("logo") - .addComponent(1920 / 3, 180, 0) - .addComponent("assets/logo_small.png"); - auto &play = scene->addEntity("play button") - .addComponent(1920 / 2.5, 1080 - 540, 0) - .addComponent("assets/buttons/button_new_game.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_new_game.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_new_game_hovered.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::LobbyScene; - }); - auto &settings = scene->addEntity("settings button") - .addComponent(1920 / 2.5, 1080 - 360, 0) - .addComponent("assets/buttons/button_settings.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_settings.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_settings_hovered.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::SettingsScene; - }); - auto &exit = scene->addEntity("exit button") - .addComponent(1920 / 2.5, 1080 - 180, 0) - .addComponent("assets/buttons/button_exit.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_exit.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_exit_hovered.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - wal.shouldClose = true; - }); - auto &credits = scene->addEntity("credit button") - .addComponent(1920 - 100, 1080 - 30, 0) - .addComponent("Credits", 20, RAY::Vector2(), BLACK) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); - - text->setColor(BLACK); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); - - text->setColor(ORANGE); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - gameState.nextScene = BBM::GameState::SceneID::CreditScene; - }); - play.getComponent().setButtonLinks(nullptr, &settings); - settings.getComponent().setButtonLinks(&play, &exit); - exit.getComponent().setButtonLinks(&settings, &credits, nullptr, &credits); - credits.getComponent().setButtonLinks(&exit, nullptr, &exit); - return scene; - } - - std::shared_ptr Runner::loadLobbyScene() - { - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - auto scene = std::make_shared(); - - addMenuControl(*scene); - scene->addEntity("Control entity") - .addComponent("assets/musics/music_player_select.ogg") - .addComponent(sounds); - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - scene->addEntity("lobby text") - .addComponent(1920 / 2.75, 100, 0) - .addComponent("Get Ready", 120, RAY::Vector2(), ORANGE); - auto &play = scene->addEntity("play button") - .addComponent(1920 / 2.5, 1080 - 180, 0) - .addComponent("assets/buttons/button_new_game.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - auto *texture = dynamic_cast(entity.getComponent().drawable.get()); - texture->use("assets/buttons/button_new_game.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - auto *texture = dynamic_cast(entity.getComponent().drawable.get()); - texture->use("assets/buttons/button_new_game_hovered.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - if (Runner::gameState.currentScene != GameState::LobbyScene - || !LobbySystem::playersAreReady(*wal.getScene())) - return; - LobbySystem::switchToGame(wal); - }) - .addComponent>(); - - - auto &back = scene->addEntity("back to menu") - .addComponent(10, 1080 - 85, 0) - .addComponent("assets/buttons/button_back.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back_hovered.png"); - }); - auto &lavaOption = scene->addEntity("lava option text") - .addComponent(1920 / 6, 2 * 1080 / 3, 0) - .addComponent("Lava: Off", 70, RAY::Vector2(), BLACK) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); - - if (text->getString().find("Off") != std::string::npos) { - text->setText("Lava: On"); - //do - } else { - text->setText("Lava: Off"); - //do - } - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(BLACK); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(ORANGE); - }); - - auto &heightOption = scene->addEntity("Height option text") - .addComponent(1920 / 1.75, 2 * 1080 / 3, 0) - .addComponent("2nd Level: Off", 70, RAY::Vector2(), BLACK) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); - - if (text->getString().find("Off") != std::string::npos) { - text->setText("2nd Level: On"); - //do - } else { - text->setText("2nd Level: Off"); - //do - } - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(BLACK); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(ORANGE); - }); - - static const std::vector colors = { BLUE, RED, GREEN, YELLOW }; - for (int i = 0; i < 4; i++) { - auto &playerTile = scene->addEntity("player tile") - .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) - .addComponent(RAY::Vector2(224 * (i + 1) + 200 * i, 1080 / 3), RAY::Vector2(200, 200), colors[i]); - auto &player = scene->addEntity("player") - .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) - .addComponent("assets/player/icons/none.png"); - auto &ready = scene->addEntity("ready") - .addComponent(224 * (i + 1) + 200 * i, 1080 / 3, 0) - .addComponent(); - player.addComponent(i, ready); - } - scene->addEntity("camera") - .addComponent(8, 20, 7) - .addComponent(Vector3f(8, 0, 8)); - play.getComponent().setButtonLinks(&lavaOption, &back, &back, nullptr); - back.getComponent().setButtonLinks(&play, nullptr, nullptr, &play); - lavaOption.getComponent().setButtonLinks(nullptr, &play, nullptr, &heightOption); - heightOption.getComponent().setButtonLinks(nullptr, &play, &lavaOption, nullptr); - return scene; - } - - std::shared_ptr Runner::loadPauseMenuScene() - { - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - auto scene = std::make_shared(); - - addMenuControl(*scene); - scene->addEntity("Control entity") - .addComponent("assets/musics/music_player_select.ogg") - .addComponent(sounds); - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - scene->addEntity("pause text") - .addComponent(1920 / 2.5, 180, 0) - .addComponent("PAUSE", 120, RAY::Vector2(), ORANGE); - auto &play = scene->addEntity("play button") - .addComponent(1920 / 6.5, 1080 - 360, 0) - .addComponent("assets/buttons/button_back.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back_hovered.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::GameScene; - }); - auto &settings = scene->addEntity("settings button") - .addComponent(1920 / 2.5, 1080 - 360, 0) - .addComponent("assets/buttons/button_settings.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_settings.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_settings_hovered.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::SettingsScene; - }); - auto &exit = scene->addEntity("exit button") - .addComponent(1920 / 1.5, 1080 - 360, 0) - .addComponent("assets/buttons/button_exit.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_exit.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_exit_hovered.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - gameState._loadedScenes[GameState::SceneID::GameScene].reset(); - gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; - }); - play.getComponent().setButtonLinks(nullptr, nullptr, nullptr, &settings); - settings.getComponent().setButtonLinks(nullptr, nullptr, &play, &exit); - exit.getComponent().setButtonLinks(nullptr, nullptr, &settings, nullptr); - return scene; - } - - std::shared_ptr Runner::loadSettingsMenuScene() - { - auto scene = std::make_shared(); - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - - addMenuControl(*scene); - scene->addEntity("Control entity") - .addComponent("assets/musics/music_title.ogg") - .addComponent(sounds); - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - scene->addEntity("logo") - .addComponent(1920 / 3, 180, 0) - .addComponent("assets/logo_small.png"); - auto &music = scene->addEntity("music text") - .addComponent(1920 / 2.5, 1080 - 540, 0) - .addComponent("Music Volume", 70, RAY::Vector2(), BLACK) - .addComponent() - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(BLACK); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(ORANGE); - }); - - auto &musicUp = scene->addEntity("music up button") - .addComponent(1920 / 1.5, 1080 - 540, 0) - .addComponent("assets/buttons/button_plus.png") - .addComponent("assets/musics/music_title.ogg") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_plus.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - auto &component = entity.getComponent(); - - component.turnUpVolume(); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_plus_hovered.png"); - }); - - auto &musicDown = scene->addEntity("music down button") - .addComponent(1920 / 3, 1080 - 540, 0) - .addComponent("assets/buttons/button_minus.png") - .addComponent("assets/musics/music_title.ogg") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_minus.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - auto &component = entity.getComponent(); - - component.turnDownVolume(); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_minus_hovered.png"); - }); - - auto &sound = scene->addEntity("sound text") - .addComponent(1920 / 2.5, 1080 - 360, 0) - .addComponent("Sound Volume", 70, RAY::Vector2(), BLACK) - .addComponent() - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(BLACK); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(ORANGE); - }); - - auto &soundUp = scene->addEntity("sound up button") - .addComponent(1920 / 1.5, 1080 - 360, 0) - .addComponent("assets/buttons/button_plus.png") - .addComponent(sounds) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - auto &component = entity.getComponent(); - - component.turnUpVolume(); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_plus.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_plus_hovered.png"); - }); - - auto &soundDown = scene->addEntity("sound down button") - .addComponent(1920 / 3, 1080 - 360, 0) - .addComponent("assets/buttons/button_minus.png") - .addComponent(sounds) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_minus.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - auto &component = entity.getComponent(); - - component.turnDownVolume(); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_minus_hovered.png"); - }); - - auto &debug = scene->addEntity("debug text") - .addComponent(1920 / 2.5, 1080 - 180, 0) - .addComponent("Debug Mode: Off", 70, RAY::Vector2(), BLACK) - .addComponent([](WAL::Entity &entity, WAL::Wal &wal) - { - RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); - - if (text->getString().find("Off") != std::string::npos) { - text->setText("Debug Mode: On"); - wal.getSystem().setDebug(true); - } else { - text->setText("Debug Mode: Off"); - wal.getSystem().setDebug(false); - } - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(BLACK); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - entity.getComponent().drawable->setColor(ORANGE); - }); - - auto &back = scene->addEntity("back to menu") - .addComponent(10, 1080 - 85, 0) - .addComponent("assets/buttons/button_back.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back_hovered.png"); - }); - //needed material - //music - //sound - - music.getComponent().setButtonLinks(nullptr, &sound, &musicDown, &musicUp); - musicDown.getComponent().setButtonLinks(&debug, &sound, nullptr, &music); - musicUp.getComponent().setButtonLinks(&debug, &sound, &music); - sound.getComponent().setButtonLinks(&music, &debug, &soundDown, &soundUp); - soundDown.getComponent().setButtonLinks(&music, &debug, nullptr, &sound); - soundUp.getComponent().setButtonLinks(&music, &debug, &sound); - debug.getComponent().setButtonLinks(&sound, &back, &back); - back.getComponent().setButtonLinks(&debug, nullptr, nullptr, &debug); - return scene; - } - - std::shared_ptr Runner::loadGameScene() - { - auto scene = std::make_shared(); - scene->addEntity("camera") - .addComponent(8, 20, 7) - .addComponent(Vector3f(8, 0, 8)); - MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); - - return scene; - } - - WAL::Entity &Runner::createPlayer(WAL::Scene &scene) - { - std::map soundPath ={ - {SoundComponent::JUMP, "assets/sounds/jump.wav"}, - {SoundComponent::MOVE, "assets/sounds/move.ogg"}, - {SoundComponent::BOMB, "assets/sounds/bomb_drop.ogg"}, - //{SoundComponent::DEATH, "assets/sounds/death.ogg"} - }; - - return scene.addEntity("player") - .addComponent() - .addComponent("assets/player/player.iqm", true, std::make_pair(MAP_DIFFUSE, "assets/player/textures/blue.png")) - .addComponent() - .addComponent() - .addComponent("assets/shaders/glsl330/predator.fs") - .addComponent>() - .addComponent(RAY::ModelAnimations("assets/player/player.iqm"), 3) - .addComponent(BBM::Vector3f{0.25, 0, 0.25}, BBM::Vector3f{.75, 2, .75}) - .addComponent() - .addComponent(soundPath) - .addComponent("assets/musics/music_battle.ogg") - .addComponent() - .addComponent(1, [](WAL::Entity &entity) { - auto &animation = entity.getComponent(); - animation.setAnimIndex(5); - }); - } - - std::shared_ptr Runner::loadCreditScene() - { - auto scene = std::make_shared(); - static const std::map sounds = { - {SoundComponent::JUMP, "assets/sounds/click.ogg"} - }; - - scene->addEntity("background") - .addComponent() - .addComponent("assets/plain_menu_background.png"); - - scene->addEntity("Control entity") - .addComponent() - .addComponent() - .addComponent("assets/musics/music_title.ogg") - .addComponent(sounds); - - auto &raylibLogo = scene->addEntity("raylib logo") - .addComponent(1920 / 4, 1080 / 1.75, 0) - .addComponent("assets/raylib.png"); - auto &raylibText = scene->addEntity("raylib text") - .addComponent(1920 / 4, 1080 / 2, 0) - .addComponent("Powered by:", 35, RAY::Vector2(), BLACK); - auto &otherRepoText = scene->addEntity("other repo text") - .addComponent(1920 / 4, 1080 / 4, 0) - .addComponent("Many Thanks to:", 35, RAY::Vector2(), BLACK); - auto &BriansRepo = scene->addEntity("thx brian") - .addComponent(1920 / 3.5, 1080 / 3.5, 0) - .addComponent("Brian Guitteny (and his team)", 35, RAY::Vector2(), BLACK); - auto &team = scene->addEntity("team") - .addComponent(1920 / 1.5, 1080 / 3.5, 0) - .addComponent("Team:\n Zoe Roux\n Clément Le Bihan\n Arthur Jamet\n Louis Auzuret\n Benjamin Henry\n Tom Augier", 35, RAY::Vector2(), BLACK); - auto &back = scene->addEntity("back to menu") - .addComponent(10, 1080 - 85, 0) - .addComponent("assets/buttons/button_back.png") - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back.png"); - }) - .addComponent([](WAL::Entity &entity, WAL::Wal &) - { - RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); - - texture->use("assets/buttons/button_back_hovered.png"); - }); - return scene; - } - void Runner::addMenuControl(WAL::Scene &scene) { scene.addEntity("Keyboard default control") @@ -747,6 +114,7 @@ namespace BBM gameState._loadedScenes[GameState::SceneID::PauseMenuScene] = loadPauseMenuScene(); gameState._loadedScenes[GameState::SceneID::TitleScreenScene] = loadTitleScreenScene(); gameState._loadedScenes[GameState::SceneID::CreditScene] = loadCreditScene(); + gameState._loadedScenes[GameState::SceneID::SplashScreen] = loadSplashScreenScene(); gameState._loadedScenes[GameState::SceneID::LobbyScene] = loadLobbyScene(); } @@ -757,7 +125,7 @@ namespace BBM Runner::addSystems(wal); Runner::enableRaylib(wal); Runner::loadScenes(); - wal.changeScene(Runner::gameState._loadedScenes[GameState::SceneID::TitleScreenScene]); + wal.changeScene(Runner::gameState._loadedScenes[GameState::SceneID::SplashScreen]); try { wal.run(Runner::updateState, Runner::gameState); diff --git a/sources/Runner/Runner.hpp b/sources/Runner/Runner.hpp index b160cfc6..dd225e1e 100644 --- a/sources/Runner/Runner.hpp +++ b/sources/Runner/Runner.hpp @@ -56,6 +56,9 @@ namespace BBM //! @return A reference to the created player. static WAL::Entity &createPlayer(WAL::Scene &scene); + //! @brief load all data related to splash screen + static std::shared_ptr loadSplashScreenScene(); + //! @brief loads all scenes in the game state static void loadScenes(); }; diff --git a/sources/Runner/SettingsMenuScene.cpp b/sources/Runner/SettingsMenuScene.cpp new file mode 100644 index 00000000..8883bbeb --- /dev/null +++ b/sources/Runner/SettingsMenuScene.cpp @@ -0,0 +1,211 @@ + +#include +#include +#include "Runner.hpp" +#include +#include "Component/Music/MusicComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Keyboard/KeyboardComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Button/ButtonComponent.hpp" +#include "Drawables/2D/Text.hpp" +#include "System/Renderer/RenderSystem.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadSettingsMenuScene() + { + auto scene = std::make_shared(); + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + + addMenuControl(*scene); + scene->addEntity("Control entity") + .addComponent("assets/musics/music_title.ogg") + .addComponent(sounds); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("logo") + .addComponent(1920 / 3, 180, 0) + .addComponent("assets/logo_small.png"); + auto &music = scene->addEntity("music text") + .addComponent(1920 / 2.5, 1080 - 540, 0) + .addComponent("Music Volume", 70, RAY::Vector2(), BLACK) + .addComponent() + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(ORANGE); + }); + + auto &musicUp = scene->addEntity("music up button") + .addComponent(1920 / 1.5, 1080 - 540, 0) + .addComponent("assets/buttons/button_plus.png") + .addComponent("assets/musics/music_title.ogg") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_plus.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + auto &component = entity.getComponent(); + + component.turnUpVolume(); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_plus_hovered.png"); + }); + + auto &musicDown = scene->addEntity("music down button") + .addComponent(1920 / 3, 1080 - 540, 0) + .addComponent("assets/buttons/button_minus.png") + .addComponent("assets/musics/music_title.ogg") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_minus.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + auto &component = entity.getComponent(); + + component.turnDownVolume(); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_minus_hovered.png"); + }); + + auto &sound = scene->addEntity("sound text") + .addComponent(1920 / 2.5, 1080 - 360, 0) + .addComponent("Sound Volume", 70, RAY::Vector2(), BLACK) + .addComponent() + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(ORANGE); + }); + + auto &soundUp = scene->addEntity("sound up button") + .addComponent(1920 / 1.5, 1080 - 360, 0) + .addComponent("assets/buttons/button_plus.png") + .addComponent(sounds) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + auto &component = entity.getComponent(); + + component.turnUpVolume(); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_plus.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_plus_hovered.png"); + }); + + auto &soundDown = scene->addEntity("sound down button") + .addComponent(1920 / 3, 1080 - 360, 0) + .addComponent("assets/buttons/button_minus.png") + .addComponent(sounds) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_minus.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + auto &component = entity.getComponent(); + + component.turnDownVolume(); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_minus_hovered.png"); + }); + + auto &debug = scene->addEntity("debug text") + .addComponent(1920 / 2.5, 1080 - 180, 0) + .addComponent("Debug Mode: Off", 70, RAY::Vector2(), BLACK) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); + + if (text->getString().find("Off") != std::string::npos) { + text->setText("Debug Mode: On"); + wal.getSystem().setDebug(true); + } else { + text->setText("Debug Mode: Off"); + wal.getSystem().setDebug(false); + } + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + entity.getComponent().drawable->setColor(ORANGE); + }); + auto &back = scene->addEntity("back to menu") + .addComponent(10, 1080 - 85, 0) + .addComponent("assets/buttons/button_back.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back_hovered.png"); + }); + //needed material + //music + //sound + + music.getComponent().setButtonLinks(nullptr, &sound, &musicDown, &musicUp); + musicDown.getComponent().setButtonLinks(&debug, &sound, nullptr, &music); + musicUp.getComponent().setButtonLinks(&debug, &sound, &music); + sound.getComponent().setButtonLinks(&music, &debug, &soundDown, &soundUp); + soundDown.getComponent().setButtonLinks(&music, &debug, nullptr, &sound); + soundUp.getComponent().setButtonLinks(&music, &debug, &sound); + debug.getComponent().setButtonLinks(&sound, &back, &back); + back.getComponent().setButtonLinks(&debug, nullptr, nullptr, &debug); + return scene; + } +} \ No newline at end of file diff --git a/sources/Runner/SplashScreenScene.cpp b/sources/Runner/SplashScreenScene.cpp new file mode 100644 index 00000000..a22d20da --- /dev/null +++ b/sources/Runner/SplashScreenScene.cpp @@ -0,0 +1,36 @@ + +#include +#include +#include "Runner.hpp" +#include "Component/Music/MusicComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Keyboard/KeyboardComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Button/ButtonComponent.hpp" +#include "Drawables/2D/Text.hpp" +#include "Component/IntroAnimation/IntroAnimationComponent.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadSplashScreenScene() + { + auto scene = std::make_shared(); + + addMenuControl(*scene); + auto &splashComponent = scene->addEntity("animation component") + .addComponent(); + auto &background = scene->addEntity("background") + .addComponent(0, 0, 0) + .addComponent(RAY::Vector2(), RAY::Vector2(1920, 1080)); + auto &text = scene->addEntity("powered by text") + .addComponent(1920 / 2 - 200, 1080 / 2 - 180, 0) + .addComponent("powered by", 30, RAY::Vector2(), BLACK); + auto &skipText = scene->addEntity("Press space to skip") + .addComponent(1920 - 250, 1080 - 30, 0) + .addComponent("Press space to skip", 20, RAY::Vector2(), BLACK); + return scene; + } +} \ No newline at end of file diff --git a/sources/Runner/TitleScreenScene.cpp b/sources/Runner/TitleScreenScene.cpp new file mode 100644 index 00000000..729434f3 --- /dev/null +++ b/sources/Runner/TitleScreenScene.cpp @@ -0,0 +1,46 @@ + +#include +#include +#include "Runner.hpp" +#include +#include "Component/Music/MusicComponent.hpp" +#include "Component/Sound/SoundComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Keyboard/KeyboardComponent.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Button/ButtonComponent.hpp" +#include "Drawables/2D/Text.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + std::shared_ptr Runner::loadTitleScreenScene() + { + static const std::map sounds = { + {SoundComponent::JUMP, "assets/sounds/click.ogg"} + }; + auto scene = std::make_shared(); + addMenuControl(*scene); + scene->addEntity("control") + .addComponent(sounds) + .addComponent("assets/musics/music_title.ogg"); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("logo") + .addComponent(320, 180, 0) + .addComponent("assets/logo_big.png"); + scene->addEntity("text_prompt") + .addComponent(1920 / 2.5, 1080 - 130, 0) + .addComponent("Press space", 70, RAY::Vector2(), BLACK) + .addComponent() + .addComponent() + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }); + return scene; + } +} \ No newline at end of file diff --git a/sources/System/Bomb/BombSystem.cpp b/sources/System/Bomb/BombSystem.cpp new file mode 100644 index 00000000..6049c874 --- /dev/null +++ b/sources/System/Bomb/BombSystem.cpp @@ -0,0 +1,29 @@ +// +// Created by Zoe Roux on 6/9/21. +// + +#include +#include "BombSystem.hpp" + +namespace BBM +{ + BombSystem::BombSystem(WAL::Wal &wal) + : System(wal) + {} + + void BombSystem::onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) + { + auto &bomb = entity.get(); + if (!bomb.ignoreOwner) + return; + auto &pos = entity.get(); + for (auto &[owner, ownerPos, _] : this->_wal.getScene()->view()) { + if (owner.getUid() != bomb.ownerID) + continue; + if (pos.position != ownerPos.position.round()) { + bomb.ignoreOwner = false; + return; + } + } + } +} diff --git a/sources/System/Bomb/BombSystem.hpp b/sources/System/Bomb/BombSystem.hpp new file mode 100644 index 00000000..5cf00261 --- /dev/null +++ b/sources/System/Bomb/BombSystem.hpp @@ -0,0 +1,28 @@ +// +// Created by Zoe Roux on 6/9/21. +// + +#pragma once + +#include +#include "Component/Position/PositionComponent.hpp" +#include "Component/Bomb/BasicBombComponent.hpp" + +namespace BBM +{ + class BombSystem : public WAL::System + { + public: + //! @inherit + void onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) override; + + //! @brief Construct a new bomb system. + explicit BombSystem(WAL::Wal &wal); + //! @brief A bomb system is copy constructable + BombSystem(const BombSystem &) = default; + //! @brief A default destructor + ~BombSystem() override = default; + //! @brief A bomb system can't be assigned. + BombSystem operator=(const BombSystem &) = delete; + }; +} diff --git a/sources/System/BombHolder/BombHolderSystem.cpp b/sources/System/BombHolder/BombHolderSystem.cpp index a66e7ad9..d91c2a27 100644 --- a/sources/System/BombHolder/BombHolderSystem.cpp +++ b/sources/System/BombHolder/BombHolderSystem.cpp @@ -2,6 +2,8 @@ // Created by Zoe Roux on 5/31/21. // +#include +#include #include "Component/Timer/TimerComponent.hpp" #include "System/Event/EventSystem.hpp" #include "Component/Renderer/Drawable3DComponent.hpp" @@ -17,7 +19,18 @@ namespace RAY3D = RAY::Drawables::Drawables3D; namespace BBM { - std::chrono::nanoseconds BombHolderSystem::explosionTimer = 3s; + std::chrono::nanoseconds BombHolderSystem::explosionTimer = 2s; + + void BombHolderSystem::_bombCollide(WAL::Entity &entity, + const WAL::Entity &bomb, + CollisionComponent::CollidedAxis collidedAxis) + { + auto &bombInfo = bomb.getComponent(); + if (bombInfo.ignoreOwner && bombInfo.ownerID == entity.getUid()) + return; + return MapGenerator::wallCollided( entity, bomb, collidedAxis); + } + BombHolderSystem::BombHolderSystem(WAL::Wal &wal) : System(wal) @@ -27,6 +40,13 @@ namespace BBM { if (count <= 0) return; + wal.getScene()->scheduleNewEntity("explosion") + .addComponent(position) + .addComponent(1s, [](WAL::Entity &explosion, WAL::Wal &wal) { + explosion.scheduleDeletion(); + }) + .addComponent("assets/bombs/explosion/explosion.glb", false, + std::make_pair(MAP_DIFFUSE, "assets/bombs/explosion/blast.png")); wal.getSystem().dispatchEvent([position, count](WAL::Wal &wal) { for (auto &[entity, pos, _] : wal.getScene()->view>()) { if (pos.position.round() == position) { @@ -46,21 +66,26 @@ namespace BBM { bomb.scheduleDeletion(); auto position = bomb.getComponent().position.round(); - _dispatchExplosion(position, wal, 3); + auto explosionRadius = bomb.getComponent().explosionRadius; + _dispatchExplosion(position, wal, 3 + (explosionRadius - 3)); } - void BombHolderSystem::_spawnBomb(Vector3f position) + void BombHolderSystem::_spawnBomb(Vector3f position, BombHolderComponent &holder, unsigned id) { this->_wal.getScene()->scheduleNewEntity("Bomb") .addComponent(position.round()) + .addComponent(holder.damage, holder.explosionRadius, id) .addComponent(BombHolderSystem::explosionTimer, &BombHolderSystem::_bombExplosion) -// .addComponent(WAL::Callback(), -// &MapGenerator::wallCollide, 0.25, .75) + .addComponent(WAL::Callback(), + &BombHolderSystem::_bombCollide, 0.25, .75) .addComponent("assets/bombs/bomb.obj", false, std::make_pair(MAP_DIFFUSE, "assets/bombs/bomb_normal.png")); + holder.damage = 1; + holder.explosionRadius = 3; } - void BombHolderSystem::onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) + void BombHolderSystem::onUpdate(WAL::ViewEntity &entity, + std::chrono::nanoseconds dtime) { auto &holder = entity.get(); auto &position = entity.get(); @@ -68,7 +93,7 @@ namespace BBM if (controllable.bomb && holder.bombCount > 0) { holder.bombCount--; - this->_spawnBomb(position.position); + this->_spawnBomb(position.position, holder, entity->getUid()); } if (holder.bombCount < holder.maxBombCount) { holder.nextBombRefill -= dtime; diff --git a/sources/System/BombHolder/BombHolderSystem.hpp b/sources/System/BombHolder/BombHolderSystem.hpp index 105f9139..481d7697 100644 --- a/sources/System/BombHolder/BombHolderSystem.hpp +++ b/sources/System/BombHolder/BombHolderSystem.hpp @@ -6,6 +6,7 @@ #include #include +#include #include "Models/Vector3.hpp" #include "Component/Position/PositionComponent.hpp" #include "Component/BombHolder/BombHolderComponent.hpp" @@ -18,21 +19,23 @@ namespace BBM { private: //! @brief Spawn a bomb at the specified position. - void _spawnBomb(Vector3f position); + void _spawnBomb(Vector3f position, BombHolderComponent &holder, unsigned id); //! @brief Spawn a bomb at the specified position. static void _dispatchExplosion(Vector3f position, WAL::Wal &, int count); //! @brief The method triggered when the bomb explode. static void _bombExplosion(WAL::Entity &bomb, WAL::Wal &); + + //! @brief The method called when a player collide with a bomb. + static void _bombCollide(WAL::Entity &entity, const WAL::Entity &wall, BBM::CollisionComponent::CollidedAxis collidedAxis); public: //! @brief The explosion time of new bombs. static std::chrono::nanoseconds explosionTimer; - //! @brief The radius of the explosion. - static float explosionRadius; //! @inherit - void onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) override; + void onUpdate(WAL::ViewEntity &entity, + std::chrono::nanoseconds dtime) override; //! @brief A default constructor explicit BombHolderSystem(WAL::Wal &wal); diff --git a/sources/System/Bonus/PlayerBonusSystem.cpp b/sources/System/Bonus/PlayerBonusSystem.cpp new file mode 100644 index 00000000..69dcfc27 --- /dev/null +++ b/sources/System/Bonus/PlayerBonusSystem.cpp @@ -0,0 +1,32 @@ +// +// Created by hbenjamin on 09/06/2021. +// + +#include "PlayerBonusSystem.hpp" + +using namespace std::chrono_literals; + +namespace BBM +{ + PlayerBonusSystem::PlayerBonusSystem(WAL::Wal &wal) + : System(wal) + {} + + void PlayerBonusSystem::onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) + { + auto &controllable = entity.get(); + auto &holder = entity.get(); + auto &playerBonus = entity.get(); + + playerBonus.nextSpeedBonusRate -= dtime; + if (playerBonus.nextSpeedBonusRate <= 0ns) { + playerBonus.nextSpeedBonusRate = playerBonus.speedBonusRate; + controllable.speed = 0.25f; + } + playerBonus.nextRangeBonusRate -= dtime; + if (playerBonus.nextRangeBonusRate <= 0ns) { + playerBonus.nextRangeBonusRate = playerBonus.rangeBonusRate; + holder.explosionRadius = 3; + } + } +} \ No newline at end of file diff --git a/sources/System/Bonus/PlayerBonusSystem.hpp b/sources/System/Bonus/PlayerBonusSystem.hpp new file mode 100644 index 00000000..b454ce6e --- /dev/null +++ b/sources/System/Bonus/PlayerBonusSystem.hpp @@ -0,0 +1,34 @@ +// +// Created by hbenjamin on 09/06/2021. +// + +#pragma once + +#include "System/System.hpp" +#include "Wal.hpp" +#include "Models/Vector3.hpp" +#include "Component/Bonus/PlayerBonusComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include "Component/BombHolder/BombHolderComponent.hpp" + +namespace BBM +{ + //! @brief The system that allow one to place bombs. + class PlayerBonusSystem : public WAL::System + { + private: + public: + //! @inherit + void onUpdate(WAL::ViewEntity &entity, std::chrono::nanoseconds dtime) override; + + //! @brief A default constructor + explicit PlayerBonusSystem(WAL::Wal &wal); + //! @brief A bomb holder system is copy constructable + PlayerBonusSystem(const PlayerBonusSystem &) = default; + //! @brief A default destructor + ~PlayerBonusSystem() override = default; + //! @brief A bomb holder system is not assignable. + PlayerBonusSystem &operator=(const PlayerBonusSystem &) = delete; + }; +} + diff --git a/sources/System/Collision/CollisionSystem.cpp b/sources/System/Collision/CollisionSystem.cpp index db68e3c0..0a321133 100644 --- a/sources/System/Collision/CollisionSystem.cpp +++ b/sources/System/Collision/CollisionSystem.cpp @@ -25,6 +25,7 @@ namespace BBM void CollisionSystem::onFixedUpdate(WAL::ViewEntity &entity) { + unsigned int entityUid = entity->getUid(); auto &posA = entity.get(); auto &colA = entity.get(); Vector3f pointA = posA.position + colA.positionOffset; @@ -49,12 +50,11 @@ namespace BBM Vector3f maxAz = Vector3f::max(pointAz, pointAz + colA.bound); for (auto &[other, posB, colB] : this->getView()) { - if (other.getUid() == entity->getUid()) + if (other.getUid() == entityUid) continue; auto pointB = posB.position + colB.positionOffset; int collidedAxis = 0; - // TODO if B is also a movable we don't check with it's changing position Vector3f minB = Vector3f::min(pointB, pointB + colB.bound); Vector3f maxB = Vector3f::max(pointB, pointB + colB.bound); diff --git a/sources/System/Controllable/ControllableSystem.cpp b/sources/System/Controllable/ControllableSystem.cpp index f14c46b3..6916de9f 100644 --- a/sources/System/Controllable/ControllableSystem.cpp +++ b/sources/System/Controllable/ControllableSystem.cpp @@ -18,8 +18,8 @@ namespace BBM { auto &controllable = entity.get(); auto &movable = entity.get(); - Vector2f move = controllable.move.normalized() * ControllableSystem::speed; + Vector2f move = controllable.move.normalized() * controllable.speed; - movable.addForce(Vector3f(move.x, controllable.jump, move.y)); + movable.addForce(Vector3f(move.x, 0, move.y)); } } \ No newline at end of file diff --git a/sources/System/Controllable/ControllableSystem.hpp b/sources/System/Controllable/ControllableSystem.hpp index 25a9e837..0a0d8c21 100644 --- a/sources/System/Controllable/ControllableSystem.hpp +++ b/sources/System/Controllable/ControllableSystem.hpp @@ -9,14 +9,14 @@ #include "Component/Controllable/ControllableComponent.hpp" #include "System/System.hpp" +using namespace std::chrono_literals; + namespace BBM { //! @brief A system to handle Controllable entities. class ControllableSystem : public WAL::System { public: - //! @brief The speed applied to every controllable entities. - static constexpr const float speed = .25f; //! @inherit void onFixedUpdate(WAL::ViewEntity &entity) override; diff --git a/sources/System/Gamepad/GamepadSystem.cpp b/sources/System/Gamepad/GamepadSystem.cpp index 6e10a488..623d5edd 100644 --- a/sources/System/Gamepad/GamepadSystem.cpp +++ b/sources/System/Gamepad/GamepadSystem.cpp @@ -33,9 +33,9 @@ namespace BBM key.second = gamepad.isDown(key.first); controllable.move.x = gamepad.getAxisValue(gamepadComponent.LeftStickX) * -1; controllable.move.y = gamepad.getAxisValue(gamepadComponent.LeftStickY) * -1; - controllable.move.x -= gamepad.isDown(gamepadComponent.keyRight); - controllable.move.x += gamepad.isDown(gamepadComponent.keyLeft); - controllable.move.y += gamepad.isDown(gamepadComponent.keyUp); - controllable.move.y -= gamepad.isDown(gamepadComponent.keyDown); + controllable.move.x -= static_cast(gamepad.isDown(gamepadComponent.keyRight)); + controllable.move.x += static_cast(gamepad.isDown(gamepadComponent.keyLeft)); + controllable.move.y += static_cast(gamepad.isDown(gamepadComponent.keyUp)); + controllable.move.y -= static_cast(gamepad.isDown(gamepadComponent.keyDown)); } } \ No newline at end of file diff --git a/sources/System/Health/HealthSystem.cpp b/sources/System/Health/HealthSystem.cpp index 4419e9e1..1f9ab156 100644 --- a/sources/System/Health/HealthSystem.cpp +++ b/sources/System/Health/HealthSystem.cpp @@ -3,11 +3,12 @@ // Edited by Benjamin Henry on 2021-05-20. // -#include +#include +#include #include "HealthSystem.hpp" #include "Component/Health/HealthComponent.hpp" -#include "Component/Controllable/ControllableComponent.hpp" -#include "Entity/Entity.hpp" + +namespace RAY3D = RAY::Drawables::Drawables3D; namespace BBM { @@ -20,7 +21,7 @@ namespace BBM auto &health = entity.get(); if (health.getHealthPoint() == 0) { - health.onDeath(entity); + health.onDeath(entity, this->_wal); } } } \ No newline at end of file diff --git a/sources/System/Health/HealthSystem.hpp b/sources/System/Health/HealthSystem.hpp index f1cd2397..5f09cb1d 100644 --- a/sources/System/Health/HealthSystem.hpp +++ b/sources/System/Health/HealthSystem.hpp @@ -5,6 +5,8 @@ #pragma once +#include "Models/Vector3.hpp" +#include "Wal.hpp" #include "Component/Health/HealthComponent.hpp" #include "System/System.hpp" @@ -13,7 +15,8 @@ namespace BBM //! @brief A system to handle Health entities. class HealthSystem : public WAL::System { - public: + private: + public: //! @inherit void onFixedUpdate(WAL::ViewEntity &entity) override; diff --git a/sources/System/IntroAnimation/IntroAnimationSystem.cpp b/sources/System/IntroAnimation/IntroAnimationSystem.cpp new file mode 100644 index 00000000..887a11d8 --- /dev/null +++ b/sources/System/IntroAnimation/IntroAnimationSystem.cpp @@ -0,0 +1,103 @@ + +#include "Component/Button/ButtonComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "System/IntroAnimation/IntroAnimationSystem.hpp" +#include "Entity/Entity.hpp" +#include "Component/Renderer/Drawable2DComponent.hpp" +#include "Component/Controllable/ControllableComponent.hpp" +#include +#include +#include "Runner/Runner.hpp" +#include "Component/Music/MusicComponent.hpp" + +namespace RAY2D = RAY::Drawables::Drawables2D; + +namespace BBM +{ + IntroAnimationSystem::IntroAnimationSystem(WAL::Wal &wal) + : System(wal), wal(wal) + {} + + void IntroAnimationSystem::onFixedUpdate(WAL::ViewEntity &entity) + { + static const RAY::Vector2 logoPos(1920 / 2 - 128, 1080 / 2 - 128); + auto &component = entity.get(); + auto scene = wal.getScene(); + RAY2D::Rectangle *rectangle = nullptr; + RAY2D::Text *text = nullptr; + static auto &rayText = scene->addEntity("raylibtext Rectangle") + .addComponent(1920 / 2 - 44, 1080 / 2 + 48, 0) + .addComponent("", 50, RAY::Vector2(), BLACK); + static auto &bottomRectangle = scene->addEntity("bottom Rectangle") + .addComponent(1920 / 2 - 128, 1080 / 2 - 128, 0) + .addComponent(logoPos, RAY::Vector2(16, 16), BLACK); + static auto &leftRectangle = scene->addEntity("left Rectangle") + .addComponent(1920 / 2 - 128, 1080 / 2 - 128, 0) + .addComponent(logoPos, RAY::Vector2(16, 16), BLACK); + static auto &rightRectangle = scene->addEntity("right Rectangle") + .addComponent(1920 / 2 - 128, 1080 / 2 - 128, 0) + .addComponent(logoPos, RAY::Vector2(16, 16), BLACK); + static auto &topRectangle = scene->addEntity("top Rectangle") + .addComponent(1920 / 2 - 128, 1080 / 2 - 128, 0) + .addComponent(logoPos, RAY::Vector2(16, 16), BLACK); + static short letterCounter = 0; + + switch (component.currentStep) + { + case IntroAnimationComponent::animationSteps::boxBlinking: + if ((component.frameCounter / 15) % 2) + topRectangle.getComponent().drawable->setColor(BLACK); + else + topRectangle.getComponent().drawable->setColor(WHITE); + if (component.frameCounter >= 60) { + component.currentStep = IntroAnimationComponent::animationSteps::topLeftgrowing; + component.frameCounter = -1; + topRectangle.getComponent().drawable->setColor(BLACK); + leftRectangle.getComponent().drawable->setColor(BLACK); + } + break; + case IntroAnimationComponent::animationSteps::topLeftgrowing: + rectangle = dynamic_cast(leftRectangle.getComponent().drawable.get()); + rectangle->incrementHeight(8); + rectangle = dynamic_cast(topRectangle.getComponent().drawable.get()); + rectangle->incrementWidth(8); + if (rectangle->getWidth() >= 256) { + component.currentStep = IntroAnimationComponent::animationSteps::bottomRightGrowing; + bottomRectangle.getComponent().position = Vector3f(1920 / 2 - 128, 1080 / 2 - 128 + 240, 0); + rightRectangle.getComponent().position = Vector3f(1920 / 2 - 128 + 240, 1080 / 2 - 128, 0); + } + break; + case IntroAnimationComponent::animationSteps::bottomRightGrowing: + rectangle = dynamic_cast(bottomRectangle.getComponent().drawable.get()); + rectangle->incrementWidth(8); + rectangle = dynamic_cast(rightRectangle.getComponent().drawable.get()); + rectangle->incrementHeight(8); + if (rectangle->getHeight() >= 256) { + component.currentStep = IntroAnimationComponent::animationSteps::lettersTyping; + component.frameCounter = 0; + } + break; + case IntroAnimationComponent::animationSteps::lettersTyping: + if ((component.frameCounter / 10) % 2) { + letterCounter++; + text = dynamic_cast(rayText.getComponent().drawable.get()); + if (letterCounter == 2) { + scene->addEntity("startup sound") + .addComponent("assets/sounds/splash_sound.ogg") + .getComponent().playMusic(); + } + text->setText(std::string("raylib").substr(0, letterCounter)); + } + if (component.frameCounter == 60) + Runner::gameState.nextScene = Runner::gameState.TitleScreenScene; + break; + default: + break; + } + component.frameCounter++; + } + + void IntroAnimationSystem::onSelfUpdate(void) + { + } +} \ No newline at end of file diff --git a/sources/System/IntroAnimation/IntroAnimationSystem.hpp b/sources/System/IntroAnimation/IntroAnimationSystem.hpp new file mode 100644 index 00000000..1a266443 --- /dev/null +++ b/sources/System/IntroAnimation/IntroAnimationSystem.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include "Component/IntroAnimation/IntroAnimationComponent.hpp" +#include "System/System.hpp" + +namespace BBM +{ + //! @brief A system to handle Controllable entities in a menu. + class IntroAnimationSystem : public WAL::System + { + private: + //! @brief reference to wal + WAL::Wal &wal; + + public: + //! @inherit + void onSelfUpdate(void) override; + + //! @inherit + void onFixedUpdate(WAL::ViewEntity &entities) override; + + //! @brief A default constructor + IntroAnimationSystem(WAL::Wal &wal); + //! @brief A IntroAnimation system is not copy constructable + IntroAnimationSystem(const IntroAnimationSystem &) = delete; + //! @brief A default destructor + ~IntroAnimationSystem() override = default; + //! @brief A IntroAnimation system is assignable. + IntroAnimationSystem &operator=(const IntroAnimationSystem &) = default; + }; +} \ No newline at end of file diff --git a/sources/System/Levitate/LevitateSystem.cpp b/sources/System/Levitate/LevitateSystem.cpp new file mode 100644 index 00000000..61e91379 --- /dev/null +++ b/sources/System/Levitate/LevitateSystem.cpp @@ -0,0 +1,29 @@ +// +// Created by hbenjamin on 07/06/2021. +// + +#include "LevitateSystem.hpp" + +namespace BBM { + LevitateSystem::LevitateSystem(WAL::Wal &wal) + : System(wal) + {} + + void LevitateSystem::onFixedUpdate(WAL::ViewEntity &entity) { + auto &levitate = entity.get(); + auto &position = entity.get(); + float &y = position.position.y; + + if (levitate.up) { + if (y < levitate.y + 0.1f) + y += 0.004f; + else + levitate.up = false; + return; + } + if (y > levitate.y - 0.1f) + y -= 0.004f; + else + levitate.up = true; + } +} \ No newline at end of file diff --git a/sources/System/Levitate/LevitateSystem.hpp b/sources/System/Levitate/LevitateSystem.hpp new file mode 100644 index 00000000..a11b59e0 --- /dev/null +++ b/sources/System/Levitate/LevitateSystem.hpp @@ -0,0 +1,29 @@ +// +// Created by hbenjamin on 07/06/2021. +// + +#pragma once + +#include "Component/Levitate/LevitateComponent.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Wal.hpp" +#include "System/System.hpp" + +namespace BBM { + class LevitateSystem : public WAL::System + { + private: + public: + //! @inherit + void onFixedUpdate(WAL::ViewEntity &entity) override; + + //! @brief A default constructor + LevitateSystem(WAL::Wal &wal); + //! @brief A Levitate system is copy constructable + LevitateSystem(const LevitateSystem &) = default; + //! @brief A default destructor + ~LevitateSystem() override = default; + //! @brief A Levitate system is assignable. + LevitateSystem &operator=(const LevitateSystem &) = default; + }; +} \ No newline at end of file diff --git a/tests/CollisionTest.cpp b/tests/CollisionTest.cpp index 1aeb43b3..bf5a31dc 100644 --- a/tests/CollisionTest.cpp +++ b/tests/CollisionTest.cpp @@ -1,4 +1,4 @@ -// + // Created by Louis Auzuret on 5/31/21. // @@ -61,7 +61,7 @@ TEST_CASE("Collision test", "[Component][System]") } -TEST_CASE("Collsion test with movable", "[Component][System]") +TEST_CASE("Collision test with movable", "[Component][System]") { Wal wal; CollisionSystem collision(wal); @@ -99,6 +99,100 @@ TEST_CASE("Collsion test with movable", "[Component][System]") REQUIRE(entity.getComponent().position.z == 0.0); } + +TEST_CASE("Collision test callbacks calls", "[Component][System]") +{ + int nbCallbacksCalled = 0; + Wal wal; + CollisionSystem collision(wal); + MovableSystem movable(wal); + + wal.changeScene(std::make_shared()); + + wal.getScene()->addEntity("player") + .addComponent() + .addComponent( + [&nbCallbacksCalled](Entity &actual, const Entity &, int) { nbCallbacksCalled++; }, + [&nbCallbacksCalled](Entity &actual, const Entity &, int) { nbCallbacksCalled++; }, 0, 5.0) + .addComponent(); + + wal.getScene()->addEntity("block") + .addComponent(0, 0, 0) + .addComponent( + [&nbCallbacksCalled](Entity &actual, const Entity &, int) { nbCallbacksCalled++; }, + [&nbCallbacksCalled](Entity &actual, const Entity &, int) { + nbCallbacksCalled++; + try { + auto &mov = actual.getComponent(); + mov._velocity = Vector3f(); + } catch (std::exception &e) {}; + }, 0, 1); + Entity &entity = wal.getScene()->getEntities().front(); + REQUIRE(entity.getComponent().position == Vector3f()); + + entity.getComponent().bound.x = 5; + entity.getComponent().bound.y = 5; + entity.getComponent().bound.z = 5; + + entity.getComponent().addForce({1, 1, 1}); + collision.update(std::chrono::nanoseconds(1)); + collision.fixedUpdate(); + movable.update(std::chrono::nanoseconds(1)); + movable.fixedUpdate(); + REQUIRE(nbCallbacksCalled == 4); + REQUIRE(entity.getComponent().position.x == 0.0); + REQUIRE(entity.getComponent().position.y == 0.0); + REQUIRE(entity.getComponent().position.z == 0.0); +} + +TEST_CASE("Collision test callbacks args", "[Component][System]") +{ + int nbCallbacksCalled = 0; + Wal wal; + CollisionSystem collision(wal); + MovableSystem movable(wal); + + wal.changeScene(std::make_shared()); + + wal.getScene()->addEntity("player") + .addComponent() + .addComponent( + [&nbCallbacksCalled](Entity &actual, const Entity &other, int) { + nbCallbacksCalled++; + REQUIRE(actual.getName() == "player"); + REQUIRE(other.getName() == "block"); + }, + [&nbCallbacksCalled](Entity &actual, const Entity &other, int) { + nbCallbacksCalled++; + REQUIRE(other.getName() == "player"); + REQUIRE(actual.getName() == "block"); + }, 0, 5.0); + + wal.getScene()->addEntity("block") + .addComponent(0, 0, 0) + .addComponent( + [&nbCallbacksCalled](Entity &actual, const Entity &other, int) { + nbCallbacksCalled++; + REQUIRE(other.getName() == "player"); + REQUIRE(actual.getName() == "block"); + }, + [&nbCallbacksCalled](Entity &actual, const Entity &other, int) { + nbCallbacksCalled++; + REQUIRE(actual.getName() == "player"); + REQUIRE(other.getName() == "block"); + }, 0, 1); + Entity &entity = wal.getScene()->getEntities().front(); + REQUIRE(entity.getComponent().position == Vector3f()); + + entity.getComponent().bound.x = 5; + entity.getComponent().bound.y = 5; + entity.getComponent().bound.z = 5; + + collision.update(std::chrono::nanoseconds(1)); + collision.fixedUpdate(); + REQUIRE(nbCallbacksCalled == 4); +} + TEST_CASE("Vector round", "[Vector]") { Vector3f v(1.3, 1.5, 1.7);