diff --git a/CRogue/data/assets/textures/gui/keyboard/A.png b/CRogue/data/assets/textures/gui/keyboard/A.png deleted file mode 100644 index 573d08c..0000000 Binary files a/CRogue/data/assets/textures/gui/keyboard/A.png and /dev/null differ diff --git a/CRogue/data/assets/textures/gui/keyboard/D.png b/CRogue/data/assets/textures/gui/keyboard/D.png deleted file mode 100644 index 7980bdc..0000000 Binary files a/CRogue/data/assets/textures/gui/keyboard/D.png and /dev/null differ diff --git a/CRogue/data/assets/textures/gui/keyboard/ESC.png b/CRogue/data/assets/textures/gui/keyboard/ESC.png new file mode 100644 index 0000000..eb9ffad Binary files /dev/null and b/CRogue/data/assets/textures/gui/keyboard/ESC.png differ diff --git a/CRogue/data/assets/textures/gui/keyboard/H.png b/CRogue/data/assets/textures/gui/keyboard/H.png new file mode 100644 index 0000000..a0641cf Binary files /dev/null and b/CRogue/data/assets/textures/gui/keyboard/H.png differ diff --git a/CRogue/data/assets/textures/gui/keyboard/S.png b/CRogue/data/assets/textures/gui/keyboard/S.png deleted file mode 100644 index d7969cd..0000000 Binary files a/CRogue/data/assets/textures/gui/keyboard/S.png and /dev/null differ diff --git a/CRogue/data/assets/textures/gui/keyboard/TAB.png b/CRogue/data/assets/textures/gui/keyboard/TAB.png new file mode 100644 index 0000000..a52eec6 Binary files /dev/null and b/CRogue/data/assets/textures/gui/keyboard/TAB.png differ diff --git a/CRogue/data/assets/textures/gui/keyboard/W.png b/CRogue/data/assets/textures/gui/keyboard/W.png deleted file mode 100644 index 9c6fcee..0000000 Binary files a/CRogue/data/assets/textures/gui/keyboard/W.png and /dev/null differ diff --git a/CRogue/data/assets/textures/gui/keyboard/WASD.png b/CRogue/data/assets/textures/gui/keyboard/WASD.png new file mode 100644 index 0000000..a80512b Binary files /dev/null and b/CRogue/data/assets/textures/gui/keyboard/WASD.png differ diff --git a/CRogue/data/lvds/ld1.lvd b/CRogue/data/lvds/ld1.lvd index 442ce8f..5804d13 100644 --- a/CRogue/data/lvds/ld1.lvd +++ b/CRogue/data/lvds/ld1.lvd @@ -18,8 +18,8 @@ #2 #0 #0 &7 #0 #0 #0 #0 #0 #3 00 #2 O1 O5 O5 O5 O5 O5 O5 O3 #3 00 #2 #0 #0 #0 #0 #0 #0 #3 #2 O7 O0 O0 O0 O0 O0 O0 &A #3 00 #2 O1 O5 O5 O5 O5 O3 #3 -#2 O7 O0 O0 O0 O0 O0 O0 O8 #0 #0 #0 O7 O0 O0 O0 O0 O8 #3 -#2 O7 O0 O0 &0 O0 O0 O0 O0 O5 O5 O5 O0 O0 O0 O0 O0 O8 #3 +#2 O7 O0 O0 O0 O0 &0 O0 O8 #0 #0 #0 O7 O0 O0 O0 O0 O8 #3 +#2 O7 O0 O0 O0 O0 O0 O0 O0 O5 O5 O5 O0 O0 O0 O0 O0 O8 #3 #2 &9 O0 O0 O0 O0 O0 O0 O0 O6 O6 O6 O0 O0 O0 &1 O0 O8 #3 #2 O7 O0 O0 O0 O0 O0 O0 O8 #6 #1 #7 O7 O0 O0 O0 O0 O8 #3 #2 O7 O0 O0 O0 O0 O0 O0 &A #3 00 #2 O2 O6 O0 O0 O6 O4 #3 diff --git a/CRogue/data/lvds/ld3.lvd b/CRogue/data/lvds/ld3.lvd index a22a184..cde9d47 100644 --- a/CRogue/data/lvds/ld3.lvd +++ b/CRogue/data/lvds/ld3.lvd @@ -46,7 +46,7 @@ #2 O2 O6 O6 O6 O6 O6 O6 O6 O6 O6 O6 O4 #6 #1 #7 O7 O0 O0 &3 O0 O8 #6 #1 #7 O2 O6 O6 O6 O6 O6 O6 O6 O6 O6 O6 O4 #3 #4 #1 #1 #1 #1 #1 #1 #1 #1 #1 #1 #1 #1 #5 00 #2 O2 O6 O0 O0 O6 O4 #3 00 #4 #1 #1 #1 #1 #1 #1 #1 #1 #1 #1 #1 #1 #5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 #4 #1 #7 O7 O8 #6 #1 #5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 -00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 #2 O7 O8 #3 +00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 #2 &6 O8 #3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 #2 #0 #0 O7 O8 &8 #0 #3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 #2 O1 O5 O0 O0 O5 O3 #3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 #2 O7 O0 O0 O0 O0 O8 #3 diff --git a/CRogue/src/Scene/LevelScene.cpp b/CRogue/src/Scene/LevelScene.cpp index 9c60178..a7fcd14 100644 --- a/CRogue/src/Scene/LevelScene.cpp +++ b/CRogue/src/Scene/LevelScene.cpp @@ -211,7 +211,7 @@ void LevelScene::updateGUIHealth(int health) { GUIHealth[i]->setTexture(Assets::heart_empty); int half = health % 2; - if (half != 0 && health > 0) + if (half > 0) GUIHealth[whole]->setTexture(Assets::heart_half); playerHealth = health; diff --git a/CRogue/src/Scene/SceneManager.cpp b/CRogue/src/Scene/SceneManager.cpp index 75f1162..73b8c00 100644 --- a/CRogue/src/Scene/SceneManager.cpp +++ b/CRogue/src/Scene/SceneManager.cpp @@ -4,6 +4,7 @@ #include "MenuScene.h" #include "PauseMenu.h" #include "StatsScene.h" +#include "TutorialScene.h" #include Scene* SceneManager::mainScene = nullptr; @@ -15,7 +16,7 @@ bool SceneManager::gamePaused = true; void SceneManager::init() { currentLevel = 1; - auxScene = new LevelScene(currentLevel, 0.15f, 0, 0, 0, 0, 0); + auxScene = new LevelScene(currentLevel, 0.15f, 0, 0, 0, 1, 0); loadScene(auxScene); mainScene = new MenuScene(); loadScene(mainScene); @@ -94,6 +95,18 @@ void SceneManager::showStats() { } +void SceneManager::showTutorial() { + + if (gamePaused) + mainScene = new TutorialScene(); + else + mainScene = new MenuScene(); + + loadScene(mainScene); + gamePaused = !gamePaused; + +} + void SceneManager::update(Vector2f mousePosition) { if (loadingNextLevel) { loadNextLevel(); diff --git a/CRogue/src/Scene/SceneManager.h b/CRogue/src/Scene/SceneManager.h index 3b20c65..45df50b 100644 --- a/CRogue/src/Scene/SceneManager.h +++ b/CRogue/src/Scene/SceneManager.h @@ -23,6 +23,7 @@ class SceneManager { static void quitGame(); static void pauseGame(); static void showStats(); + static void showTutorial(); static void update(Vector2f mousePosition); static void draw(RWindow* render); static Scene* getCurrentScene(); diff --git a/CRogue/src/Scene/TutorialScene.cpp b/CRogue/src/Scene/TutorialScene.cpp new file mode 100644 index 0000000..35719f6 --- /dev/null +++ b/CRogue/src/Scene/TutorialScene.cpp @@ -0,0 +1,39 @@ +#include "TutorialScene.h" + +#include +#include +#include + +TutorialScene::TutorialScene() : Scene() { + + GUIPanel = Panel(Vector2f(0, 0), Color(200, 180, 190, 50)); + +} + +void TutorialScene::update(Vector2f mousePosition) { + GUIPanel.update(mousePosition); +} + +void TutorialScene::loadScene() { + + GUIPanel.addComponent(new Label(Vector2f(400, 80), "CONTROLES", 30, false, true)); + + GUIPanel.addComponent(new AnimatedSpriteImage(Animation(0.6f, Assets::WASD), Vector2f(100, 200), Vector2f(2, 2), Vector2f(31.5f, 21))); + GUIPanel.addComponent(new AnimatedSpriteImage(Animation(0.6f, Assets::playerRun), Vector2f(100, 320), Vector2f(4, 4), Vector2f(12, 12))); + + GUIPanel.addComponent(new AnimatedSpriteImage(Animation(0.6f, Assets::H), Vector2f(300, 200), Vector2f(2, 2), Vector2f(9.5f, 0))); + GUIPanel.addComponent(new AnimatedSpriteImage(Animation(0.6f, Assets::playerHeal), Vector2f(300, 320), Vector2f(4, 4), Vector2f(12, 12))); + + GUIPanel.addComponent(new AnimatedSpriteImage(Animation(0.6f, Assets::TAB), Vector2f(500, 200), Vector2f(2, 2), Vector2f(16.5f, 0))); + GUIPanel.addComponent(new Label(Vector2f(500, 320), "Inventario", 16, false, true, true)); + + GUIPanel.addComponent(new AnimatedSpriteImage(Animation(0.6f, Assets::ESC), Vector2f(700, 200), Vector2f(2, 2), Vector2f(20.5f, 0))); + GUIPanel.addComponent(new Label(Vector2f(700, 320), "Pausa", 16, false, true, true)); + + GUIPanel.addComponent(new Label(Vector2f(400, 430), "Click izquierdo para atacar", 16, false, true, true)); + + Button* backButton = new Button(Vector2f(400, 520), "Volver", 20); + backButton->setCallback(&SceneManager::showTutorial); + GUIPanel.addComponent(backButton); + +} diff --git a/CRogue/src/Scene/TutorialScene.h b/CRogue/src/Scene/TutorialScene.h new file mode 100644 index 0000000..a3979e7 --- /dev/null +++ b/CRogue/src/Scene/TutorialScene.h @@ -0,0 +1,11 @@ +#pragma once + +#include "Scene.h" + +class TutorialScene : public Scene { +public: + TutorialScene(); + void update(Vector2f mousePosition) override; + void loadScene() override; +}; + diff --git a/CRogue/src/UI/AnimatedSpriteImage.cpp b/CRogue/src/UI/AnimatedSpriteImage.cpp new file mode 100644 index 0000000..299d48a --- /dev/null +++ b/CRogue/src/UI/AnimatedSpriteImage.cpp @@ -0,0 +1,29 @@ +#include "AnimatedSpriteImage.h" + +AnimatedSpriteImage::AnimatedSpriteImage(Animation anim, Vector2f pos, Vector2f scale, Vector2f origin) { + animation = anim; + sprite.setPosition(pos); + sprite.setScale(scale); + sprite.setOrigin(origin); +} + +void AnimatedSpriteImage::update(Vector2f mousePosition, Vector2f panelPosition) { + animation.play(); + sprite.setTexture(*animation.getFrame()); +} + +void AnimatedSpriteImage::draw(RWindow* render) { + render->draw(sprite); +} + +void AnimatedSpriteImage::setPosition(Vector2f position) { + sprite.setPosition(position); +} + +Vector2f AnimatedSpriteImage::getPosition() { + return sprite.getPosition(); +} + +void AnimatedSpriteImage::move(Vector2f delta) { + sprite.move(delta); +} diff --git a/CRogue/src/UI/AnimatedSpriteImage.h b/CRogue/src/UI/AnimatedSpriteImage.h new file mode 100644 index 0000000..d705235 --- /dev/null +++ b/CRogue/src/UI/AnimatedSpriteImage.h @@ -0,0 +1,18 @@ +#pragma once + +#include "UIComponent.h" +#include + +class AnimatedSpriteImage : public UIComponent { +public: + AnimatedSpriteImage(Animation anim, Vector2f pos, Vector2f scale, Vector2f origin); + void update(Vector2f mousePosition, Vector2f panelPosition); + void draw(RWindow* render); + void setPosition(Vector2f position); + Vector2f getPosition(); + void move(Vector2f delta); +private: + Sprite sprite; + Animation animation; +}; + diff --git a/CRogue/src/UI/RWindow.cpp b/CRogue/src/UI/RWindow.cpp index b2396c3..6ff7d49 100644 --- a/CRogue/src/UI/RWindow.cpp +++ b/CRogue/src/UI/RWindow.cpp @@ -28,7 +28,7 @@ void RWindow::setMousePosition(Vector2f pos) { void RWindow::setSwordCursor() { Cursor cursor; - if (cursor.loadFromPixels(Assets::mouse.getPixelsPtr(), { 20,20 }, { 0,0 })) + if (cursor.loadFromPixels(Assets::mouse->copyToImage().getPixelsPtr(), { 20,20 }, { 0,0 })) setMouseCursor(cursor); } diff --git a/CRogue/src/assets/Assets.cpp b/CRogue/src/assets/Assets.cpp index 2dbb080..e5e545a 100644 --- a/CRogue/src/assets/Assets.cpp +++ b/CRogue/src/assets/Assets.cpp @@ -48,7 +48,11 @@ Texture* Assets::key = nullptr; Texture* Assets::healthPotion = nullptr; Texture* Assets::healthPotion_small = nullptr; -Image Assets::mouse; +vector Assets::WASD; +vector Assets::H; +vector Assets::ESC; +vector Assets::TAB; +Texture* Assets::mouse = nullptr; Font Assets::defaultFont; Font Assets::titleFont; @@ -114,7 +118,11 @@ void Assets::load() { healthPotion_small = Loader::loadTexture("data/assets/textures/items/health_small.png"); //GUI - mouse = Loader::loadTexture("data/assets/textures/gui/mouse.png")->copyToImage(); + WASD = Loader::loadSpriteSheet("data/assets/textures/gui/keyboard/WASD.png", 63, 42); + H = Loader::loadSpriteSheet("data/assets/textures/gui/keyboard/H.png", 19, 21); + ESC = Loader::loadSpriteSheet("data/assets/textures/gui/keyboard/ESC.png", 41, 21); + TAB = Loader::loadSpriteSheet("data/assets/textures/gui/keyboard/TAB.png", 33, 21); + mouse = Loader::loadTexture("data/assets/textures/gui/mouse.png"); heart = Loader::loadTexture("data/assets/textures/gui/heart2.png"); heart_half = Loader::loadTexture("data/assets/textures/gui/heart1.png"); heart_empty = Loader::loadTexture("data/assets/textures/gui/heart0.png"); diff --git a/CRogue/src/assets/Assets.h b/CRogue/src/assets/Assets.h index 433c65c..71be9b6 100644 --- a/CRogue/src/assets/Assets.h +++ b/CRogue/src/assets/Assets.h @@ -55,7 +55,11 @@ class Assets { static Texture* healthPotion; static Texture* healthPotion_small; - static Image mouse; + static vector WASD; + static vector H; + static vector ESC; + static vector TAB; + static Texture* mouse; static Font defaultFont; static Font titleFont; diff --git a/CRogue/src/scene/MenuScene.cpp b/CRogue/src/scene/MenuScene.cpp index ed1ce5f..9fe41f0 100644 --- a/CRogue/src/scene/MenuScene.cpp +++ b/CRogue/src/scene/MenuScene.cpp @@ -23,7 +23,11 @@ void MenuScene::loadScene() { statsButton->setCallback(&SceneManager::showStats); GUIPanel.addComponent(statsButton); - Button* quitButton = new Button(Vector2f(400, 500), "Salir", 16); + Button* tutorialButton = new Button(Vector2f(400, 500), "Controles", 16); + tutorialButton->setCallback(&SceneManager::showTutorial); + GUIPanel.addComponent(tutorialButton); + + Button* quitButton = new Button(Vector2f(400, 550), "Salir", 16); quitButton->setCallback(&SceneManager::quitGame); GUIPanel.addComponent(quitButton);