diff options
| author | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 13:40:20 +0100 | 
|---|---|---|
| committer | JAROWMR <jarorutjes07@gmail.com> | 2025-01-08 13:40:20 +0100 | 
| commit | aa8bf26452157f81f72b6d6759e461ff2ca24568 (patch) | |
| tree | c8b69948708410dac3282ab5d3e7f9cde4cce22f | |
| parent | c001bfe4e82cecc880700b6f2a434371d818a473 (diff) | |
updated preview and added credits button
| -rw-r--r-- | game/hud/SpeedScript.cpp | 2 | ||||
| -rw-r--r-- | game/hud/SpeedScript.h | 2 | ||||
| -rw-r--r-- | game/menus/mainmenu/CreditsSubScene.cpp | 68 | ||||
| -rw-r--r-- | game/menus/mainmenu/CreditsSubScene.h | 9 | ||||
| -rw-r--r-- | game/menus/mainmenu/CreditsSubScript.cpp | 46 | ||||
| -rw-r--r-- | game/menus/mainmenu/CreditsSubScript.h | 14 | ||||
| -rw-r--r-- | game/menus/mainmenu/MainMenuScene.cpp | 15 | 
7 files changed, 154 insertions, 2 deletions
| diff --git a/game/hud/SpeedScript.cpp b/game/hud/SpeedScript.cpp index d0a4dfe..29d4193 100644 --- a/game/hud/SpeedScript.cpp +++ b/game/hud/SpeedScript.cpp @@ -26,9 +26,11 @@ void SpeedScript::init() {  void SpeedScript::fixed_update(crepe::duration_t dt) {  	LoopTimerManager & lp = this->get_loop_timer();  	if (this->get_key_state(Keycode::PAGE_UP)) { +		if(lp.get_time_scale() >= 2) return;  		lp.set_time_scale(lp.get_time_scale() + 0.1);  	}  	if (this->get_key_state(Keycode::PAGE_DOWN)) { +		if(lp.get_time_scale() <= 0.5) return;  		lp.set_time_scale(lp.get_time_scale() - 0.1);  	}  } diff --git a/game/hud/SpeedScript.h b/game/hud/SpeedScript.h index 6c15a89..b40f7cc 100644 --- a/game/hud/SpeedScript.h +++ b/game/hud/SpeedScript.h @@ -10,6 +10,6 @@ public:  private:  	crepe::SaveManager * savemgr; -	bool toggle = true; +	bool toggle = false;  	float timescale = 1;  }; diff --git a/game/menus/mainmenu/CreditsSubScene.cpp b/game/menus/mainmenu/CreditsSubScene.cpp new file mode 100644 index 0000000..9a49257 --- /dev/null +++ b/game/menus/mainmenu/CreditsSubScene.cpp @@ -0,0 +1,68 @@ + +#include "CreditsSubScene.h" +#include "CreditsSubScript.h" +#include "EndGameSubScript.h" + +#include "../../Config.h" +#include "../ButtonSubScene.h" +#include "../FloatingWindowSubScene.h" + +#include <string> + +#include <crepe/api/BehaviorScript.h> +#include <crepe/api/GameObject.h> +#include <crepe/api/Text.h> +#include <crepe/types.h> + +using namespace crepe; +using namespace std; + +void CreditsSubScene::create(Scene & scn) { + +	const std::string TAG = "end_game_tag"; +	GameObject script = scn.new_object("script"); +	script.add_component<BehaviorScript>().set_script<CreditsSubScript>(TAG); + +	// Window +	FloatingWindowSubScene window; +	window.create( +		scn, +		FloatingWindowSubScene::Data { +			.group_tag = TAG, +			.width = 500, +			.offset = {0, -50}, +			.width_middle_offset = -2, +		} +	); + +	// Titel +	const string TITEL_STRING = "Credits"; +	GameObject titel = scn.new_object("titel", TAG); +	crepe::vec2 size = {200, (200.0f / TITEL_STRING.size()) * 2}; +	titel.add_component<Text>( +		size, FONT, +		Text::Data { +			.world_space = false, +			.text_color = Color::WHITE, +		}, +		vec2 {0, -207} + FONTOFFSET, TITEL_STRING +	); + +	// Buttons +	vec2 button_position = {190, 190}; +	ButtonSubScene button; +	button.create( +		scn, +		ButtonSubScene::Data { +			.text = "Back", +			.text_width = 150, +			.position = {-button_position.x, button_position.y}, +			//.script_type = ButtonSubScene::ScriptSelect::REPLAY, +			//.button_type = ButtonSubScene::ButtonSelect::BACK, +			.scale = 0.6, +			.worldspace = false, +			.tag = TAG, +			.sorting_layer_offset = 20, +		} +	); +} diff --git a/game/menus/mainmenu/CreditsSubScene.h b/game/menus/mainmenu/CreditsSubScene.h new file mode 100644 index 0000000..e7ff735 --- /dev/null +++ b/game/menus/mainmenu/CreditsSubScene.h @@ -0,0 +1,9 @@ +#pragma once + +#include <crepe/api/Scene.h> + +class CreditsSubScene { + +public: +	void create(crepe::Scene & scn); +}; diff --git a/game/menus/mainmenu/CreditsSubScript.cpp b/game/menus/mainmenu/CreditsSubScript.cpp new file mode 100644 index 0000000..5326594 --- /dev/null +++ b/game/menus/mainmenu/CreditsSubScript.cpp @@ -0,0 +1,46 @@ +#include "CreditsSubScript.h" + +#include "../../Events.h" +#include "../IFloatingWindowScript.h" +#include "../ButtonReplaySubScript.h" + +#include <string> + +#include <crepe/api/Button.h> +#include <crepe/api/Sprite.h> +#include <crepe/api/Text.h> +#include <crepe/types.h> + +using namespace crepe; + +CreditsSubScript::CreditsSubScript(const std::string & tag) { this->tag = tag; } + +void CreditsSubScript::init() { +	this->disable_all(); +} + +bool CreditsSubScript::disable_all() { +	IFloatingWindowScript::disable_all_sprites(); +	RefVector<Button> buttons = this->get_components_by_tag<Button>(this->tag); +	for (Button & button : buttons) { +		button.active = false; +	} +	RefVector<Text> texts = this->get_components_by_tag<Text>(this->tag); +	for (Text & text : texts) { +		text.active = false; +	} +	return false; +} + +bool CreditsSubScript::enable_all() { +	IFloatingWindowScript::enable_all_sprites(); +	RefVector<Button> buttons = this->get_components_by_tag<Button>(this->tag); +	for (Button & button : buttons) { +		button.active = true; +	} +	RefVector<Text> texts = this->get_components_by_tag<Text>(this->tag); +	for (Text & text : texts) { +		text.active = true; +	} +	return false; +} diff --git a/game/menus/mainmenu/CreditsSubScript.h b/game/menus/mainmenu/CreditsSubScript.h new file mode 100644 index 0000000..08e1f91 --- /dev/null +++ b/game/menus/mainmenu/CreditsSubScript.h @@ -0,0 +1,14 @@ +#pragma once + +#include "../IFloatingWindowScript.h" + +#include <crepe/api/Event.h> +#include <crepe/api/Script.h> + +class CreditsSubScript : public IFloatingWindowScript { +public: +	CreditsSubScript(const std::string & tag); +	void init() override; +	bool disable_all(); +	bool enable_all(); +}; diff --git a/game/menus/mainmenu/MainMenuScene.cpp b/game/menus/mainmenu/MainMenuScene.cpp index 43418e3..743fe43 100644 --- a/game/menus/mainmenu/MainMenuScene.cpp +++ b/game/menus/mainmenu/MainMenuScene.cpp @@ -64,7 +64,7 @@ void MainMenuScene::load_scene() {  		ButtonSubScene::Data {  			.text = "SHOP",  			.text_offset = {-20, 0}, -			.text_width = 115, +			.text_width = 110,  			.icon_offset = {60, 0},  			.icon_type = ButtonSubScene::IconSelect::SHOP,  			.position = pos_btn, @@ -72,6 +72,19 @@ void MainMenuScene::load_scene() {  		}  	); +	//Credits btn +	pos_btn.y += MENU_BUTTON_SPACING + LARGE_OVERLAY_SIZE.y; +	button.create( +		*this, +		ButtonSubScene::Data { +			.text = "CREDITS", +			.text_offset = {0, 0}, +			.text_width = 200, +			.position = pos_btn, +			//.script_type = ButtonSubScene::ScriptSelect::SHOP, +		} +	); +  	//Start of map  	StartSubScene start;  	HallwaySubScene hallway; |