From a981a42a7378ed51155590215557e52553031272 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 10 Jan 2025 16:26:05 +0100 Subject: missile solution, cannot find @max issue --- game/PreviewScene.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'game/PreviewScene.cpp') diff --git a/game/PreviewScene.cpp b/game/PreviewScene.cpp index d9801a7..1e64e41 100644 --- a/game/PreviewScene.cpp +++ b/game/PreviewScene.cpp @@ -49,7 +49,7 @@ void PreviewScene::load_scene() { .bg_color = Color::RED, } ); - camera.add_component(Rigidbody::Data {}); + camera.add_component().set_script(); camera.add_component().set_script(); camera.add_component().set_script(); @@ -77,13 +77,16 @@ void PreviewScene::load_scene() { .collision_layer = COLL_LAY_BOT_TOP, }); ceiling.add_component(vec2(INFINITY, 200)); + GameObject world = this->new_object("world", "TAG", vec2 {0, 0}, 0, 1); - world.add_component(Rigidbody::Data { .body_type = Rigidbody::BodyType::STATIC, - .collision_layers = {0}, + .collision_layer = COLL_LAY_BOT_TOP, }); + world.add_component(vec2(100,INFINITY), vec2(VIEWPORT_X,VIEWPORT_Y)); + world.add_component(vec2(100,INFINITY), vec2(100,VIEWPORT_Y)); + PrevPlayerSubScene player(*this); NpcSubScene npc(*this); SmokeSubScene smoke(*this); @@ -111,6 +114,8 @@ void PreviewScene::load_scene() { } ); + + /* button.create( *this, ButtonSubScene::Data { @@ -158,18 +163,7 @@ void PreviewScene::load_scene() { .btn_side_color = ButtonSubScene::ButtonSideColor::ORANGE, } ); - - /* - - for (int i = 0; i < 200; ++i) { - int row = i / 10; - int col = i % 10; - float x = col * 25 + i; - float y = row * 25 - 400; - GameObject game_coin = this->new_object("coin", "coin", vec2 {x, y}, 0, 1); - Coin coin(game_coin, vec2 {0, 0}); - } - */ + */ } string PreviewScene::get_name() const { return "preview scene"; } -- cgit v1.2.3 From 00086eaffe2c9c75ebad07eb77f1cc6198104adf Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 10 Jan 2025 19:17:35 +0100 Subject: added boundaries to preview scene --- game/PreviewScene.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'game/PreviewScene.cpp') diff --git a/game/PreviewScene.cpp b/game/PreviewScene.cpp index 1e64e41..ae43225 100644 --- a/game/PreviewScene.cpp +++ b/game/PreviewScene.cpp @@ -114,8 +114,6 @@ void PreviewScene::load_scene() { } ); - - /* button.create( *this, ButtonSubScene::Data { @@ -163,7 +161,6 @@ void PreviewScene::load_scene() { .btn_side_color = ButtonSubScene::ButtonSideColor::ORANGE, } ); - */ } string PreviewScene::get_name() const { return "preview scene"; } -- cgit v1.2.3 From c17a1ac94186a2de6ad30e9228a031fb08434e52 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 10 Jan 2025 19:32:25 +0100 Subject: tiny adjustments for preview scene --- game/PreviewScene.cpp | 2 +- game/preview/NpcSubScene.cpp | 2 +- game/preview/PrevPlayerScript.cpp | 18 ++++++------------ game/preview/PrevPlayerSubScene.cpp | 4 ++-- 4 files changed, 10 insertions(+), 16 deletions(-) (limited to 'game/PreviewScene.cpp') diff --git a/game/PreviewScene.cpp b/game/PreviewScene.cpp index ae43225..1179ffc 100644 --- a/game/PreviewScene.cpp +++ b/game/PreviewScene.cpp @@ -81,7 +81,7 @@ void PreviewScene::load_scene() { GameObject world = this->new_object("world", "TAG", vec2 {0, 0}, 0, 1); world.add_component(Rigidbody::Data { .body_type = Rigidbody::BodyType::STATIC, - .collision_layer = COLL_LAY_BOT_TOP, + .collision_layer = 100, }); world.add_component(vec2(100,INFINITY), vec2(VIEWPORT_X,VIEWPORT_Y)); diff --git a/game/preview/NpcSubScene.cpp b/game/preview/NpcSubScene.cpp index a3781af..c9ab5b6 100644 --- a/game/preview/NpcSubScene.cpp +++ b/game/preview/NpcSubScene.cpp @@ -57,7 +57,7 @@ NpcSubScene::NpcSubScene(Scene & scn) { .body_type = Rigidbody::BodyType::DYNAMIC, .linear_velocity = {-50, 0}, //.max_linear_velocity = 40, - .collision_layers = {COLL_LAY_BOT_TOP, COLL_LAY_PLAYER}, + .collision_layers = {COLL_LAY_BOT_TOP, COLL_LAY_PLAYER, 100}, .collision_layer = COLL_LAY_PLAYER, }); diff --git a/game/preview/PrevPlayerScript.cpp b/game/preview/PrevPlayerScript.cpp index 2657b8d..3e6eed4 100644 --- a/game/preview/PrevPlayerScript.cpp +++ b/game/preview/PrevPlayerScript.cpp @@ -1,12 +1,11 @@ #include "PrevPlayerScript.h" #include "../missile/SpawnEvent.h" -#include "api/Transform.h" + +#include #include #include #include -#include -#include using namespace crepe; @@ -59,16 +58,16 @@ bool PrevPlayerScript::key_pressed(const KeyPressEvent & ev) { this->head_anim->set_anim(7); break; case Keycode::LEFT: - this->head->data.angle_offset -= 1; + this->get_component().rotation += 10; break; case Keycode::RIGHT: - this->head->data.angle_offset += 1; + this->get_component().rotation -= 10; break; case Keycode::UP: - this->head->data.scale_offset += 0.1; + this->head->data.position_offset += 10; break; case Keycode::DOWN: - this->head->data.scale_offset -= 0.1; + this->head->data.position_offset -= 10; break; case Keycode::P: this->get_component().play(); @@ -98,11 +97,6 @@ bool PrevPlayerScript::key_pressed(const KeyPressEvent & ev) { case Keycode::M: trigger_event(MissileSpawnEvent {}); break; - //todo - case Keycode::PAGE_UP: - case Keycode::PAGE_DOWN: - case Keycode::HOME: - break; default: break; } diff --git a/game/preview/PrevPlayerSubScene.cpp b/game/preview/PrevPlayerSubScene.cpp index 4351deb..3f5a5d5 100644 --- a/game/preview/PrevPlayerSubScene.cpp +++ b/game/preview/PrevPlayerSubScene.cpp @@ -71,10 +71,10 @@ PrevPlayerSubScene::PrevPlayerSubScene(Scene & scn) { } ); player.add_component(Rigidbody::Data { - .gravity_scale = 20, + .gravity_scale = 1, .body_type = Rigidbody::BodyType::DYNAMIC, .linear_velocity = vec2(100, 0), - .collision_layers = {COLL_LAY_BOT_TOP}, + .collision_layers = {COLL_LAY_BOT_TOP, 100}, .collision_layer = COLL_LAY_PLAYER, }); player.add_component(vec2(50, 50)); -- cgit v1.2.3 From 0b19fe5a9168368d4be0993407dd3fc3bdfa0611 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Fri, 10 Jan 2025 19:32:49 +0100 Subject: make format --- game/PreviewScene.cpp | 6 +++--- game/preview/PrevPlayerScript.cpp | 2 +- game/preview/PrevPlayerSubScene.cpp | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'game/PreviewScene.cpp') diff --git a/game/PreviewScene.cpp b/game/PreviewScene.cpp index 1179ffc..14a5560 100644 --- a/game/PreviewScene.cpp +++ b/game/PreviewScene.cpp @@ -77,15 +77,15 @@ void PreviewScene::load_scene() { .collision_layer = COLL_LAY_BOT_TOP, }); ceiling.add_component(vec2(INFINITY, 200)); - + GameObject world = this->new_object("world", "TAG", vec2 {0, 0}, 0, 1); world.add_component(Rigidbody::Data { .body_type = Rigidbody::BodyType::STATIC, .collision_layer = 100, }); - world.add_component(vec2(100,INFINITY), vec2(VIEWPORT_X,VIEWPORT_Y)); - world.add_component(vec2(100,INFINITY), vec2(100,VIEWPORT_Y)); + world.add_component(vec2(100, INFINITY), vec2(VIEWPORT_X, VIEWPORT_Y)); + world.add_component(vec2(100, INFINITY), vec2(100, VIEWPORT_Y)); PrevPlayerSubScene player(*this); NpcSubScene npc(*this); diff --git a/game/preview/PrevPlayerScript.cpp b/game/preview/PrevPlayerScript.cpp index 3e6eed4..fce5c5a 100644 --- a/game/preview/PrevPlayerScript.cpp +++ b/game/preview/PrevPlayerScript.cpp @@ -2,9 +2,9 @@ #include "../missile/SpawnEvent.h" -#include #include #include +#include #include using namespace crepe; diff --git a/game/preview/PrevPlayerSubScene.cpp b/game/preview/PrevPlayerSubScene.cpp index 3f5a5d5..9ff111c 100644 --- a/game/preview/PrevPlayerSubScene.cpp +++ b/game/preview/PrevPlayerSubScene.cpp @@ -17,8 +17,7 @@ using namespace crepe; PrevPlayerSubScene::PrevPlayerSubScene(Scene & scn) { - GameObject player - = scn.new_object("player", "player", vec2 {800 , -100}, 0, 1); + GameObject player = scn.new_object("player", "player", vec2 {800, -100}, 0, 1); Asset player_body_asset {"asset/barry/defaultBody.png"}; Sprite & player_body_sprite = player.add_component( player_body_asset, -- cgit v1.2.3