diff options
Diffstat (limited to 'game/GameScene.cpp')
-rw-r--r-- | game/GameScene.cpp | 71 |
1 files changed, 69 insertions, 2 deletions
diff --git a/game/GameScene.cpp b/game/GameScene.cpp index 2511567..bd12d50 100644 --- a/game/GameScene.cpp +++ b/game/GameScene.cpp @@ -1,10 +1,16 @@ #include "GameScene.h" #include "Config.h" #include "MoveCameraManualyScript.h" -#include "PlayerSubScene.h" #include "StartGameScript.h" +#include "coins/CoinSubScene.h" +#include "coins/CoinPool.h" +#include "coins/CoinSystemScript.h" #include "background/BackgroundSubScene.h" +#include "hud/HudScript.h" +#include "hud/HudSubScene.h" +#include "hud/SpeedScript.h" +#include "player/PlayerSubScene.h" #include <cmath> #include <crepe/api/Animator.h> @@ -36,7 +42,11 @@ void GameScene::load_scene() { } ); camera.add_component<BehaviorScript>().set_script<MoveCameraManualyScript>(); - camera.add_component<Rigidbody>(Rigidbody::Data {}); + camera.add_component<BehaviorScript>().set_script<CoinSystemScript>(); + camera.add_component<BehaviorScript>().set_script<HudScript>(); + camera.add_component<BehaviorScript>().set_script<SpeedScript>(); + + camera.add_component<Rigidbody>(Rigidbody::Data{}); PlayerSubScene player(*this); @@ -66,6 +76,63 @@ void GameScene::load_scene() { GameObject start_game_script = new_object("start_game_script", "script", vec2(0, 0)); start_game_script.add_component<BehaviorScript>().set_script<StartGameScript>(); + + //create coin pool + CoinPool coin_system; + coin_system.create_coins(*this); + + HudSubScene hud; + hud.create(*this); + + // zapper, laser and missile (below) for testing purpose only!!! + GameObject zapper = new_object("zapper", "zapper", vec2(1000, 0)); + Asset zapper_asset {"asset/obstacles/zapper/regular_zappers/zapEffect.png"}; + Sprite & zapper_sprite = zapper.add_component<Sprite>( + zapper_asset, + Sprite::Data { + .sorting_in_layer = SORT_IN_LAY_OBSTACLES, + .order_in_layer = 0, + .size = vec2(100, 100), + } + ); + zapper.add_component<Rigidbody>(Rigidbody::Data { + .body_type = Rigidbody::BodyType::KINEMATIC, + .kinematic_collision = false, + .collision_layer = COLL_LAY_ZAPPER, + }); + zapper.add_component<BoxCollider>(vec2(100, 100)); + GameObject laser = new_object("laser", "laser", vec2(2000, 0)); + Asset laser_asset {"asset/obstacles/laser/laserPower.png"}; + Sprite & laser_sprite = laser.add_component<Sprite>( + laser_asset, + Sprite::Data { + .sorting_in_layer = SORT_IN_LAY_OBSTACLES, + .order_in_layer = 0, + .size = vec2(100, 100), + } + ); + laser.add_component<Rigidbody>(Rigidbody::Data { + .body_type = Rigidbody::BodyType::KINEMATIC, + .kinematic_collision = false, + .collision_layer = COLL_LAY_LASER, + }); + laser.add_component<BoxCollider>(vec2(100, 100)); + GameObject missile = new_object("missile", "missile", vec2(4000, 0)); + Asset missile_asset {"asset/obstacles/missile/missile.png"}; + Sprite & missile_sprite = missile.add_component<Sprite>( + missile_asset, + Sprite::Data { + .sorting_in_layer = SORT_IN_LAY_OBSTACLES, + .order_in_layer = 0, + .size = vec2(100, 100), + } + ); + missile.add_component<Rigidbody>(Rigidbody::Data { + .body_type = Rigidbody::BodyType::KINEMATIC, + .kinematic_collision = false, + .collision_layer = COLL_LAY_MISSILE, + }); + missile.add_component<BoxCollider>(vec2(100, 100)); } string GameScene::get_name() const { return "scene1"; } |