From 006b4c76c97e5ae295b74d33d6c35ef88d42452a Mon Sep 17 00:00:00 2001 From: MiyanoOsu <96168694+MiyanoOsu@users.noreply.github.com> Date: Tue, 4 Jan 2022 21:56:31 +0700 Subject: [PATCH] Delete src directory --- src/config/Action.cpp | 18 -- src/config/Action.h | 28 -- src/config/AudioHelper.cpp | 169 ----------- src/config/AudioHelper.h | 75 ----- src/config/ConfigurationManager.cpp | 106 ------- src/config/ConfigurationManager.h | 58 ---- src/config/KeyBinder.cpp | 106 ------- src/config/KeyBinder.h | 37 --- src/config/TextHelper.cpp | 140 --------- src/config/TextHelper.h | 32 -- src/engine/audio/AudioConfiguration.cpp | 7 - src/engine/audio/AudioConfiguration.h | 31 -- src/engine/audio/AudioManager.cpp | 116 -------- src/engine/audio/AudioManager.h | 59 ---- src/engine/common/Common.h | 30 -- src/engine/renderer/CircularTransition.cpp | 71 ----- src/engine/renderer/CircularTransition.h | 48 --- src/engine/renderer/SimpleTransition.cpp | 63 ---- src/engine/renderer/SimpleTransition.h | 46 --- src/engine/renderer/Surface.cpp | 29 -- src/engine/renderer/Surface.h | 33 --- src/engine/resources/ResourceManager.cpp | 83 ------ src/engine/resources/ResourceManager.h | 36 --- src/engine/resources/WFile.cpp | 28 -- src/engine/resources/WFile.h | 26 -- src/engine/resources/WImage.cpp | 31 -- src/engine/resources/WImage.h | 29 -- src/engine/resources/WMusic.cpp | 14 - src/engine/resources/WMusic.h | 26 -- src/engine/resources/WResource.cpp | 19 -- src/engine/resources/WResource.h | 27 -- src/engine/resources/WSound.cpp | 14 - src/engine/resources/WSound.h | 28 -- src/engine/texts/Text.cpp | 294 ------------------- src/engine/texts/Text.h | 55 ---- src/engine/texts/TextConfiguration.cpp | 47 --- src/engine/texts/TextConfiguration.h | 46 --- src/engine/texts/TextManager.cpp | 174 ----------- src/engine/texts/TextManager.h | 54 ---- src/engine/util/geometry/BoundingBox.cpp | 50 ---- src/engine/util/geometry/BoundingBox.h | 40 --- src/engine/util/geometry/a.txt | 1 - src/engine/util/list/List.cpp | 117 -------- src/engine/util/list/List.h | 43 --- src/engine/util/list/ListCell.cpp | 76 ----- src/engine/util/list/ListCell.h | 42 --- src/engine/util/list/Listable.cpp | 11 - src/engine/util/list/Listable.h | 37 --- src/engine/util/list/a.txt | 1 - src/engine/util/physic/SlideManager.cpp | 196 ------------- src/engine/util/physic/SlideManager.h | 49 ---- src/engine/util/physic/a.txt | 1 - src/engine/util/time/Chrono.cpp | 15 - src/engine/util/time/Chrono.h | 31 -- src/engine/util/time/Metronome.cpp | 26 -- src/engine/util/time/Metronome.h | 36 --- src/engine/util/time/a.txt | 1 - src/engine/util/tree/Node.cpp | 310 -------------------- src/engine/util/tree/Node.h | 83 ------ src/engine/util/tree/Quadtree.cpp | 86 ------ src/engine/util/tree/Quadtree.h | 46 --- src/engine/util/tree/a.txt | 1 - src/engine/window/Event.cpp | 119 -------- src/engine/window/Event.h | 37 --- src/engine/window/Timer.cpp | 15 - src/engine/window/Timer.h | 29 -- src/engine/window/WindowManager.cpp | 111 ------- src/engine/window/WindowManager.h | 53 ---- src/game/GlobalSave.cpp | 146 ---------- src/game/GlobalSave.h | 68 ----- src/game/MainController.cpp | 124 -------- src/game/MainController.h | 67 ----- src/game/Save.cpp | 324 --------------------- src/game/Save.h | 177 ----------- src/game/algo/AStar.cpp | 204 ------------- src/game/algo/AStar.h | 48 --- src/main.cpp | 68 ----- 77 files changed, 5222 deletions(-) delete mode 100644 src/config/Action.cpp delete mode 100644 src/config/Action.h delete mode 100644 src/config/AudioHelper.cpp delete mode 100644 src/config/AudioHelper.h delete mode 100644 src/config/ConfigurationManager.cpp delete mode 100644 src/config/ConfigurationManager.h delete mode 100644 src/config/KeyBinder.cpp delete mode 100644 src/config/KeyBinder.h delete mode 100644 src/config/TextHelper.cpp delete mode 100644 src/config/TextHelper.h delete mode 100644 src/engine/audio/AudioConfiguration.cpp delete mode 100644 src/engine/audio/AudioConfiguration.h delete mode 100644 src/engine/audio/AudioManager.cpp delete mode 100644 src/engine/audio/AudioManager.h delete mode 100644 src/engine/common/Common.h delete mode 100644 src/engine/renderer/CircularTransition.cpp delete mode 100644 src/engine/renderer/CircularTransition.h delete mode 100644 src/engine/renderer/SimpleTransition.cpp delete mode 100644 src/engine/renderer/SimpleTransition.h delete mode 100644 src/engine/renderer/Surface.cpp delete mode 100644 src/engine/renderer/Surface.h delete mode 100644 src/engine/resources/ResourceManager.cpp delete mode 100644 src/engine/resources/ResourceManager.h delete mode 100644 src/engine/resources/WFile.cpp delete mode 100644 src/engine/resources/WFile.h delete mode 100644 src/engine/resources/WImage.cpp delete mode 100644 src/engine/resources/WImage.h delete mode 100644 src/engine/resources/WMusic.cpp delete mode 100644 src/engine/resources/WMusic.h delete mode 100644 src/engine/resources/WResource.cpp delete mode 100644 src/engine/resources/WResource.h delete mode 100644 src/engine/resources/WSound.cpp delete mode 100644 src/engine/resources/WSound.h delete mode 100644 src/engine/texts/Text.cpp delete mode 100644 src/engine/texts/Text.h delete mode 100644 src/engine/texts/TextConfiguration.cpp delete mode 100644 src/engine/texts/TextConfiguration.h delete mode 100644 src/engine/texts/TextManager.cpp delete mode 100644 src/engine/texts/TextManager.h delete mode 100644 src/engine/util/geometry/BoundingBox.cpp delete mode 100644 src/engine/util/geometry/BoundingBox.h delete mode 100644 src/engine/util/geometry/a.txt delete mode 100644 src/engine/util/list/List.cpp delete mode 100644 src/engine/util/list/List.h delete mode 100644 src/engine/util/list/ListCell.cpp delete mode 100644 src/engine/util/list/ListCell.h delete mode 100644 src/engine/util/list/Listable.cpp delete mode 100644 src/engine/util/list/Listable.h delete mode 100644 src/engine/util/list/a.txt delete mode 100644 src/engine/util/physic/SlideManager.cpp delete mode 100644 src/engine/util/physic/SlideManager.h delete mode 100644 src/engine/util/physic/a.txt delete mode 100644 src/engine/util/time/Chrono.cpp delete mode 100644 src/engine/util/time/Chrono.h delete mode 100644 src/engine/util/time/Metronome.cpp delete mode 100644 src/engine/util/time/Metronome.h delete mode 100644 src/engine/util/time/a.txt delete mode 100644 src/engine/util/tree/Node.cpp delete mode 100644 src/engine/util/tree/Node.h delete mode 100644 src/engine/util/tree/Quadtree.cpp delete mode 100644 src/engine/util/tree/Quadtree.h delete mode 100644 src/engine/util/tree/a.txt delete mode 100644 src/engine/window/Event.cpp delete mode 100644 src/engine/window/Event.h delete mode 100644 src/engine/window/Timer.cpp delete mode 100644 src/engine/window/Timer.h delete mode 100644 src/engine/window/WindowManager.cpp delete mode 100644 src/engine/window/WindowManager.h delete mode 100644 src/game/GlobalSave.cpp delete mode 100644 src/game/GlobalSave.h delete mode 100644 src/game/MainController.cpp delete mode 100644 src/game/MainController.h delete mode 100644 src/game/Save.cpp delete mode 100644 src/game/Save.h delete mode 100644 src/game/algo/AStar.cpp delete mode 100644 src/game/algo/AStar.h delete mode 100644 src/main.cpp diff --git a/src/config/Action.cpp b/src/config/Action.cpp deleted file mode 100644 index 17b6c4a..0000000 --- a/src/config/Action.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "Action.h" - -Action::Action() { - for (int i = 0; i < NB_ACTIONS; i++) { - actions[i] = false; - } -} - -Action::~Action() { -} - -void Action::setAction(ActionType key, bool b) { - actions[key] = b; -} - -bool Action::isAction(ActionType key) { - return actions[key]; -} diff --git a/src/config/Action.h b/src/config/Action.h deleted file mode 100644 index 34d7a8e..0000000 --- a/src/config/Action.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __ACTION_H__ -#define __ACTION_H__ - -enum ActionType {UP, DOWN, LEFT, RIGHT, PUSH_UP, PUSH_DOWN, PUSH_LEFT, PUSH_RIGHT, RUN, HIT, HIT2, LOAD, LOAD2, ACTION, ENTER, CARRY, TALK, NAVI, - TROC_ITEMS, DISPLAY_MAP, MAP_1, MAP_2, MAP_3, MAP_4, MAP_5, MAP_6, MAP_7, MAP_8, MAP_9, QUIT_GAME, ULTI, AIDE, ONI, NB_ACTIONS}; - -class Action { - public : - Action(); - ~Action(); - - void setAction(ActionType key, bool b); - bool isAction(ActionType key); - private : - bool actions[NB_ACTIONS]; -}; - -#endif // Action.h diff --git a/src/config/AudioHelper.cpp b/src/config/AudioHelper.cpp deleted file mode 100644 index fda234d..0000000 --- a/src/config/AudioHelper.cpp +++ /dev/null @@ -1,169 +0,0 @@ -#include "AudioHelper.h" - -AudioHelper::AudioHelper() : sounds(0) { -} - -AudioHelper::~AudioHelper() { - if (sounds != 0) deleteSounds(); -} - -string AudioHelper::getMusicName(int id) { - switch (id) { - case 0 : return "data/musics/Titre.ogg"; - case 1 : return "data/musics/Fee.ogg"; - case 2 : return "data/musics/Mort.ogg"; - case 3 : return "data/musics/Plage.ogg"; - case 4 : return "data/musics/Jungle.ogg"; - case 5 : return "data/musics/Coquillages.ogg"; - case 6 : return "data/musics/Opening.ogg"; - case 7 : return "data/musics/Lac.ogg"; - case 8 : return "data/musics/Plaine.ogg"; - case 9 : return "data/musics/Falaises.ogg"; - case 10 : return "data/musics/Gemmes.ogg"; - case 11 : return "data/musics/Marais.ogg"; - case 12 : return "data/musics/Fontaine.ogg"; - case 13 : return "data/musics/Canyon.ogg"; - case 14 : return "data/musics/Desert.ogg"; - case 15 : return "data/musics/VillageO.ogg"; - case 16 : return "data/musics/Cimetiere.ogg"; - case 17 : return "data/musics/Mont.ogg"; - case 18 : return "data/musics/Cave.ogg"; - case 19 : return "data/musics/Boss.ogg"; - case 20 : return "data/musics/Epee.ogg"; - case 21 : return "data/musics/Magasin.ogg"; - case 22 : return "data/musics/Jeu.ogg"; - case 23 : return "data/musics/Maison.ogg"; - case 24 : return "data/musics/Maire.ogg"; - case 25 : return "data/musics/Bar.ogg"; - case 26 : return "data/musics/Colisee.ogg"; - case 27 : return "data/musics/Sorciere.ogg"; - case 28 : return "data/musics/DJungle.ogg"; - case 29 : return "data/musics/DTerre.ogg"; - case 30 : return "data/musics/DPyramide.ogg"; - case 31 : return "data/musics/DEau.ogg"; - case 32 : return "data/musics/DFeu.ogg"; - case 33 : return "data/musics/DOmbre.ogg"; - case 34 : return "data/musics/DGlace.ogg"; - case 35 : return "data/musics/DSecret.ogg"; - case 36 : return "data/musics/DFinal.ogg"; - case 37 : return "data/musics/DFinal2.ogg"; - case 38 : return "data/musics/BossF.ogg"; - case 39 : return "data/musics/End.ogg"; - default : return ""; - } -} - -WSound* AudioHelper::getSound(int id) { - return sounds[id]; -} - -void AudioHelper::loadSounds() { - sounds = new WSound*[TS_NB_MAX]; - sounds[TS_MENU1] = new WSound("data/sounds/menu/menu1.wav"); - sounds[TS_MENU2] = new WSound("data/sounds/menu/menu2.wav"); - sounds[TS_MENU3] = new WSound("data/sounds/menu/menu3.wav"); - - sounds[TS_STEP_GRASS1] = new WSound("data/sounds/steps/Steps_Grass1.wav"); - sounds[TS_STEP_GRASS2] = new WSound("data/sounds/steps/Steps_Grass2.wav"); - sounds[TS_STEP_DIRT1] = new WSound("data/sounds/steps/Steps_Dirt1.wav"); - sounds[TS_STEP_DIRT2] = new WSound("data/sounds/steps/Steps_Dirt2.wav"); - sounds[TS_STEP_TALLGRASS1] = new WSound("data/sounds/steps/Steps_TallGrass1.wav"); - sounds[TS_STEP_TALLGRASS2] = new WSound("data/sounds/steps/Steps_TallGrass2.wav"); - sounds[TS_STEP_ICE1] = new WSound("data/sounds/steps/Steps_Ice1.wav"); - sounds[TS_STEP_ICE2] = new WSound("data/sounds/steps/Steps_Ice2.wav"); - sounds[TS_STEP_WATER1] = new WSound("data/sounds/steps/Steps_Water1.wav"); - sounds[TS_STEP_WATER2] = new WSound("data/sounds/steps/Steps_Water2.wav"); - sounds[TS_STEP_SAND1] = new WSound("data/sounds/steps/Steps_Sand1.wav"); - sounds[TS_STEP_SAND2] = new WSound("data/sounds/steps/Steps_Sand2.wav"); - sounds[TS_STEP_STONE1] = new WSound("data/sounds/steps/Steps_Stone1.wav"); - sounds[TS_STEP_STONE2] = new WSound("data/sounds/steps/Steps_Stone2.wav"); - sounds[TS_STEP_WOOD1] = new WSound("data/sounds/steps/Steps_Wood1.wav"); - sounds[TS_STEP_WOOD2] = new WSound("data/sounds/steps/Steps_Wood2.wav"); - sounds[TS_STEP_CARPET1] = new WSound("data/sounds/steps/Steps_Carpet1.wav"); - sounds[TS_STEP_CARPET2] = new WSound("data/sounds/steps/Steps_Carpet2.wav"); - - - sounds[TS_JUMP] = new WSound("data/sounds/link/jump.wav"); - sounds[TS_NAGE] = new WSound("data/sounds/link/nage.wav"); - sounds[TS_ATTACK1] = new WSound("data/sounds/link/attack1.wav"); - sounds[TS_ATTACK2] = new WSound("data/sounds/link/attack2.wav"); - sounds[TS_ATTACK3] = new WSound("data/sounds/link/attack3.wav"); - sounds[TS_ATTACK4] = new WSound("data/sounds/link/attack4.wav"); - sounds[TS_HURT] = new WSound("data/sounds/link/hurt.wav"); - sounds[TS_DANGER] = new WSound("data/sounds/link/danger.wav"); - sounds[TS_HEART] = new WSound("data/sounds/link/heart.wav"); - sounds[TS_RUPEE] = new WSound("data/sounds/link/rupee.wav"); - sounds[TS_SPIN] = new WSound("data/sounds/link/spin.wav"); - sounds[TS_ITEM] = new WSound("data/sounds/link/item.wav"); - sounds[TS_FALL] = new WSound("data/sounds/link/fall.wav"); - sounds[TS_MAGICCHARGE] = new WSound("data/sounds/link/charge.wav"); - sounds[TS_HAPPY] = new WSound("data/sounds/link/happy.wav"); - sounds[TS_SHOOT] = new WSound("data/sounds/link/shoot.wav"); - sounds[TS_THROW] = new WSound("data/sounds/link/lance.wav"); - sounds[TS_PORTE] = new WSound("data/sounds/link/porte.wav"); - sounds[TS_GRAPPIN] = new WSound("data/sounds/link/hookshot.wav"); - sounds[TS_MAGIC] = new WSound("data/sounds/link/magic.wav"); - sounds[TS_MARTEAU] = new WSound("data/sounds/link/hammer.wav"); - sounds[TS_PLOT] = new WSound("data/sounds/link/plot.wav"); - sounds[TS_CAPE_ON] = new WSound("data/sounds/link/capeon.wav"); - sounds[TS_CAPE_OFF] = new WSound("data/sounds/link/capeoff.wav"); - sounds[TS_CANE] = new WSound("data/sounds/link/cane.wav"); - sounds[TS_BYRNA] = new WSound("data/sounds/link/byrna.wav"); - sounds[TS_SHOCK] = new WSound("data/sounds/link/shock.wav"); - sounds[TS_BOOMERANG] = new WSound("data/sounds/link/boomerang.wav"); - sounds[TS_BAGUETTE_FEU] = new WSound("data/sounds/link/baguetteFeu.wav"); - sounds[TS_BAGUETTE_GLACE] = new WSound("data/sounds/link/baguetteGlace.wav"); - - - sounds[TS_NAVY_HEY] = new WSound("data/sounds/link/hey.wav"); - sounds[TS_NAVY_LISTEN] = new WSound("data/sounds/link/listen.wav"); - sounds[TS_NAVY_HELLO] = new WSound("data/sounds/link/hello.wav"); - sounds[TS_NAVY_LOOK] = new WSound("data/sounds/link/look.wav"); - - sounds[TS_SONG_1] = new WSound("data/sounds/ocarina/zelda.wav"); - sounds[TS_SONG_2] = new WSound("data/sounds/ocarina/envol.wav"); - sounds[TS_SONG_3] = new WSound("data/sounds/ocarina/vide.wav"); - - sounds[TS_SWORD] = new WSound("data/sounds/items/sword.wav"); - sounds[TS_SWORDCHARGING] = new WSound("data/sounds/items/SwordCharging.wav"); - - sounds[TS_HITENNEMY] = new WSound("data/sounds/others/hitenemy.wav"); - sounds[TS_KILLENNEMY] = new WSound("data/sounds/others/killenemy.wav"); - sounds[TS_PLOUF] = new WSound("data/sounds/others/plouf.wav"); - sounds[TS_SOL] = new WSound("data/sounds/others/stamp.wav"); - sounds[TS_BOOM] = new WSound("data/sounds/others/bomb.wav"); - sounds[TS_TOMBE] = new WSound("data/sounds/others/tombe.wav"); - sounds[TS_BURN] = new WSound("data/sounds/others/burn.wav"); - sounds[TS_BUISSON] = new WSound("data/sounds/others/buisson.wav"); - sounds[TS_DOOR] = new WSound("data/sounds/others/door.wav"); - sounds[TS_SURPRISE] = new WSound("data/sounds/others/surprise.wav"); - sounds[TS_ERROR] = new WSound("data/sounds/others/error.wav"); - sounds[TS_ESCALIERS_DOWN] = new WSound("data/sounds/others/descend.wav"); - sounds[TS_ESCALIERS_UP] = new WSound("data/sounds/others/monte.wav"); - sounds[TS_TELEPORT] = new WSound("data/sounds/others/timewarp.wav"); - - sounds[TS_PUSH] = new WSound("data/sounds/objects/push.wav"); - sounds[TS_BREAK] = new WSound("data/sounds/objects/casse.wav"); - sounds[TS_COFFRE] = new WSound("data/sounds/objects/coffre.wav"); - sounds[TS_POULE] = new WSound("data/sounds/objects/poule.wav"); - sounds[TS_PICS] = new WSound("data/sounds/objects/pics.wav"); - - sounds[TS_TEXT] = new WSound("data/sounds/texts/text.wav"); - sounds[TS_TEXTNEXT] = new WSound("data/sounds/texts/textnext.wav"); - sounds[TS_TEXTEND] = new WSound("data/sounds/texts/textend.wav"); - - -} - -void AudioHelper::deleteSounds() { - if (sounds != 0) { - for (int i = 0; i < TS_NB_MAX; i++) { - delete sounds[i]; - } - delete[] sounds; - } -} - -int AudioHelper::getNbSounds() { - return TS_NB_MAX; -} diff --git a/src/config/AudioHelper.h b/src/config/AudioHelper.h deleted file mode 100644 index 21bd371..0000000 --- a/src/config/AudioHelper.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __AUDIOHELPER_H__ -#define __AUDIOHELPER_H__ - -#include "../engine/common/Common.h" -#include "../engine/audio/AudioConfiguration.h" -#include "../engine/resources/WSound.h" - -enum TypeSound{ - TS_MENU1, TS_MENU2, TS_MENU3, - - TS_STEP_GRASS1, TS_STEP_GRASS2, - TS_STEP_TALLGRASS1, TS_STEP_TALLGRASS2, - TS_STEP_DIRT1, TS_STEP_DIRT2, - TS_STEP_ICE1, TS_STEP_ICE2, - TS_STEP_WATER1, TS_STEP_WATER2, - TS_STEP_SAND1, TS_STEP_SAND2, - TS_STEP_STONE1, TS_STEP_STONE2, - TS_STEP_WOOD1, TS_STEP_WOOD2, - TS_STEP_CARPET1, TS_STEP_CARPET2, - - TS_JUMP, TS_PLOUF, TS_NAGE, TS_FALL, TS_SOL, - TS_ATTACK1, TS_ATTACK2, TS_ATTACK3, TS_ATTACK4, - TS_SWORD, TS_SWORDCHARGING, TS_SPIN, - TS_HURT, TS_DANGER, TS_BOOM, TS_TOMBE, TS_SHOCK, - TS_SHOOT, TS_THROW, TS_PORTE, TS_GRAPPIN, - TS_MAGIC, TS_BURN, TS_MARTEAU, TS_PLOT, - TS_CAPE_ON, TS_CAPE_OFF, TS_CANE, TS_BYRNA, - TS_BUISSON, TS_DOOR, TS_SURPRISE, - TS_ESCALIERS_DOWN, TS_ESCALIERS_UP, - TS_TELEPORT, TS_BOOMERANG, TS_BAGUETTE_FEU, - TS_BAGUETTE_GLACE, - - TS_NAVY_HEY, TS_NAVY_LISTEN, TS_NAVY_HELLO, TS_NAVY_LOOK, - - TS_SONG_1, TS_SONG_2, TS_SONG_3, - - TS_HEART, TS_RUPEE, TS_ITEM, TS_HAPPY, TS_MAGICCHARGE, - - TS_PUSH, TS_BREAK, TS_COFFRE, TS_POULE, TS_ERROR, TS_PICS, - - TS_HITENNEMY, TS_KILLENNEMY, - - TS_TEXT, TS_TEXTNEXT, TS_TEXTEND, - - TS_NB_MAX}; - -class AudioHelper : public AudioConfiguration { - public : - AudioHelper(); - ~AudioHelper(); - - string getMusicName(int id); - WSound* getSound(int id); - - void loadSounds(); - - int getNbSounds(); - - private : - void deleteSounds(); - - WSound** sounds; -}; - -#endif // AudioHelper.h diff --git a/src/config/ConfigurationManager.cpp b/src/config/ConfigurationManager.cpp deleted file mode 100644 index 5e1cf7d..0000000 --- a/src/config/ConfigurationManager.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "ConfigurationManager.h" - -#include "../engine/audio/AudioManager.h" -#include "../engine/texts/TextManager.h" -#include "KeyBinder.h" - -ConfigurationManager ConfigurationManager::instance=ConfigurationManager(); - -ConfigurationManager::ConfigurationManager() : haveToSave(false), file(""), - volume(128), volson(128), lang(0), skin(1), audio(0), text(0) { -} - -ConfigurationManager::~ConfigurationManager() { -} - -ConfigurationManager* ConfigurationManager::getInstance() { - return &instance; -} - -void ConfigurationManager::init(string filename, string keys) { - file = filename; - haveToSave = false; - - ifstream f(file.c_str(), ios::in | ios::binary); - if(f.is_open()) { - f.read((char *)&volume,sizeof(int)); - f.read((char *)&volson,sizeof(int)); - f.read((char *)&lang,sizeof(int)); - f.read((char *)&skin,sizeof(int)); - f.close(); - } - - audio = new AudioHelper(); - - AudioManager::getInstance()->init(); - AudioManager::getInstance()->setConfiguration(audio); - AudioManager::getInstance()->setVolumeMusic(volume); - AudioManager::getInstance()->setVolumeSound(volson); - - text = new TextHelper(); - text->setLanguage(lang); - - TextManager::getInstance()->setConfiguration(text); - - KeyBinder::getInstance()->load(keys); -} - -void ConfigurationManager::close() { - delete audio; - delete text; -} - -void ConfigurationManager::save() { - if (!haveToSave) { - return; - } - ofstream f(file.c_str(), ios::out | ios::binary); - f.write((char *)&volume,sizeof(int)); - f.write((char *)&volson,sizeof(int)); - f.write((char *)&lang,sizeof(int)); - f.write((char *)&skin,sizeof(int)); - f.close(); - haveToSave = false; -} - -bool ConfigurationManager::isFrench() { - return lang == 0; -} - -string ConfigurationManager::getSkinName() { - switch (skin) { - case 0 : return "Original"; - case 1 : return "Blond"; - case 2 : return "Glass"; - default : return "Blond"; - } -} - -int ConfigurationManager::getVolume() {return volume;} -int ConfigurationManager::getVolson() {return volson;} -int ConfigurationManager::getLang() {return lang;} -int ConfigurationManager::getSkin() {return skin;} - -void ConfigurationManager::setVolume(int v) { - volume = v; - haveToSave = true; - AudioManager::getInstance()->setVolumeMusic(volume); -} - -void ConfigurationManager::setVolson(int v) { - volson = v; - haveToSave = true; - AudioManager::getInstance()->setVolumeSound(volson); -} - -void ConfigurationManager::setLang(int l) { - lang = l; - text->setLanguage(lang); - TextManager::getInstance()->reloadTexts(); - haveToSave = true; -} - -void ConfigurationManager::setSkin(int s) { - skin = s; - haveToSave = true; -} diff --git a/src/config/ConfigurationManager.h b/src/config/ConfigurationManager.h deleted file mode 100644 index 415bed6..0000000 --- a/src/config/ConfigurationManager.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __CONFIGURATIONMANAGER_H__ -#define __CONFIGURATIONMANAGER_H__ - -#include "../engine/common/Common.h" - -#include "AudioHelper.h" -#include "TextHelper.h" - -class ConfigurationManager { - public : - static ConfigurationManager* getInstance(); - - void init(string filename, string keys); - - void save(); - - bool isFrench(); - string getSkinName(); - - int getVolume(); - int getVolson(); - int getLang(); - int getSkin(); - - void setVolume(int v); - void setVolson(int v); - void setLang(int l); - void setSkin(int s); - - void close(); - - private : - ConfigurationManager(); - ~ConfigurationManager(); - static ConfigurationManager instance; - - bool haveToSave; - string file; - int volume; - int volson; - int lang; - int skin; - - AudioHelper* audio; - TextHelper* text; -}; - -#endif // ConfigurationManager.h diff --git a/src/config/KeyBinder.cpp b/src/config/KeyBinder.cpp deleted file mode 100644 index a6f38be..0000000 --- a/src/config/KeyBinder.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "KeyBinder.h" - -KeyBinder KeyBinder::instance=KeyBinder(); - -KeyBinder::KeyBinder() { - // default values : - binding[UP] = kUp; - binding[DOWN] = kDown; - binding[LEFT] = kLeft; - binding[RIGHT] = kRight; - - binding[RUN] = kShift; - - binding[HIT] = kZ; - binding[LOAD] = kZ; - binding[HIT2] = kW; - binding[LOAD2] = kW; - binding[ACTION] = kX; - binding[CARRY] = kC; - binding[ULTI] = kV; - - binding[TALK] = kSpace; - - binding[NAVI] = kCtrl; - - binding[TROC_ITEMS] = kI; - binding[ONI] = kO; - binding[DISPLAY_MAP] = kP; - - binding[MAP_1] = k1; - binding[MAP_2] = k2; - binding[MAP_3] = k3; - binding[MAP_4] = k4; - binding[MAP_5] = k5; - binding[MAP_6] = k6; - binding[MAP_7] = k7; - binding[MAP_8] = k8; - binding[MAP_9] = k9; - - binding[ENTER] = kReturn; - binding[QUIT_GAME] = kEscape; - - binding[AIDE] = kF1; -} - -KeyBinder::~KeyBinder() { -} - -KeyBinder* KeyBinder::getInstance() { - return &instance; -} - -Action* KeyBinder::bind(Event* event) { - - action.setAction(UP, event->isDown(binding[UP])); - action.setAction(DOWN, event->isDown(binding[DOWN])); - action.setAction(LEFT, event->isDown(binding[LEFT])); - action.setAction(RIGHT, event->isDown(binding[RIGHT])); - - action.setAction(PUSH_UP, event->isPushed(binding[UP])); - action.setAction(PUSH_DOWN, event->isPushed(binding[DOWN])); - action.setAction(PUSH_LEFT, event->isPushed(binding[LEFT])); - action.setAction(PUSH_RIGHT, event->isPushed(binding[RIGHT])); - - action.setAction(RUN, event->isDown(binding[RUN])); - - action.setAction(HIT, (event->isPushed(binding[HIT]) && !event->isDown(binding[LOAD2])) - || (event->isPushed(binding[HIT2]) && !event->isDown(binding[LOAD]))); - action.setAction(LOAD, event->isDown(binding[LOAD]) || event->isDown(binding[LOAD2])); - action.setAction(ACTION, event->isPushed(binding[ACTION])); - action.setAction(CARRY, event->isPushed(binding[CARRY])); - action.setAction(ULTI, event->isPushed(binding[ULTI])); - - action.setAction(TALK, event->isPushed(binding[TALK])); - - action.setAction(NAVI, event->isDown(binding[NAVI])); - - action.setAction(TROC_ITEMS, event->isPushed(binding[TROC_ITEMS])); - action.setAction(ONI, event->isPushed(binding[ONI])); - action.setAction(DISPLAY_MAP, event->isPushed(binding[DISPLAY_MAP])); - - action.setAction(MAP_1, event->isPushed(binding[MAP_1])); - action.setAction(MAP_2, event->isPushed(binding[MAP_2])); - action.setAction(MAP_3, event->isPushed(binding[MAP_3])); - action.setAction(MAP_4, event->isPushed(binding[MAP_4])); - action.setAction(MAP_5, event->isPushed(binding[MAP_5])); - action.setAction(MAP_6, event->isPushed(binding[MAP_6])); - action.setAction(MAP_7, event->isPushed(binding[MAP_7])); - action.setAction(MAP_8, event->isPushed(binding[MAP_8])); - action.setAction(MAP_9, event->isPushed(binding[MAP_9])); - - action.setAction(AIDE, event->isPushed(binding[AIDE])); - - action.setAction(ENTER, event->isPushed(binding[ENTER])); - action.setAction(QUIT_GAME, event->isPushed(binding[QUIT_GAME])); - - return &action; -} - -void KeyBinder::load(string filename) { - // TODO -} - -void KeyBinder::save(string filename) { - // TODO -} diff --git a/src/config/KeyBinder.h b/src/config/KeyBinder.h deleted file mode 100644 index f1a8918..0000000 --- a/src/config/KeyBinder.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __KEYBINDER_H__ -#define __KEYBINDER_H__ - -#include "../engine/common/Common.h" -#include "../engine/window/Event.h" - -#include "Action.h" - -class KeyBinder { - public : - static KeyBinder* getInstance(); - - Action* bind(Event* event); - - void load(string filename); // load key configuration - void save(string filename); - - private : - KeyBinder(); - ~KeyBinder(); - static KeyBinder instance; - - Action action; - Keys binding[NB_ACTIONS]; -}; - -#endif // KeyBinder.h diff --git a/src/config/TextHelper.cpp b/src/config/TextHelper.cpp deleted file mode 100644 index af47ec8..0000000 --- a/src/config/TextHelper.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include "TextHelper.h" - -#include "../engine/resources/ResourceManager.h" - -#include "../game/MainController.h" - -TextHelper::TextHelper() { - setWSpace(6); - setWSize(8); - setHSize(16); - image = ResourceManager::getInstance()->loadImage("data/images/texts/font.png", true); - setImage(image); -} - -TextHelper::~TextHelper() { - ResourceManager::getInstance()->free(image); -} - -void TextHelper::setLanguage(int i) { - switch (i) { - case 0 : setTextfile("data/texts/french.txt"); break; - case 1 : setTextfile("data/texts/english.txt"); break; - default : setTextfile("data/texts/english.txt"); break; - } -} - -string TextHelper::getVariableValue(int textId, int varId) { - ostringstream os; - int tmp; - switch (textId) { - case 11 : - tmp = 4 - MainController::getInstance()->getGameController()-> - getSceneController()->getScene()->getLink()->getInventory()->nbQuartCoeur(); - os<getGameController()->getSave()->isExpert() ? 3 : 5; - os<getGameController()-> - getSceneController()->getScene()->getCoffre(0, 11); - return os.str(); - case 470 : case 471 : case 472 : case 473 : - os << MainController::getInstance()->getGameController()-> - getSceneController()->getScene()->getMap()->getGameScore(); - return os.str(); - case 597 : - os << (7 - MainController::getInstance()->getGameController()-> - getSceneController()->getScene()->getLink()->getInventory()->nbMedaillons()); - return os.str(); - case 659 : case 766 : - os << MainController::getInstance()->getGameController()->getSave()->getDeaths(); - return os.str(); - case 660 : - tmp = 0; - for (int i = 0; i < NB_QUART_COEUR; i++) { - if (MainController::getInstance()->getGameController()->getSave()->getQuartCoeur(i) != 0) { - tmp++; - } - } - os << tmp; - return os.str(); - case 661 : - tmp = 0; - for (int i = 0; i < NB_GEMME_FORCE; i++) { - if (MainController::getInstance()->getGameController()->getSave()->getGemmeForce(i) != 0) { - tmp++; - } - } - os << tmp; - return os.str(); - case 662 : - tmp = 0; - for (int i = 0; i < NB_COQUILLAGES; i++) { - if (MainController::getInstance()->getGameController()->getSave()->getCoquillages(i) != 0) { - tmp++; - } - } - os << tmp; - return os.str(); - case 663 : - tmp = 0; - for (int i = 0; i < NB_TROC; i++) { - if (MainController::getInstance()->getGameController()->getSave()->getTroc(i) != -1) { - tmp++; - } - } - os << tmp; - return os.str(); - case 664 : - os << ((MainController::getInstance()->getGameController()->getSave()->getNaviMaxMagic() - 15) / 5); - return os.str(); - case 665 : - - tmp = 0; - for (int i = 0; i < NB_EQPMT - 1; i++) { - if (MainController::getInstance()->getGameController()->getSave()->getEquipment(i) != 0) { - tmp++; - } - } - tmp += MainController::getInstance()->getGameController()->getSave()->getBouclier(); - tmp += MainController::getInstance()->getGameController()->getSave()->getTunique() - 1; - tmp += MainController::getInstance()->getGameController()->getSave()->getEpee(); - if (MainController::getInstance()->getGameController()->getSave()->getEpee() == 5) tmp--; - if (MainController::getInstance()->getGameController()->getSave()->getMaxMagic() > 32) tmp++; - tmp += (MainController::getInstance()->getGameController()->getSave()->getMaxArrows() - 30) / 5; - tmp += (MainController::getInstance()->getGameController()->getSave()->getMaxBombs() - 10) / 2; - if (MainController::getInstance()->getGameController()->getSave()->getMaxRupees() > 0) tmp++; - if (MainController::getInstance()->getGameController()->getSave()->getMaxRupees() > 99) tmp++; - if (MainController::getInstance()->getGameController()->getSave()->getMaxRupees() > 250) tmp++; - if (MainController::getInstance()->getGameController()->getSave()->getMaxRupees() > 500) tmp++; - - for (int i = 0; i < NB_MEDAILLONS; i++) { - if (MainController::getInstance()->getGameController()->getSave()->getMedaillons(i) != 0) { - tmp++; - } - } - - for (int j = 1; j < NB_DONJON; j++) { - for (int i = 0; i < 3; i++) { - if (MainController::getInstance()->getGameController()->getSave()->getCoffre(j, i) != 0) tmp++; - } - } - - os << tmp; - return os.str(); - case 666 : - os << MainController::getInstance()->getGameController()->getSave()->getCompletion(); - return os.str(); - } - return ""; -} - -string TextHelper::getCommonValue(string tag) { - if (tag == "line") { - return " "; - } - return ""; -} diff --git a/src/config/TextHelper.h b/src/config/TextHelper.h deleted file mode 100644 index a915c47..0000000 --- a/src/config/TextHelper.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __TEXTHELPER_H__ -#define __TEXTHELPER_H__ - -#include "../engine/common/Common.h" -#include "../engine/texts/TextConfiguration.h" -#include "../engine/resources/WImage.h" - -class TextHelper : public TextConfiguration { - public : - TextHelper(); - ~TextHelper(); - - void setLanguage(int i); - - string getVariableValue(int textId, int varId); - string getCommonValue(string tag); - - private : - WImage* image; -}; - -#endif // TextHelper.h diff --git a/src/engine/audio/AudioConfiguration.cpp b/src/engine/audio/AudioConfiguration.cpp deleted file mode 100644 index 18c6d75..0000000 --- a/src/engine/audio/AudioConfiguration.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "AudioConfiguration.h" - -AudioConfiguration::AudioConfiguration() { -} - -AudioConfiguration::~AudioConfiguration() { -} diff --git a/src/engine/audio/AudioConfiguration.h b/src/engine/audio/AudioConfiguration.h deleted file mode 100644 index 3189e3c..0000000 --- a/src/engine/audio/AudioConfiguration.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __AUDIOCONFIGURATION_H__ -#define __AUDIOCONFIGURATION_H__ - -#include "../common/Common.h" -#include "../resources/WMusic.h" -#include "../resources/WSound.h" - -class AudioConfiguration { - public : - AudioConfiguration(); - virtual ~AudioConfiguration() = 0; - - virtual string getMusicName(int id) = 0; - virtual WSound* getSound(int id) = 0; - - virtual void loadSounds() = 0; - - virtual int getNbSounds() = 0; -}; - -#endif // AudioConfiguration.h diff --git a/src/engine/audio/AudioManager.cpp b/src/engine/audio/AudioManager.cpp deleted file mode 100644 index ba5b154..0000000 --- a/src/engine/audio/AudioManager.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "AudioManager.h" - -AudioManager AudioManager::instance=AudioManager(); - -AudioManager::AudioManager() : current(0), music(0), volumeMusic(128), volumeSound(128), - config(0), previous_volume(0), previous_volson(0), playing(false) { - - SOUND = true; - previousMusic = -1; -} - -AudioManager::~AudioManager() { - -} - -void AudioManager::init() { - if(SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) SOUND = false; - - if (SOUND) { - Mix_OpenAudio(22050, AUDIO_S16SYS, 2, 2048); - previous_volume = Mix_VolumeMusic(volumeMusic); - } -} - -AudioManager* AudioManager::getInstance() { - return &instance; -} - -void AudioManager::close() { - if (SOUND) { - if (current != 0) { - Mix_PauseMusic(); - } - Mix_VolumeMusic(previous_volume); - if (current != 0) { - Mix_HaltMusic(); - delete current; - } - - Mix_CloseAudio(); - } -} - -void AudioManager::setConfiguration(AudioConfiguration* conf) { - if (SOUND) { - config = conf; - config->loadSounds(); - setVolumeSound(volumeSound); - } -} - -int AudioManager::getVolumeMusic() { - return volumeMusic; -} - -int AudioManager::getVolumeSound() { - return volumeSound; -} - -void AudioManager::setVolumeMusic(int v) { - volumeMusic = v; - if (SOUND) Mix_VolumeMusic(volumeMusic); -} - -void AudioManager::setVolumeSound(int v) { - volumeSound = v; - if (SOUND) for (int i = 0; i < config->getNbSounds(); i++) Mix_VolumeChunk(config->getSound(i)->getSound(), volumeSound); -} - -void AudioManager::playMusic(int i) { - if (SOUND) { - if (music != i || !playing) { - music = i; - if (current != 0) { - Mix_HaltMusic(); - delete current; - } - current = new WMusic(config->getMusicName(i)); - Mix_PlayMusic(current->getMusic(),-1); - playing = true; - } - } -} - -void AudioManager::stopMusic() { - if (SOUND) { - previousMusic = music; - Mix_HaltMusic(); - playing = false; - } -} - -void AudioManager::replayMusic() { - if (previousMusic != -1) { - playMusic(previousMusic); - } -} - -void AudioManager::playSound(int i, int chl) { - if (SOUND) { - Mix_PlayChannel(chl, config->getSound(i)->getSound(), 0); - } -} - -int AudioManager::isPlaying(int chl) { - if (SOUND) { - return Mix_Playing(chl); - } - return 0; -} - -void AudioManager::stopSound(int chl) { - if (SOUND) { - Mix_HaltChannel(chl); - } -} diff --git a/src/engine/audio/AudioManager.h b/src/engine/audio/AudioManager.h deleted file mode 100644 index ac1c0ff..0000000 --- a/src/engine/audio/AudioManager.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __AUDIOMANAGER_H__ -#define __AUDIOMANAGER_H__ - -#include "../common/Common.h" - -#include "AudioConfiguration.h" - -class AudioManager { - public : - static AudioManager* getInstance(); - - void init(); - - void setConfiguration(AudioConfiguration* conf); - - void playMusic(int i); - void stopMusic(); - void replayMusic(); - void playSound(int i, int chl = -1); - - int isPlaying(int chl); - void stopSound(int chl); - - int getVolumeMusic(); - int getVolumeSound(); - - void setVolumeMusic(int v); - void setVolumeSound(int v); - - void close(); - - private : - AudioManager(); - ~AudioManager(); - static AudioManager instance; - - WMusic* current; - int music; - int volumeMusic; - int volumeSound; - AudioConfiguration* config; - int previous_volume; - int previous_volson; - bool playing; - bool SOUND; - int previousMusic; -}; - -#endif // AudioManager.h diff --git a/src/engine/common/Common.h b/src/engine/common/Common.h deleted file mode 100644 index 6e46a13..0000000 --- a/src/engine/common/Common.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#define FULLSCREEN false -#define WINDOW_SIZE_W 320 -#define WINDOW_SIZE_H 240 - -#define GAME_SIZE_W 320 -#define GAME_SIZE_H 240 - -#define CASE 16 - -#include -#include -#include - -using namespace std; - -#endif // Common.h - diff --git a/src/engine/renderer/CircularTransition.cpp b/src/engine/renderer/CircularTransition.cpp deleted file mode 100644 index d13269b..0000000 --- a/src/engine/renderer/CircularTransition.cpp +++ /dev/null @@ -1,71 +0,0 @@ -#include "CircularTransition.h" - -#include "../window/WindowManager.h" - -#include - -CircularTransition::CircularTransition() { - rect = SDL_CreateRGBSurface(SDL_SWSURFACE, GAME_SIZE_W, GAME_SIZE_H, 16, 0, 0, 0, 0); - reset(); -} - -CircularTransition::~CircularTransition() { - SDL_FreeSurface(rect); -} - -void CircularTransition::loop() { - if (step == 1) { - radius -= 10; - if (radius == 0) { - step = 2; - } - } else if (step == 3) { - radius += 10; - if (radius == 320) { - step = 4; - } - } - SDL_FillRect(rect, NULL, SDL_MapRGB(rect->format, 0, 0, 0)); - if (radius > 0) { - filledEllipseRGBA(rect, x, y, radius, radius*2/3, 0, 0, 255, 255); - SDL_SetColorKey(rect,SDL_SRCCOLORKEY, SDL_MapRGB(rect->format,0,0,255)); - } -} - -void CircularTransition::draw() { - WindowManager::getInstance()->draw(rect); -} - -bool CircularTransition::isRunning() { - return run; -} - -void CircularTransition::start(int i, int j) { - run = true; - step = 1; - x = i; - y = j; -} - -bool CircularTransition::isWaiting() { - return (step == 2); -} - -void CircularTransition::restart(int i, int j) { - step = 3; - radius = 0; - x = i; - y = j; -} - -bool CircularTransition::isAchieved() { - return (step == 4); -} - -void CircularTransition::reset() { - run = false; - step = 0; - radius = 320; - filledEllipseRGBA(rect, 160, 120, radius, radius*2/3, 0, 0, 255, 255); - SDL_SetColorKey(rect,SDL_SRCCOLORKEY, SDL_MapRGB(rect->format,0,0,255)); -} diff --git a/src/engine/renderer/CircularTransition.h b/src/engine/renderer/CircularTransition.h deleted file mode 100644 index 6dae629..0000000 --- a/src/engine/renderer/CircularTransition.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __CIRCULARTRANSITION_H__ -#define __CIRCULARTRANSITION_H__ - -#include "../common/Common.h" - -#include - -class CircularTransition { - public : - CircularTransition(); - ~CircularTransition(); - - void loop(); - void draw(); - - bool isRunning(); - - void start(int x, int y); - - bool isWaiting(); - - void restart(int x, int y); - - bool isAchieved(); - - void reset(); - - private : - - SDL_Surface* rect; - bool run; - int step; - int radius; - int x; - int y; -}; - -#endif // CircularTransition.h diff --git a/src/engine/renderer/SimpleTransition.cpp b/src/engine/renderer/SimpleTransition.cpp deleted file mode 100644 index 0ad91ad..0000000 --- a/src/engine/renderer/SimpleTransition.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include "SimpleTransition.h" - -#include "../window/WindowManager.h" - - -SimpleTransition::SimpleTransition() { - rect = SDL_CreateRGBSurface(SDL_SWSURFACE, GAME_SIZE_W, GAME_SIZE_H, 16, 0, 0, 0, 0); - reset(); -} - -SimpleTransition::~SimpleTransition() { - SDL_FreeSurface(rect); -} - -void SimpleTransition::loop() { - if (step == 1) { - alpha += 15; - if (alpha == 255) { - step = 2; - } - //rect.SetColor(sf::Color(0, 0, 0, alpha)); - SDL_SetAlpha(rect, SDL_SRCALPHA, alpha); - } else if (step == 3) { - alpha -= 15; - if (alpha == 0) { - step = 4; - } - SDL_SetAlpha(rect, SDL_SRCALPHA, alpha); - } -} - -void SimpleTransition::draw() { - WindowManager::getInstance()->draw(rect); -} - -bool SimpleTransition::isRunning() { - return run; -} - -void SimpleTransition::start() { - run = true; - step = 1; -} - -bool SimpleTransition::isWaiting() { - return (step == 2); -} - -void SimpleTransition::restart() { - step = 3; - alpha = 255; -} - -bool SimpleTransition::isAchieved() { - return (step == 4); -} - -void SimpleTransition::reset() { - run = false; - step = 0; - alpha = 0; -} - diff --git a/src/engine/renderer/SimpleTransition.h b/src/engine/renderer/SimpleTransition.h deleted file mode 100644 index 03fc47b..0000000 --- a/src/engine/renderer/SimpleTransition.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __SIMPLETRANSITION_H__ -#define __SIMPLETRANSITION_H__ - -#include "../common/Common.h" - -#include - -class SimpleTransition { - public : - SimpleTransition(); - ~SimpleTransition(); - - void loop(); - void draw(); - - bool isRunning(); - - void start(); - - bool isWaiting(); - - void restart(); - - bool isAchieved(); - - void reset(); - - private : - - SDL_Surface* rect; - bool run; - int step; - int alpha; -}; - -#endif // SimpleTransition.h diff --git a/src/engine/renderer/Surface.cpp b/src/engine/renderer/Surface.cpp deleted file mode 100644 index e7bc969..0000000 --- a/src/engine/renderer/Surface.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "Surface.h" - -Surface::Surface(int w, int h, bool alpha) { - image = new WImage(w, h, alpha); -} - -Surface::~Surface() { - delete image; -} - -void Surface::put(WImage* im, int dstX, int dstY, int srcX, int srcY, int srcW, int srcH) { - SDL_Surface* tmp = im->getImage(); - - SDL_Rect src; - src.x = srcX; - src.y = srcY; - src.w = srcW; - src.h = srcH; - - SDL_Rect dst; - dst.x = dstX; - dst.y = dstY; - - SDL_BlitSurface(tmp, &src, image->getImage(), &dst); -} - -WImage* Surface::toImage() { - return image; -} diff --git a/src/engine/renderer/Surface.h b/src/engine/renderer/Surface.h deleted file mode 100644 index d9e514c..0000000 --- a/src/engine/renderer/Surface.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __SURFACE_H__ -#define __SURFACE_H__ - -#include "../../engine/common/Common.h" -#include "../../engine/resources/WImage.h" - -#include - -class Surface { - public : - Surface(int w, int h, bool alpha = false); - ~Surface(); - - void put(WImage* im, int dstX, int dstY, int srcX = 0, int srcY = 0, int srcW = 0, int srcH = 0); - - WImage* toImage(); - - private : - - WImage* image; -}; - -#endif // Surface.h diff --git a/src/engine/resources/ResourceManager.cpp b/src/engine/resources/ResourceManager.cpp deleted file mode 100644 index 20a5029..0000000 --- a/src/engine/resources/ResourceManager.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "ResourceManager.h" - -ResourceManager ResourceManager::instance=ResourceManager(); - -ResourceManager::ResourceManager() { -} - -ResourceManager::~ResourceManager() { -} - -ResourceManager* ResourceManager::getInstance() { - return &instance; -} - -WImage* ResourceManager::loadImage(string filename, bool alpha) { - - if (resources.find(filename) == resources.end()) { - resources[filename] = new WImage(filename, alpha); - } - - WImage* image = dynamic_cast(resources[filename]); - - if (image != 0) { - image->load(); - } - - return image; -} - -WMusic* ResourceManager::loadMusic(string filename) { - - if (resources.find(filename) == resources.end()) { - resources[filename] = new WMusic(filename); - } - - WMusic* music = dynamic_cast(resources[filename]); - - if (music != 0) { - music->load(); - } - - return music; -} - -WSound* ResourceManager::loadSound(string filename) { - - if (resources.find(filename) == resources.end()) { - resources[filename] = new WSound(filename); - } - - WSound* sound = dynamic_cast(resources[filename]); - - if (sound != 0) { - sound->load(); - } - - return sound; -} - -WFile* ResourceManager::loadFile(string filename) { - - if (resources.find(filename) == resources.end()) { - resources[filename] = new WFile(filename); - } - - WFile* file = dynamic_cast(resources[filename]); - - if (file != 0) { - file->load(); - } - - return file; -} - -void ResourceManager::free(WResource* resource) { - if (resource == 0) { - return; - } - if (resource->unload() == 0) { - resources.erase(resource->getName()); - delete resource; - } -} diff --git a/src/engine/resources/ResourceManager.h b/src/engine/resources/ResourceManager.h deleted file mode 100644 index be0e56e..0000000 --- a/src/engine/resources/ResourceManager.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - - Wolf of Light - - Copyright (C) 2010 Vincent Jouillat - -*/ - -#ifndef __RESOURCEMANAGER_H__ -#define __RESOURCEMANAGER_H__ - -#include - -#include "../common/Common.h" -#include "WImage.h" -#include "WMusic.h" -#include "WSound.h" -#include "WFile.h" - -class ResourceManager { - public : - static ResourceManager* getInstance(); - WImage* loadImage(string filename, bool alpha = false); - WMusic* loadMusic(string filename); - WSound* loadSound(string filename); - WFile* loadFile(string filename); - void free(WResource* resource); - private : - ResourceManager(); - ~ResourceManager(); - static ResourceManager instance; - - map resources; -}; - -#endif // ResourceManager.h diff --git a/src/engine/resources/WFile.cpp b/src/engine/resources/WFile.cpp deleted file mode 100644 index 73b1c62..0000000 --- a/src/engine/resources/WFile.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "WFile.h" - -WFile::WFile(string filename) : buffer(0), size(0) { - name = filename; - ifstream file; - file.open (name.c_str(), ifstream::in | ifstream::binary); - if (file.is_open()) { - file.seekg (0, ios::end); - size = file.tellg(); - file.seekg (0, ios::beg); - buffer = new char [size]; - file.read (buffer, size); - file.close(); - } -} - -WFile::~WFile() { - delete buffer; -} - -char* WFile::getBuffer() { - return buffer; -} - -long WFile::getSize() { - return size; -} - diff --git a/src/engine/resources/WFile.h b/src/engine/resources/WFile.h deleted file mode 100644 index dd25e9b..0000000 --- a/src/engine/resources/WFile.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - - Wolf of Light - - Copyright (C) 2010 Vincent Jouillat - -*/ - -#ifndef __WFILE_H__ -#define __WFILE_H__ - -#include "../common/Common.h" -#include "WResource.h" - -class WFile : public WResource { - public : - WFile(string filename); - ~WFile(); - char* getBuffer(); - long getSize(); - private : - char* buffer; - long size; -}; - -#endif // WFile.h diff --git a/src/engine/resources/WImage.cpp b/src/engine/resources/WImage.cpp deleted file mode 100644 index e9aa6e1..0000000 --- a/src/engine/resources/WImage.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "WImage.h" - -WImage::WImage(string filename, bool alpha) { - name = filename; - image = IMG_Load(name.c_str()); - if (alpha) { - SDL_SetColorKey(image, SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 0, 0, 255)); - } -} - -WImage::WImage(int w, int h, bool alpha) { - if (alpha) { - image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 16, 0, 0, 0, 0); - SDL_FillRect(image, NULL, SDL_MapRGB(image->format, 0, 0, 255)); - SDL_SetColorKey(image, SDL_SRCCOLORKEY, SDL_MapRGB(image->format, 0, 0, 255)); - } else { - image = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 16, 0, 0, 0, 0); - } -} - -WImage::~WImage() { - SDL_FreeSurface(image); -} - -SDL_Surface* WImage::getImage() { - return image; -} - -void WImage::setAlpha(int alpha) { - SDL_SetAlpha(image, SDL_SRCALPHA, alpha); -} diff --git a/src/engine/resources/WImage.h b/src/engine/resources/WImage.h deleted file mode 100644 index 9b84edc..0000000 --- a/src/engine/resources/WImage.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - - Wolf of Light - - Copyright (C) 2010 Vincent Jouillat - -*/ - -#ifndef __WIMAGE_H__ -#define __WIMAGE_H__ - -#include -#include - -#include "../common/Common.h" -#include "WResource.h" - -class WImage : public WResource { - public : - WImage(string filename, bool alpha = false); - WImage(int w, int h, bool alpha = false); - ~WImage(); - SDL_Surface* getImage(); - void setAlpha(int alpha); // 0 to 255 - private : - SDL_Surface* image; -}; - -#endif // WImage.h diff --git a/src/engine/resources/WMusic.cpp b/src/engine/resources/WMusic.cpp deleted file mode 100644 index c646596..0000000 --- a/src/engine/resources/WMusic.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "WMusic.h" - -WMusic::WMusic(string filename) { - name = filename; - music = Mix_LoadMUS(name.c_str()); -} - -WMusic::~WMusic() { - Mix_FreeMusic(music); -} - -Mix_Music* WMusic::getMusic() { - return music; -} diff --git a/src/engine/resources/WMusic.h b/src/engine/resources/WMusic.h deleted file mode 100644 index 9f090e8..0000000 --- a/src/engine/resources/WMusic.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - - Wolf of Light - - Copyright (C) 2010 Vincent Jouillat - -*/ - -#ifndef __WMUSIC_H__ -#define __WMUSIC_H__ - -#include - -#include "../common/Common.h" -#include "WResource.h" - -class WMusic : public WResource { - public : - WMusic(string filename); - ~WMusic(); - Mix_Music* getMusic(); - private : - Mix_Music* music; -}; - -#endif // WMusic.h diff --git a/src/engine/resources/WResource.cpp b/src/engine/resources/WResource.cpp deleted file mode 100644 index 6e02e6b..0000000 --- a/src/engine/resources/WResource.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "WResource.h" - -WResource::WResource() : count(0), name("") { -} - -WResource::~WResource() { -} - -string WResource::getName() { - return name; -} - -void WResource::load() { - count++; -} - -int WResource::unload() { - return --count; -} diff --git a/src/engine/resources/WResource.h b/src/engine/resources/WResource.h deleted file mode 100644 index 6cae77e..0000000 --- a/src/engine/resources/WResource.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - - Wolf of Light - - Copyright (C) 2010 Vincent Jouillat - -*/ - -#ifndef __WRESOURCE_H__ -#define __WRESOURCE_H__ - -#include "../common/Common.h" - -class WResource { - public : - WResource(); - virtual ~WResource() = 0; - string getName(); - void load(); - int unload(); - private : - int count; - protected : - string name; -}; - -#endif // WResource.h diff --git a/src/engine/resources/WSound.cpp b/src/engine/resources/WSound.cpp deleted file mode 100644 index 52445f5..0000000 --- a/src/engine/resources/WSound.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#include "WSound.h" - -WSound::WSound(string filename) { - name = filename; - sound = Mix_LoadWAV(name.c_str()); -} - -WSound::~WSound() { - Mix_FreeChunk(sound); -} - -Mix_Chunk* WSound::getSound() { - return sound; -} diff --git a/src/engine/resources/WSound.h b/src/engine/resources/WSound.h deleted file mode 100644 index e7b195e..0000000 --- a/src/engine/resources/WSound.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - - Wolf of Light - - Copyright (C) 2010 Vincent Jouillat - -*/ - -#ifndef __WSOUND_H__ -#define __WSOUND_H__ - -#include -#include - -#include "../common/Common.h" -#include "WResource.h" - -class WSound : public WResource { - public : - WSound(string filename); - ~WSound(); - Mix_Chunk* getSound(); - private : - Mix_Chunk* sound; -}; - -#endif // WSound.h - diff --git a/src/engine/texts/Text.cpp b/src/engine/texts/Text.cpp deleted file mode 100644 index c93b40f..0000000 --- a/src/engine/texts/Text.cpp +++ /dev/null @@ -1,294 +0,0 @@ -#include "Text.h" -#include "TextManager.h" - -Text::Text(string txt) : wBox(0), hBox(0), text(txt), inBox(""), outBox("") { - computeLength(); - lengthInBox = 0; -} - -Text::~Text() { -} - -void Text::display(int x, int y, int l) { - displayInternal(x, y, l, 0); -} - -void Text::displayOnSurface(int x, int y, Surface* surface, int l) { - if (surface == 0) { - return; - } - displayInternal(x, y, l, surface); -} - -void Text::displayInternal(int x, int y, int l, Surface* surface) { - - int space = TextManager::getInstance()->getWSpace(); - - if (l == -1) { - l = length; - } - - int style = 0; - int count = 0; - int begin = 0; - bool in = false; - for (unsigned int i = 0; i < text.length() && count < l; i++) { - if (in) { - if (text[i] == ']') { - // retrieve the new style - string value = text.substr(begin + 3, i - begin - 1); - int number; - istringstream ss(value); - ss >> number; - style = number; - in = false; - } - } else { - if (text[i] == '[') { - begin = i; - in = true; - } else { - if (surface == 0) { - TextManager::getInstance()->drawLetter(text[i], x, y, style); - } else { - TextManager::getInstance()->drawLetterOnSurface(text[i], x, y, surface, style); - } - x += space; - count++; - } - } - } -} - -void Text::displayBox(int x, int y, int l) { - - if (l == -1) { - l = lengthInBox; - } - - int wSpace = TextManager::getInstance()->getWSpace(); - //int wSize = TextManager::getInstance()->getWSize(); - int hSize = TextManager::getInstance()->getHSize(); - - int nbRows = wBox / wSpace; - - int style = 0; - int count = 0; - int begin = 0; - int countRow = 0; - int countLine = 0; - bool in = false; - bool newWord = true; - for (unsigned int i = 0; i < inBox.length() && count < l; i++) { - if (in) { - if (inBox[i] == ']') { - // retrieve the new style - string value = inBox.substr(begin + 3, i - begin - 1); - int number; - istringstream ss(value); - ss >> number; - style = number; - in = false; - } - } else { - if (inBox[i] == '[') { - begin = i; - in = true; - } else { - - // we check if the current word can be displayed on the current line - if (inBox[i] == ' ') { - if (countRow + 1 > nbRows) { - countRow = 0; - countLine++; - } - newWord = true; - } else { - if (newWord) { - int tmp = wordSize(inBox, i); - if (tmp == 0) { - tmp = 1; - } - - if (countRow + tmp > nbRows) { - countRow = 0; - countLine++; - } - newWord = false; - } - } - - if (countRow == 0 && inBox[i] == ' ' && i + 1 < inBox.length() && inBox[i + 1] != ' ') { - countRow--; - } else { - TextManager::getInstance()->drawLetter(inBox[i], - x + countRow * wSpace, - y + countLine * hSize, - style); - } - count++; - countRow++; - - /*if (countRow >= nbRows) { - countRow = 0; - countLine++; - }*/ - - } - } - } -} - -void Text::setBox(int w, int h) { - wBox = w; - hBox = h; - cutBox(); -} - -bool Text::hasNext() { - return (outBox.length() > 0); -} - -void Text::next() { - text = outBox; - computeLength(); - cutBox(); -} - -int Text::getWBox() { - return wBox; -} - -int Text::getHBox() { - return hBox; -} - -int Text::getLength() { - return length; -} - -int Text::getLengthInBox() { - return lengthInBox; -} - -string Text::getText() { - return text; -} - -char Text::charAtInBox(int i) { - bool in = false; - int count = 0; - for (unsigned int j = 0; j < inBox.length(); j++) { - if (in) { - if (inBox[j] == ']') { - in = false; - } - } else { - if (inBox[j] == '[') { - in = true; - } else { - if (count == i) { - return inBox[j]; - } - count++; - } - } - } - return 0; -} - -void Text::computeLength() { - length = 0; - bool in = false; - for (unsigned int i = 0; i < text.length(); i++) { - if (in) { - if (text[i] == ']') { - in = false; - } - } else { - if (text[i] == '[') { - in = true; - } else { - length++; - } - } - } -} - -void Text::cutBox() { - - lengthInBox = 0; - - int wSpace = TextManager::getInstance()->getWSpace(); - //int wSize = TextManager::getInstance()->getWSize(); - int hSize = TextManager::getInstance()->getHSize(); - - int nbRows = wBox / wSpace; - int nbLines = hBox / hSize; - - int countRow = 0; - int countLine = 0; - bool in = false; - for (unsigned int i = 0; i < text.length(); i++) { - if (in) { - if (text[i] == ']') { - in = false; - } - } else { - if (text[i] == '[') { - in = true; - } else { - - lengthInBox++; - - if (countRow == 0 && text[i] == ' ' && i + 1 < text.length() && text[i + 1] != ' ') { - continue; - } - - countRow++; - - // we check if the current word can be displayed on the current line - int tmp = wordSize(text, i); - if (tmp == 0) { - tmp = 1; - } - if (countRow + tmp - 1 > nbRows) { - countRow = tmp; - countLine++; - - if (countLine >= nbLines) { - inBox = text.substr(0, i); - outBox = text.substr(i, text.length() - i); - return; - } - i += (tmp - 1); - lengthInBox += (tmp - 1); - } - } - } - } - inBox = text; - outBox = ""; -} - -int Text::wordSize(string txt, unsigned int i) { - int size = 0; - bool in = false; - for (; i < text.length(); i++) { - if (in) { - if (text[i] == ']') { - in = false; - } - } else { - if (text[i] == '[') { - in = true; - } else { - if (text[i] == ' ') { - return size; - } - size++; - } - } - } - return size; -} diff --git a/src/engine/texts/Text.h b/src/engine/texts/Text.h deleted file mode 100644 index f307c6a..0000000 --- a/src/engine/texts/Text.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __TEXT_H__ -#define __TEXT_H__ - -#include "../common/Common.h" - -#include "../renderer/Surface.h" - -class Text { - public : - Text(string txt); - ~Text(); - - void display(int x, int y, int l = -1); // display on a line - void displayOnSurface(int x, int y, Surface* surface, int l = -1); // display on a line - void displayBox(int x, int y, int l = -1); // display on a box - - void setBox(int w, int h); - bool hasNext(); - void next(); - - int getWBox(); - int getHBox(); - int getLength(); - int getLengthInBox(); - string getText(); - char charAtInBox(int i); - - private : - void computeLength(); - void cutBox(); // cut text to inBox and outBox - int wordSize(string txt, unsigned int i); // return size of a word from i - - void displayInternal(int x, int y, int l, Surface* surface); // display on a line - - int wBox; - int hBox; - int length; - int lengthInBox; - string text; - string inBox; - string outBox; - -}; - -#endif // Text.h diff --git a/src/engine/texts/TextConfiguration.cpp b/src/engine/texts/TextConfiguration.cpp deleted file mode 100644 index b18df80..0000000 --- a/src/engine/texts/TextConfiguration.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "TextConfiguration.h" - -TextConfiguration::TextConfiguration() : wSpace(0), wSize(0), hSize(0), image(0), textfile("") { -} - -TextConfiguration::~TextConfiguration() { -} - -int TextConfiguration::getWSpace() { - return wSpace; -} - -int TextConfiguration::getWSize() { - return wSize; -} - -int TextConfiguration::getHSize() { - return hSize; -} - - string TextConfiguration::getTextfile() { - return textfile; - } - -WImage* TextConfiguration::getImage() { - return image; -} - -void TextConfiguration::setWSpace(int i) { - wSpace = i; -} - -void TextConfiguration::setWSize(int i) { - wSize = i; -} - -void TextConfiguration::setHSize(int i) { - hSize = i; -} - -void TextConfiguration::setTextfile(string s) { - textfile = s; -} - -void TextConfiguration::setImage(WImage* im) { - image = im; -} diff --git a/src/engine/texts/TextConfiguration.h b/src/engine/texts/TextConfiguration.h deleted file mode 100644 index 6b7b5fc..0000000 --- a/src/engine/texts/TextConfiguration.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __TEXTCONFIGURATION_H__ -#define __TEXTCONFIGURATION_H__ - -#include "../common/Common.h" -#include "../resources/WImage.h" - -class TextConfiguration { - public : - TextConfiguration(); - virtual ~TextConfiguration() = 0; - - virtual string getVariableValue(int textId, int varId) = 0; - virtual string getCommonValue(string tag) = 0; - - int getWSize(); - int getHSize(); - int getWSpace(); - string getTextfile(); - WImage* getImage(); - - protected : - void setWSize(int i); - void setHSize(int i); - void setWSpace(int i); - void setTextfile(string s); - void setImage(WImage* im); - - private : - int wSpace; - int wSize; - int hSize; - WImage* image; - string textfile; -}; - -#endif // TextConfiguration.h diff --git a/src/engine/texts/TextManager.cpp b/src/engine/texts/TextManager.cpp deleted file mode 100644 index 728614d..0000000 --- a/src/engine/texts/TextManager.cpp +++ /dev/null @@ -1,174 +0,0 @@ -#include "TextManager.h" - -#include "../window/WindowManager.h" - -TextManager TextManager::instance=TextManager(); - -TextManager::TextManager() : config(0) { -} - -TextManager::~TextManager() { -} - -TextManager* TextManager::getInstance() { - return &instance; -} - -void TextManager::setConfiguration(TextConfiguration* conf) { - config = conf; - reloadTexts(); -} - -void TextManager::reloadTexts() { - loadTextsFromFile(config->getTextfile()); -} - -int TextManager::getWSpace() { - return config->getWSpace(); -} - -int TextManager::getWSize() { - return config->getWSize(); -} - -int TextManager::getHSize() { - return config->getHSize(); -} - -WImage* TextManager::getImage() { - return config->getImage(); -} - -Text* TextManager::getText(int id) { - string text = texts[id]; - - int begin = -1; - int end = -1; - bool in = false; - for (unsigned int i = 0; i < text.length(); i++) { - - if (in) { - if (text[i] == ']') { - char type = text[begin + 1]; - end = i; - - // only color styles ( like [c=?] ) are ignored - if (text[begin + 2] != '=' || type != 'c') { - if (text[begin + 2] != '=') { - string newValue = config->getCommonValue(text.substr(begin + 1, end - begin - 1)); - text.replace(begin, end - begin + 1, newValue); - i += (newValue.length() - (end - begin + 1)); - } else { - string value = text.substr(begin + 3, end - begin - 1); - int number; - istringstream ss(value); - ss >> number; - string newValue = config->getVariableValue(id, number); - text.replace(begin, end - begin + 1, newValue); - i += (newValue.length() - (end - begin + 1)); - } - } - - in = false; - } - } else { - if (text[i] == '[') { - in = true; - begin = i; - } - } - - - - } - - return new Text(text); -} - -void TextManager::loadTextsFromFile(string filename) { - texts.clear(); - - ifstream file(filename.c_str()); - - if (file) { - string line; - while (getline(file, line)) { - texts.push_back(line); - } - } -} - -void TextManager::drawLetter(char c, int i, int j, int style) { - drawLetterInternal(c, i, j, style, 0); -} - -void TextManager::drawLetterOnSurface(char c, int i, int j, Surface* surface, int style) { - if (surface == 0) { - return; - } - drawLetterInternal(c, i, j, style, surface); -} - -void TextManager::drawLetterInternal(char c, int i, int j, int style, Surface* surface) { - - int x = 0; - int y = style * getHSize(); - int w = getWSize(); - int h = getHSize(); - - int val = (int)c; - - if (val == 32) return; - - //minuscules a-z - if (val >= 97 && val <= 122) { - x = w * (26 + (val - 97)); - } - - //majuscules A-Z - if (val >= 65 && val <= 90) { - x = w * (val - 65); - } - - //chiffres - if (val >= 48 && val <= 57) { - x = w * (52 + (val - 48)); - } - - if (c == 'à') {x = w * 62;} - if (c == 'â') {x = w * 63;} - if (c == 'ä') {x = w * 64;} - if (c == 'ç') {x = w * 65;} - if (c == 'è') {x = w * 66;} - if (c == 'é') {x = w * 67;} - if (c == 'ë') {x = w * 68;} - if (c == 'ê') {x = w * 69;} - if (c == 'ï') {x = w * 70;} - if (c == 'î') {x = w * 71;} - if (c == 'ô') {x = w * 72;} - if (c == 'ö') {x = w * 73;} - if (c == 'ù') {x = w * 74;} - if (c == 'û') {x = w * 75;} - if (c == 'ü') {x = w * 76;} - if (c == '-') {x = w * 77;} - if (c == '.') {x = w * 78;} - if (c == ',') {x = w * 79;} - if (c == '\'') {x = w * 80;} - if (c == '!') {x = w * 81;} - if (c == '?') {x = w * 82;} - if (c == ':') {x = w * 83;} - if (c == '%') {x = w * 84;} - if (c == '(') {x = w * 85;} - if (c == ')') {x = w * 86;} - if (c == '/') {x = w * 87;} - - //sprite.SetSubRect(sf::IntRect(x, y, x + w, y + h)); - //sprite.SetPosition(i, j); - //WindowManager::getInstance()->draw(sprite); - if (surface == 0) { - WindowManager::getInstance()->draw(getImage(), x, y, w, h, i, j); - } else { - surface->put(getImage(), i, j, x, y, w, h); - } - -} diff --git a/src/engine/texts/TextManager.h b/src/engine/texts/TextManager.h deleted file mode 100644 index ce052a5..0000000 --- a/src/engine/texts/TextManager.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __TEXTMANAGER_H__ -#define __TEXTMANAGER_H__ - -#include "../common/Common.h" - -#include "../renderer/Surface.h" - -#include "TextConfiguration.h" -#include "Text.h" - -#include - -class TextManager { - public : - static TextManager* getInstance(); - - void setConfiguration(TextConfiguration* conf); - - int getWSpace(); - int getWSize(); - int getHSize(); - - Text* getText(int id); - WImage* getImage(); - - void drawLetter(char c, int i, int j, int style = 0); - void drawLetterOnSurface(char c, int i, int j, Surface* surface, int style = 0); - - void reloadTexts(); - - private : - TextManager(); - ~TextManager(); - static TextManager instance; - - void loadTextsFromFile(string filename); - - void drawLetterInternal(char c, int i, int j, int style, Surface* surface = 0); - - TextConfiguration* config; - vector texts; -}; - -#endif // TextManager.h diff --git a/src/engine/util/geometry/BoundingBox.cpp b/src/engine/util/geometry/BoundingBox.cpp deleted file mode 100644 index 9b0a3fd..0000000 --- a/src/engine/util/geometry/BoundingBox.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include "BoundingBox.h" - -BoundingBox::BoundingBox() : x(0), y(0), w(0), h(0) { -} - -BoundingBox::BoundingBox(int a, int b, int c, int d) : x(a), y(b), w(c), h(d) { -} - -BoundingBox::~BoundingBox() { -} - -void BoundingBox::setX(int i) { - x = i; -} - -void BoundingBox::setY(int i) { - y = i; -} - -void BoundingBox::setW(int i) { - w = i; -} - -void BoundingBox::setH(int i) { - h = i; -} - -int BoundingBox::getX() { - return x; -} - -int BoundingBox::getY() { - return y; -} - -int BoundingBox::getW() { - return w; -} - -int BoundingBox::getH() { - return h; -} - -bool BoundingBox::intersect(BoundingBox* other) { - return x < other->x + other->w && x + w > other->x && y < other->y + other->h && y + h > other->y; -} - -bool BoundingBox::hasPoint(int i, int j) { - return (i >= x && i < x + w && j >= y && j < y + h); -} diff --git a/src/engine/util/geometry/BoundingBox.h b/src/engine/util/geometry/BoundingBox.h deleted file mode 100644 index 41f51e4..0000000 --- a/src/engine/util/geometry/BoundingBox.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __BOUNDINGBOX_H__ -#define __BOUNDINGBOX_H__ - -/** - this class describes a bounding box -*/ -class BoundingBox { - public : - BoundingBox(); - BoundingBox(int a, int b, int c, int d); - ~BoundingBox(); - void setX(int i); - void setY(int i); - void setW(int i); - void setH(int i); - int getX(); - int getY(); - int getW(); - int getH(); - bool intersect(BoundingBox* other); - bool hasPoint(int i, int j); - - private : - int x; - int y; - int w; - int h; -}; - -#endif // BoundingBox.h diff --git a/src/engine/util/geometry/a.txt b/src/engine/util/geometry/a.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/engine/util/geometry/a.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/engine/util/list/List.cpp b/src/engine/util/list/List.cpp deleted file mode 100644 index 548c65e..0000000 --- a/src/engine/util/list/List.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include "List.h" - -List::List() : head(0), current(0), length(0) { -} - -List::~List() { - delete head; -} - -void List::add(Listable* obj) { - if (obj == 0) { - return; - } - - ListCell* cell = new ListCell(obj); - cell->cleanNext(); - - if (head == 0) { - head = cell; - } else if (head->getContent()->compareTo(obj) < 0) { - ListCell* tmp = head; - head = cell; - cell->add(tmp); - } else { - head->add(cell); - } - length++; -} - -bool List::remove(Listable* obj) { - if (obj == 0) { - return false; - } - if (head->getContent() == obj) { - ListCell* tmp = head; - head = tmp->getNext(); - tmp->cleanNext(); - delete tmp; - length--; - return true; - } - if (head->remove(obj)) { - length--; - return true; - } - return false; -} - -Listable* List::remove(int i) { - if (i < 0 || i >= length) { - return 0; - } - ListCell* tmp = head; - Listable* result = 0; - - if (i == 0) { - result = head->getContent(); - tmp = head->getNext(); - head->cleanNext(); - delete head; - head = tmp; - return result; - } - ListCell* previous = 0; - for (int j = 0; j < i; j++) { - previous = tmp; - tmp = tmp->getNext(); - } - previous->setNext(tmp->getNext()); - - result = tmp->getContent(); - tmp->cleanNext(); - delete tmp; - return result; -} - -int List::size() { - return length; -} - -void List::merge(List* other) { - if (other == 0) { - return; - } - if (head == 0) { - head = other->head; - } else { - head->merge(other->head); - } - length += other->length; -} - -Listable* List::get(int i) { - if (i < 0 || i >= length) { - return 0; - } - ListCell* tmp = head; - for (int j = 0; j < i; j++) { - tmp = tmp->getNext(); - } - if (tmp == 0) return 0; - return tmp->getContent(); -} - -void List::iterateOnFirst() { - current = head; -} - -bool List::hasNext() { - return (current != 0); -} - -Listable* List::getNext() { - ListCell* l = current; - current = current->getNext(); - return l->getContent(); -} diff --git a/src/engine/util/list/List.h b/src/engine/util/list/List.h deleted file mode 100644 index 5232715..0000000 --- a/src/engine/util/list/List.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __LISTE_H__ -#define __LISTE_H__ - -#include "ListCell.h" - -/** - this class describes a sorted list -*/ -class List { - public : - List(); - ~List(); - - void add(Listable* obj); - bool remove(Listable* obj); - Listable* remove(int i); - - int size(); - void merge(List* other); - - Listable* get(int i); - - void iterateOnFirst(); - bool hasNext(); - Listable* getNext(); - - private : - ListCell* head; - ListCell* current; - int length; -}; - -#endif // List.h diff --git a/src/engine/util/list/ListCell.cpp b/src/engine/util/list/ListCell.cpp deleted file mode 100644 index 20256c8..0000000 --- a/src/engine/util/list/ListCell.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "ListCell.h" - -ListCell::ListCell(Listable* obj) : content(obj), next(0) { -} - -ListCell::~ListCell() { - // we don't delete content when we delete the cell - delete next; -} - -int ListCell::compareTo(ListCell* other) { - if (content == 0 || other->content == 0) return 0; - return content->compareTo(other->content); -} - -void ListCell::add(ListCell* obj) { - if (obj == 0) { - return; - } - if (next == 0) { - next = obj; - } else if (next->compareTo(obj) < 0) { - ListCell* tmp = obj->next; - obj->next = next; - next = obj; - next->add(tmp); - } else { - next->add(obj); - } -} - -bool ListCell::remove(Listable* obj) { - if (next == 0) { - return false; - } - if (next->content == obj) { - ListCell* tmp = next->next; - next->cleanNext(); - delete next; - next = tmp; - return true; - } - return next->remove(obj); -} - -void ListCell::merge(ListCell* obj) { - if (obj == 0) { - return; - } - if (next == 0) { - next = obj; - } else if (next->compareTo(obj) < 0) { - ListCell* tmp = obj->next; - obj->next = next; - next = obj; - next->merge(tmp); - } else { - next->merge(obj); - } -} - -Listable* ListCell::getContent() { - return content; -} - -ListCell* ListCell::getNext() { - return next; -} - -void ListCell::setNext(ListCell* obj) { - next = obj; -} - -void ListCell::cleanNext() { - next = 0; -} diff --git a/src/engine/util/list/ListCell.h b/src/engine/util/list/ListCell.h deleted file mode 100644 index 405971d..0000000 --- a/src/engine/util/list/ListCell.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __LISTCELL_H__ -#define __LISTCELL_H__ - -#include "Listable.h" - -class ListCell { - public : - ListCell(Listable* obj); - ~ListCell(); - int compareTo(ListCell* other); // > 0 if this > other - - void add(ListCell* obj); - bool remove(Listable* obj); - void merge(ListCell* obj); - - Listable* getContent(); - - ListCell* getNext(); - void setNext(ListCell* obj); - - void cleanNext(); - - private : - - Listable* content; - ListCell* next; -}; - -#endif // ListCell.h - - - diff --git a/src/engine/util/list/Listable.cpp b/src/engine/util/list/Listable.cpp deleted file mode 100644 index 58ca430..0000000 --- a/src/engine/util/list/Listable.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include "Listable.h" - -Listable::Listable() { -} - -Listable::~Listable() { -} - -int Listable::compareTo(Listable* other) { - return 0; -} diff --git a/src/engine/util/list/Listable.h b/src/engine/util/list/Listable.h deleted file mode 100644 index 7d596e2..0000000 --- a/src/engine/util/list/Listable.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __LISTABLE_H__ -#define __LISTABLE_H__ - -class Listable { - public : - Listable(); - virtual ~Listable() = 0; - virtual int compareTo(Listable* other) = 0; // > 0 if this > other - - //void add(Listable* obj); - //bool remove(Listable* obj); - //void merge(Listable* obj); - - //Listable* getNext(); - //void setNext(Listable* obj); - - //void cleanNext(); - - //private : - - //Listable* next; -}; - -#endif // Listable.h - - - diff --git a/src/engine/util/list/a.txt b/src/engine/util/list/a.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/engine/util/list/a.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/engine/util/physic/SlideManager.cpp b/src/engine/util/physic/SlideManager.cpp deleted file mode 100644 index 80626de..0000000 --- a/src/engine/util/physic/SlideManager.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include "SlideManager.h" - -SlideManager::SlideManager() { - raz(); -} - -SlideManager::~SlideManager() { -} - -void SlideManager::setMoves(int dx, int dy, int vitesse) { - - if (dy != 0) { - if (dy > 0) { - fillHisto(1, vitesse); - fillHisto(0, 0); - } else { - fillHisto(0, vitesse); - fillHisto(1, 0); - } - } else { - fillHisto(0, 0); - fillHisto(1, 0); - } - - if (dx != 0) { - if (dx > 0) { - fillHisto(3, vitesse); - fillHisto(2, 0); - } else { - fillHisto(2, vitesse); - fillHisto(3, 0); - } - - } else { - fillHisto(2, 0); - fillHisto(3, 0); - } -} - -void SlideManager::fillHisto(int dir, int vitesse) { - - int oldSpeed = 0; - if (elan[dir] > 0) { - oldSpeed = histo[dir][elan[dir] - 1]; - } - if (vitesse < oldSpeed) { - computeDistance(dir); - } - - if (vitesse) { - if (elan[dir] < 16) { - elan[dir]++; - } else { - for (int i = 0; i < 15; i++) { - histo[dir][i] = histo[dir][i + 1]; - } - } - histo[dir][elan[dir] - 1] = vitesse; - } else { - elan[dir] = 0; - histo[dir][0] = vitesse; - } - -} - -void SlideManager::computeDistance(int dir) { - int total = 0; - int last = 0; - for (int i = 0; i < elan[dir]; i++) { - last = histo[dir][i]; - total += last; - } - distanceToSlide[dir] = total; - speedToSlide[dir] = last; -} - -int SlideManager::getSlideX() { - - // W - int totalW = 0; - if (distanceToSlide[2] > 0 && speedToSlide[2] > 0) { - int currentSpeed = 0; - if (elan[2] > 0) { - currentSpeed = histo[2][elan[2] - 1]; - } - - if (distanceToSlide[2] > speedToSlide[2]) { - totalW = speedToSlide[2]; - - } else { - totalW = distanceToSlide[2]; - } - distanceToSlide[2] -= totalW; - totalW -= currentSpeed; - if (totalW < 0) { - totalW = 0; - } - } - - // E - int totalE = 0; - if (distanceToSlide[3] > 0 && speedToSlide[3] > 0) { - int currentSpeed = 0; - if (elan[3] > 0) { - currentSpeed = histo[3][elan[3] - 1]; - } - - if (distanceToSlide[3] > speedToSlide[3]) { - totalE = speedToSlide[3]; - - } else { - totalE = distanceToSlide[3]; - } - distanceToSlide[3] -= totalE; - totalE -= currentSpeed; - if (totalE < 0) { - totalE = 0; - } - } - - return totalE - totalW; -} - -int SlideManager::getSlideY() { - - // N - int totalN = 0; - if (distanceToSlide[0] > 0 && speedToSlide[0] > 0) { - int currentSpeed = 0; - if (elan[0] > 0) { - currentSpeed = histo[0][elan[0] - 1]; - } - - if (distanceToSlide[0] > speedToSlide[0]) { - totalN = speedToSlide[0]; - - } else { - totalN = distanceToSlide[0]; - } - distanceToSlide[0] -= totalN; - totalN -= currentSpeed; - if (totalN < 0) { - totalN = 0; - } - } - - // S - int totalS = 0; - if (distanceToSlide[1] > 0 && speedToSlide[1] > 0) { - int currentSpeed = 0; - if (elan[1] > 0) { - currentSpeed = histo[1][elan[1] - 1]; - } - - if (distanceToSlide[1] > speedToSlide[1]) { - totalS = speedToSlide[1]; - - } else { - totalS = distanceToSlide[1]; - } - distanceToSlide[1] -= totalS; - totalS -= currentSpeed; - if (totalS < 0) { - totalS = 0; - } - } - - return totalS - totalN; -} - -void SlideManager::stopX() { - for (int i = 2; i < 4; i++) { - for (int j = 0; j < 16; j++) { - histo[i][j] = 0; - } - speedToSlide[i] = 0; - distanceToSlide[i] = 0; - elan[i] = 0; - } -} - -void SlideManager::stopY() { - for (int i = 0; i < 2; i++) { - for (int j = 0; j < 16; j++) { - histo[i][j] = 0; - } - speedToSlide[i] = 0; - distanceToSlide[i] = 0; - elan[i] = 0; - } -} - -void SlideManager::raz() { - stopY(); - stopX(); -} diff --git a/src/engine/util/physic/SlideManager.h b/src/engine/util/physic/SlideManager.h deleted file mode 100644 index e08a2ac..0000000 --- a/src/engine/util/physic/SlideManager.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __SLIDEMANAGER_H__ -#define __SLIDEMANAGER_H__ - -/** - * this class is to use to handle slides. - * SetMoves is to set current moves to compute if we have to slide. - * GetSlideX and getSlideY return slide. - * StopX and stopY stop the slide. - * raz reinitializes the manager. - */ -class SlideManager { - public : - SlideManager(); - ~SlideManager(); - - void setMoves(int dx, int dy, int vitesse); - - int getSlideX(); - int getSlideY(); - - void stopX(); - void stopY(); - - void raz(); - - private : - - void fillHisto(int dir, int vitesse); - void computeDistance(int dir); - - int histo[4][16]; - int speedToSlide[4]; // speed to begin to slide - int distanceToSlide[4]; - int elan[4]; -}; - -#endif // SlideManager.h - - diff --git a/src/engine/util/physic/a.txt b/src/engine/util/physic/a.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/engine/util/physic/a.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/engine/util/time/Chrono.cpp b/src/engine/util/time/Chrono.cpp deleted file mode 100644 index 13ddaab..0000000 --- a/src/engine/util/time/Chrono.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Chrono.h" - -Chrono::Chrono() { -} - -Chrono::~Chrono() { -} - -void Chrono::reset() { - lastAnimTime = SDL_GetTicks(); -} - -int Chrono::getElapsedTime() { - return SDL_GetTicks() - lastAnimTime; -} diff --git a/src/engine/util/time/Chrono.h b/src/engine/util/time/Chrono.h deleted file mode 100644 index 7fb035c..0000000 --- a/src/engine/util/time/Chrono.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __CHRONO_H__ -#define __CHRONO_H__ - -#include - -class Chrono { - public : - Chrono(); - ~Chrono(); - - void reset(); - int getElapsedTime(); - - private : - - Uint32 lastAnimTime; -}; - -#endif // Chrono.h - - diff --git a/src/engine/util/time/Metronome.cpp b/src/engine/util/time/Metronome.cpp deleted file mode 100644 index a7b9c0c..0000000 --- a/src/engine/util/time/Metronome.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "Metronome.h" - -Metronome::Metronome(int max, int delay) : value(0), max(max), delay(delay) { -} - -Metronome::~Metronome() { -} - -void Metronome::reset() { - value = 0; - chrono.reset(); -} - -void Metronome::loop() { - if (chrono.getElapsedTime() >= delay) { - value++; - if (value >= max) { - value = 0; - } - chrono.reset(); - } -} - -int Metronome::getValue() { - return value; -} diff --git a/src/engine/util/time/Metronome.h b/src/engine/util/time/Metronome.h deleted file mode 100644 index 1952120..0000000 --- a/src/engine/util/time/Metronome.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __METRONOME_H__ -#define __METRONOME_H__ - -#include "Chrono.h" - -class Metronome { - public : - Metronome(int max, int delay); - ~Metronome(); - - void reset(); - void loop(); - int getValue(); - - private : - - int value; - int max; - float delay; - - Chrono chrono; -}; - -#endif // Metronome.h - - diff --git a/src/engine/util/time/a.txt b/src/engine/util/time/a.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/engine/util/time/a.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/engine/util/tree/Node.cpp b/src/engine/util/tree/Node.cpp deleted file mode 100644 index bfdd163..0000000 --- a/src/engine/util/tree/Node.cpp +++ /dev/null @@ -1,310 +0,0 @@ -#include "Node.h" - -Node::Node() : width(1), height(1), previous(0), length(0), size(1), sonId(-1), maxWidth(1), maxHeight(1) { - for (int i = 0; i < 4; i++) { - sons[i] = 0; - } - alive = true; -} - -Node::~Node() { - for (int i = 0; i < 4; i++) { - delete sons[i]; - } -} - -void Node::setBox(int x, int y, int w, int h) { - // only able once and for empty tree - if (length != 0) { - return; - } - bbox.setX(x); - bbox.setY(y); - bbox.setW(w); - bbox.setH(h); - computeLength(); - computeMaxSize(); -} - -void Node::add(Node* obj) { - if (!bbox.hasPoint(obj->getX(), obj->getY())) { - if (previous != 0) { - previous->add(obj); - } else { - delete obj; - } - return; - } - - int id = getSonFromPosition(obj->getX(), obj->getY()); - if (sons[id] == 0) { - sons[id] = obj; - obj->sonId = id; - obj->previous = this; - obj->computeLength(); - obj->computeMaxSize(); - obj->computeBox(); - } else { - sons[id]->add(obj); - } - size++; -} - -bool Node::remove(Node* obj) { - if (!bbox.hasPoint(obj->getX(), obj->getY())) { - return false; - } - int id = getSonFromPosition(obj->getX(), obj->getY()); - if (sons[id] == 0) { - return false; - } - if (sons[id] == obj) { - removeSon(id); - computeLength(); - computeMaxSize(); - return true; - } else { - return sons[id]->remove(obj); - } -} - -int Node::getSonIdWithMaxLength() { - int result = -1; - int max = -1; - for (int i = 0; i < 4; i++) { - if (sons[i] != 0) { - if (sons[i]->length > max) { - max = sons[i]->length; - result = i; - } - } - } - return result; -} - -void Node::permuteNodes(Node* old) { - previous = old->previous; - for (int i = 0; i < 4; i++) { - sons[i] = old->sons[i]; - if (sons[i] != 0) { - sons[i]->previous = this; - } - } - size = old->size; - sonId = old->sonId; - old->clearSons(); - computeLength(); - bbox.setX(old->bbox.getX()); - bbox.setY(old->bbox.getY()); - bbox.setW(old->bbox.getW()); - bbox.setH(old->bbox.getH()); -} - -Node* Node::removeSon(int id) { - if (sons[id] == 0) { - return 0; - } - Node* son = sons[id]; - - int newId = son->getSonIdWithMaxLength(); - - if (newId >= 0) { - Node* newNode = son->removeSon(newId); - sons[id] = newNode; - newNode->permuteNodes(son); - } else { - sons[id] = 0; - } - - for (int i = 0; i < 4; i++) { - son->sons[i] = 0; - } - son->previous = 0; - son->sonId = -1; - computeSize(); - - return son; -} - -void Node::clearSons() { - for (int i = 0; i < 4; i++) { - sons[i] = 0; - } -} - -int Node::getSize() { - return size; -} - -int Node::getLength() { - return length; -} - -void Node::checkPosition() { - if (!bbox.hasPoint(getX(), getY())) { - if (previous == 0) { - alive = false; - return; - } - Node* tmp = previous; - previous->removeSon(sonId); - tmp->add(this); - } -} - -void Node::get(BoundingBox* bb, List* list) { - - if (alive) { - BoundingBox b(getX(), getY(), width, height); - if (b.intersect(bb)) { - list->add(this); - } - } - - for (int i = 0; i < 4; i ++) { - if (sons[i] != 0) { - Node* son = sons[i]; - BoundingBox b2(son->bbox.getX(), son->bbox.getY(), - son->bbox.getW() + son->maxWidth, - son->bbox.getH() + son->maxHeight); - if (b2.intersect(bb)) { - son->get(bb, list); - } - } - } -} - -void Node::computeLength() { - int old = length; - length = 1; - for (int i = 0; i < 4; i++) { - if (sons[i] != 0) { - if (sons[i]->length + 1 > length) { - length = sons[i]->length + 1; - } - } - } - if (length != old && previous != 0) { - previous->computeLength(); - } -} - -void Node::computeMaxSize() { - int oldW = maxWidth; - int oldH = maxHeight; - maxWidth = width; - maxHeight = height; - for (int i = 0; i < 4; i++) { - if (sons[i] != 0) { - if (sons[i]->maxWidth > maxWidth) { - maxWidth = sons[i]->maxWidth; - } - if (sons[i]->maxHeight > maxHeight) { - maxHeight = sons[i]->maxHeight; - } - } - } - if ((maxWidth != oldW || maxHeight != oldH) && previous != 0) { - previous->computeMaxSize(); - } -} - -void Node::computeSize() { - int old = size; - size = 1; - for (int i = 0; i < 4; i++) { - if (sons[i] != 0) { - size += sons[i]->size; - } - } - if (size != old && previous != 0) { - previous->computeSize(); - } -} - -void Node::computeBox() { - if (previous == 0) { - return; - } - - int w = previous->bbox.getW() / 2; - if (w == 0) w = 1; - - int h = previous->bbox.getH() / 2; - if (h == 0) h = 1; - - if (sonId % 2 == 0) { - bbox.setX(previous->bbox.getX()); - } else { - bbox.setX(previous->bbox.getX() + w); - w = previous->bbox.getW() - w; - } - if (sonId / 2 == 0) { - bbox.setY(previous->bbox.getY()); - } else { - bbox.setY(previous->bbox.getY() + h); - h = previous->bbox.getH() - h; - } - bbox.setW(w); - bbox.setH(h); -} - -int Node::getSonFromPosition(int x, int y) { - int result = 0; - if (bbox.getW() > 1 && x >= bbox.getX() + (bbox.getW() / 2)) { - result ++; - } - if (bbox.getH() > 1 && y >= bbox.getY() + (bbox.getH() / 2)) { - result += 2; - } - return result; -} - -bool Node::isAlive() { - return alive; -} - -void Node::killNode() { - alive = false; -} - -void Node::removeDeadNodes() { - for (int i = 0; i < 4; i++) { - Node* node = sons[i]; - if (node != 0) { - node->removeDeadNodes(); - if (!node->alive && !node->isResetable()) { - delete removeSon(i); - } - } - } -} - -bool Node::isResetable() { - return false; -} - -void Node::reset() { -} - -void Node::resetNodes(BoundingBox* bb) { - - for (int i = 0; i < 4; i ++) { - if (sons[i] != 0) { - Node* son = sons[i]; - BoundingBox b2(son->bbox.getX(), son->bbox.getY(), - son->bbox.getW() + son->maxWidth, - son->bbox.getH() + son->maxHeight); - if (b2.intersect(bb)) { - son->resetNodes(bb); - } - } - } - - if (isResetable()) { - BoundingBox b(getX(), getY(), width, height); - if (b.intersect(bb)) { - reset(); - } - } -} diff --git a/src/engine/util/tree/Node.h b/src/engine/util/tree/Node.h deleted file mode 100644 index e79bb54..0000000 --- a/src/engine/util/tree/Node.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __NODE_H__ -#define __NODE_H__ - -#include "../list/List.h" -#include "../geometry/BoundingBox.h" - -/** - this class describes a node -*/ -class Node : public Listable { - public : - Node(); - virtual ~Node() = 0; - - void setBox(int x, int y, int w, int h); - - void add(Node* obj); - bool remove(Node* obj); - Node* removeSon(int id); - void clearSons(); - - int getSize(); - int getLength(); - int getSonIdWithMaxLength(); - - void checkPosition(); - - void get(BoundingBox* bb, List* list); - - void permuteNodes(Node* old); - - bool isAlive(); - void killNode(); - - virtual bool isResetable(); - virtual void reset(); - - void resetNodes(BoundingBox* bb); - - void removeDeadNodes(); - - virtual int getX() = 0; - virtual int getY() = 0; - - protected : - void computeMaxSize(); - - int width; - int height; - - bool alive; - - private : - void computeLength(); - void computeSize(); - void computeBox(); - int getSonFromPosition(int x, int y); - - Node* previous; - Node* sons[4]; - - int length; - int size; - - int sonId; - - int maxWidth; - int maxHeight; - - BoundingBox bbox; -}; - -#endif // Node.h diff --git a/src/engine/util/tree/Quadtree.cpp b/src/engine/util/tree/Quadtree.cpp deleted file mode 100644 index 8718021..0000000 --- a/src/engine/util/tree/Quadtree.cpp +++ /dev/null @@ -1,86 +0,0 @@ -#include "Quadtree.h" - -Quadtree::Quadtree() : root(0) { -} - -Quadtree::~Quadtree() { - delete root; -} - -void Quadtree::setBox(int x, int y, int w, int h) { - box.setX(x - 16); - box.setY(y - 16); - box.setW(w + 32); - box.setH(h + 32); -} - -void Quadtree::add(Node* obj) { - if (root == 0) { - root = obj; - root->setBox(box.getX(), box.getY(), box.getW(), box.getH()); - } else { - root->add(obj); - } -} - -bool Quadtree::remove(Node* obj) { - if (obj == root) { - int sonId = root->getSonIdWithMaxLength(); - if (sonId >= 0) { - Node* son = root->removeSon(sonId); - son->permuteNodes(root); - root = son; - } else { - root = 0; - } - } else { - return root->remove(obj); - } - return true; -} - -int Quadtree::size() { - if (root == 0) { - return 0; - } - return root->getSize(); -} - -int Quadtree::length() { - if (root == 0) { - return 0; - } - return root->getLength(); -} - -void Quadtree::get(BoundingBox* bb, List* list) { - if (root != 0) { - root->get(bb, list); - } -} - -void Quadtree::resetNodes(BoundingBox* bb) { - if (root != 0) { - root->resetNodes(bb); - } -} - -void Quadtree::getAll(List* list) { - get(&box, list); -} - -void Quadtree::removeDeadNodes() { - if (root == 0) { - return; - } - while (root != 0 && !root->isAlive() && !root->isResetable()) { - Node* tmp = root; - remove(tmp); - tmp->clearSons(); - delete tmp; - } - if (root != 0) { - root->removeDeadNodes(); - } -} - diff --git a/src/engine/util/tree/Quadtree.h b/src/engine/util/tree/Quadtree.h deleted file mode 100644 index f6799f8..0000000 --- a/src/engine/util/tree/Quadtree.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __QUADTREE_H__ -#define __QUADTREE_H__ - -#include "Node.h" -#include "../list/List.h" -#include "../geometry/BoundingBox.h" - -/** - this class describes a quadtree -*/ -class Quadtree { - public : - Quadtree(); - ~Quadtree(); - - void setBox(int x, int y, int w, int h); - - void add(Node* obj); - bool remove(Node* obj); - - int size(); - int length(); - - void get(BoundingBox* box, List* list); - void getAll(List* list); - - void resetNodes(BoundingBox* bb); - - void removeDeadNodes(); - - private : - Node* root; - BoundingBox box; -}; - -#endif // Quadtree.h diff --git a/src/engine/util/tree/a.txt b/src/engine/util/tree/a.txt deleted file mode 100644 index 8b13789..0000000 --- a/src/engine/util/tree/a.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/engine/window/Event.cpp b/src/engine/window/Event.cpp deleted file mode 100644 index e6c1532..0000000 --- a/src/engine/window/Event.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include "Event.h" - -#undef SDLK_SPACE -#undef SDLK_LSHIFT -#undef SDLK_p -#undef SDLK_LCTRL -#undef SDLK_z -#undef SDLK_x -#undef SDLK_c -#undef SDLK_m -#define SDLK_z 308 //A ATTACK -#define SDLK_SPACE 308 //A TALK/READ -#define SDLK_LSHIFT 306 //B RUN -#define SDLK_c 306 //B PUSH/PULL -#define SDLK_LCTRL 8 //R LOOK AROUND -#define SDLK_x 32 //Y USE ITEM -#define SDLK_p 304 //X MAP -#define SDLK_m 9 //L ENCYCLOPEDIA - - -Event::Event() { - for (int i = 0; i < NB_KEYS; i++) { - current[i] = false; - past[i] = false; - } -} - -Event::~Event() { -} - -void Event::update(Uint8* keys) { - for (int i = 0; i < NB_KEYS; i++) { - past[i] = current[i]; - current[i] = false; - } - - current[kUp] = keys[SDLK_UP]; - current[kDown] = keys[SDLK_DOWN]; - current[kLeft] = keys[SDLK_LEFT]; - current[kRight] = keys[SDLK_RIGHT]; - - current[kA] = keys[SDLK_a]; - current[kB] = keys[SDLK_b]; - current[kC] = keys[SDLK_c]; - current[kD] = keys[SDLK_d]; - current[kE] = keys[SDLK_e]; - current[kF] = keys[SDLK_f]; - current[kG] = keys[SDLK_g]; - current[kH] = keys[SDLK_h]; - current[kI] = keys[SDLK_i]; - current[kJ] = keys[SDLK_j]; - current[kK] = keys[SDLK_k]; - current[kL] = keys[SDLK_l]; - current[kM] = keys[SDLK_m]; - current[kN] = keys[SDLK_n]; - current[kO] = keys[SDLK_o]; - current[kP] = keys[SDLK_p]; - current[kQ] = keys[SDLK_q]; - current[kR] = keys[SDLK_r]; - current[kS] = keys[SDLK_s]; - current[kT] = keys[SDLK_t]; - current[kU] = keys[SDLK_u]; - current[kV] = keys[SDLK_v]; - current[kW] = keys[SDLK_w]; - current[kX] = keys[SDLK_x]; - current[kY] = keys[SDLK_y]; - current[kZ] = keys[SDLK_z]; - - current[k0] = keys[SDLK_0] || keys[SDLK_KP0]; - current[k1] = keys[SDLK_1] || keys[SDLK_KP1]; - current[k2] = keys[SDLK_2] || keys[SDLK_KP2]; - current[k3] = keys[SDLK_3] || keys[SDLK_KP3]; - current[k4] = keys[SDLK_4] || keys[SDLK_KP4]; - current[k5] = keys[SDLK_5] || keys[SDLK_KP5]; - current[k6] = keys[SDLK_6] || keys[SDLK_KP6]; - current[k7] = keys[SDLK_7] || keys[SDLK_KP7]; - current[k8] = keys[SDLK_8] || keys[SDLK_KP8]; - current[k9] = keys[SDLK_9] || keys[SDLK_KP9]; - - current[kComma] = keys[SDLK_COMMA]; - current[kEscape] = keys[SDLK_ESCAPE]; - current[kTab] = keys[SDLK_TAB]; - current[kShift] = keys[SDLK_CAPSLOCK] || keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]; - current[kCtrl] = keys[SDLK_LCTRL] || keys[SDLK_RCTRL]; - current[kAlt] = keys[SDLK_LALT] || keys[SDLK_RALT]; - current[kSpace] = keys[SDLK_SPACE]; - current[kReturn] = keys[SDLK_RETURN] || keys[SDLK_KP_ENTER]; - - current[QUIT] = false; - current[RESIZE] = current[kCtrl] && current[kReturn]; - current[QUIT_FORCED] = current[kAlt] && keys[SDLK_F4]; - - current[kF1] = keys[SDLK_F1]; - - if (current[RESIZE]) { - current[kReturn] = false; - } - -} - -bool Event::isDown(Keys key) { - if (current == 0) { - return false; - } - return current[key]; -} - -bool Event::isPushed(Keys key) { - if (current == 0 || past == 0) { - return false; - } - return current[key] && !past[key]; -} - -void Event::setEvent(Keys key, bool b) { - if (current != 0) { - current[key] = b; - } -} diff --git a/src/engine/window/Event.h b/src/engine/window/Event.h deleted file mode 100644 index 05e4894..0000000 --- a/src/engine/window/Event.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __EVENT_H__ -#define __EVENT_H__ - -#include - -enum Keys {kA, kZ, kE, kR, kT, kY, kU, kI, kO, kP, kQ, kS, kD, kF, kG, kH, kJ, - kK, kL, kM, kW, kX, kC, kV, kB, kN, kComma, kEscape, kTab, kShift, kCtrl, - kAlt, kSpace, kReturn, k0, k1, k2, k3, k4, k5, k6, k7, k8, k9, QUIT, RESIZE, - kUp, kDown, kLeft, kRight, QUIT_FORCED, kF1, NB_KEYS}; - -class Event { - public : - Event(); - ~Event(); - - void update(Uint8* keys); - - bool isDown(Keys key); - bool isPushed(Keys key); - - void setEvent(Keys key, bool b); - private : - bool current[NB_KEYS]; - bool past[NB_KEYS]; -}; - -#endif // Event.h diff --git a/src/engine/window/Timer.cpp b/src/engine/window/Timer.cpp deleted file mode 100644 index 66b6330..0000000 --- a/src/engine/window/Timer.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Timer.h" - -Timer::Timer() { -} - -Timer::~Timer() { -} - -void Timer::reset() { - lastAnimTime = SDL_GetTicks(); -} - -int Timer::getElapsedTime() { - return SDL_GetTicks() - lastAnimTime; -} diff --git a/src/engine/window/Timer.h b/src/engine/window/Timer.h deleted file mode 100644 index 09e6e36..0000000 --- a/src/engine/window/Timer.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __TIMER_H__ -#define __TIMER_H__ - -#include - -class Timer { - public : - Timer(); - ~Timer(); - - void reset(); - int getElapsedTime(); - - private : - - Uint32 lastAnimTime; -}; - -#endif // Timer.h diff --git a/src/engine/window/WindowManager.cpp b/src/engine/window/WindowManager.cpp deleted file mode 100644 index 7f610b0..0000000 --- a/src/engine/window/WindowManager.cpp +++ /dev/null @@ -1,111 +0,0 @@ -#include "WindowManager.h" - -WindowManager WindowManager::instance=WindowManager(); - -WindowManager::WindowManager() : isFullScreen(FULLSCREEN), event(0), window(0), windowTmp(0), open(false) { -} - -WindowManager::~WindowManager() { - delete event; -} - -WindowManager* WindowManager::getInstance() { - return &instance; -} - -int WindowManager::createWindow(string title, string iconName) { - if (window == 0) { - if(SDL_Init(SDL_INIT_VIDEO) == -1) { - printf("Could not load SDL : %s\n", SDL_GetError()); - return -1; - } - atexit(SDL_Quit); - - SDL_WM_SetCaption(title.c_str(), NULL); - SDL_Surface* icon = SDL_LoadBMP(iconName.c_str()); - SDL_SetColorKey(icon, SDL_SRCCOLORKEY, SDL_MapRGB(icon->format,0,0,0)); - SDL_WM_SetIcon(icon, NULL); - - SDL_ShowCursor(isFullScreen ? SDL_DISABLE : SDL_DISABLE); - - window = SDL_SetVideoMode(320, 240, 16, isFullScreen ? SDL_SWSURFACE: SDL_SWSURFACE); - windowTmp = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 240, 16, 0, 0, 0, 0); - - //if (isFullScreen) SDL_Delay(2000); // wait the window is displayed - - event = new Event(); - lastAnimTime = SDL_GetTicks(); - open = true; - } - return 0; -} - -bool WindowManager::isOpened() { - return open; -} - -Event* WindowManager::getEvent() { - - - Uint8* keys = SDL_GetKeyState(NULL); - - event->update(keys); - - if (event->isPushed(RESIZE)) { - isFullScreen = ! isFullScreen; - - isFullScreen ? SDL_ShowCursor(SDL_DISABLE) : SDL_ShowCursor(SDL_DISABLE); - window = SDL_SetVideoMode(320, 240, 16, isFullScreen ? SDL_SWSURFACE: SDL_SWSURFACE); - - } - - SDL_Event sdlEvent; - while (SDL_PollEvent(&sdlEvent)) { - switch (sdlEvent.type) { - case SDL_QUIT : event->setEvent(QUIT, true); break; - } - } - - return event; -} - -void WindowManager::close() { - open = false; -} - -void WindowManager::display() { - - SDL_Surface* tmp = zoomSurface(windowTmp, 1, 1, 0); - SDL_BlitSurface(tmp, NULL, window, NULL); - SDL_FreeSurface(tmp); - - SDL_Flip(window); - - if (SDL_GetTicks() < lastAnimTime + (1000 / 60)) SDL_Delay(lastAnimTime + (1000 / 60) - SDL_GetTicks()); - lastAnimTime = SDL_GetTicks(); -} - -void WindowManager::draw(SDL_Surface* object) { - SDL_BlitSurface(object, NULL, windowTmp, NULL); -} - -void WindowManager::draw(WImage* image, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int alpha) { - SDL_Rect src; - src.x = srcX; - src.y = srcY; - src.w = srcW; - src.h = srcH; - - SDL_Rect dst; - dst.x = dstX; - dst.y = dstY; - - SDL_BlitSurface(image->getImage(), &src, windowTmp, &dst); -} - -void WindowManager::exit() { - SDL_FreeSurface(windowTmp); - - SDL_ShowCursor(SDL_DISABLE); - SDL_Quit(); -} diff --git a/src/engine/window/WindowManager.h b/src/engine/window/WindowManager.h deleted file mode 100644 index 8586f3b..0000000 --- a/src/engine/window/WindowManager.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __WINDOWMANAGER_H__ -#define __WINDOWMANAGER_H__ - -#include -#include -#include - -#include "../common/Common.h" -#include "Event.h" - -#include "../resources/WImage.h" - -class WindowManager { - public : - static WindowManager* getInstance(); - int createWindow(string title, string icon); - bool isOpened(); - Event* getEvent(); - void close(); - void display(); - - void draw(WImage* image, int srcX, int srcY, int srcW, int srcH, int dstX, int dstY, int alpha = 255); - void draw(SDL_Surface* object); - - void exit(); - - private : - WindowManager(); - ~WindowManager(); - static WindowManager instance; - - bool isFullScreen; - string name; - Event* event; - - SDL_Surface* window; - SDL_Surface* windowTmp; - - Uint32 lastAnimTime; - bool open; -}; - -#endif // WindowManager.h diff --git a/src/game/GlobalSave.cpp b/src/game/GlobalSave.cpp deleted file mode 100644 index 7e2c3f3..0000000 --- a/src/game/GlobalSave.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "GlobalSave.h" - -GlobalSave GlobalSave::instance = GlobalSave(); - -GlobalSave* GlobalSave::getInstance() { - return &instance; -} -GlobalSave::GlobalSave() { - init(); - load(); -} - -GlobalSave::~GlobalSave() { -} - -void GlobalSave::init() { - scoreArc = 0; - bestNormalTime = -1; - normalFull = false; - normalUlti = false; - normalRush = false; - bestExpertTime = -1; - expertFull = false; - expertUlti = false; - expertRush = false; - glass = false; - unlockLink = false; - unlockExpert = false; - unlockOniLink = false; -} - -void GlobalSave::load() { - ifstream f("saves/records.dat", ios::in | ios::binary); - if(!f.is_open()) { - return; - } - f.read((char *)&scoreArc,sizeof(int)); - f.read((char *)&bestNormalTime,sizeof(int)); - f.read((char *)&normalFull,sizeof(bool)); - f.read((char *)&normalUlti,sizeof(bool)); - f.read((char *)&normalRush,sizeof(bool)); - f.read((char *)&bestExpertTime,sizeof(int)); - f.read((char *)&expertFull,sizeof(bool)); - f.read((char *)&expertUlti,sizeof(bool)); - f.read((char *)&expertRush,sizeof(bool)); - f.read((char *)&glass,sizeof(bool)); - - f.close(); -} - -void GlobalSave::save() { - ofstream f("saves/records.dat", ios::out | ios::binary); - f.write((char *)&scoreArc,sizeof(int)); - f.write((char *)&bestNormalTime,sizeof(int)); - f.write((char *)&normalFull,sizeof(bool)); - f.write((char *)&normalUlti,sizeof(bool)); - f.write((char *)&normalRush,sizeof(bool)); - f.write((char *)&bestExpertTime,sizeof(int)); - f.write((char *)&expertFull,sizeof(bool)); - f.write((char *)&expertUlti,sizeof(bool)); - f.write((char *)&expertRush,sizeof(bool)); - f.write((char *)&glass,sizeof(bool)); - f.close(); -} - -void GlobalSave::update(Save* sv, bool endGame) { - bool needToSave = false; - - if (sv->getCoffre(0, 11) > scoreArc) { - scoreArc = sv->getCoffre(0, 11); - needToSave = true; - } - - if (endGame) { - if (sv->getCoffre(9, 28) && !sv->isExpert() && (sv->getTime() < bestNormalTime || bestNormalTime == -1)) { - bestNormalTime = sv->getTime(); - needToSave = true; - } - if (!normalFull && sv->getCoffre(9, 28) && !sv->isExpert() && sv->getCompletion() == 100) { - normalFull = true; - if (isExpertUnlocked()) unlockExpert = true; - needToSave = true; - } - if (!normalUlti && sv->getCoffre(9, 28) && !sv->isExpert() && !sv->getDeaths()) { - normalUlti = true; - if (isExpertUnlocked()) unlockExpert = true; - needToSave = true; - } - if (!normalRush && sv->getCoffre(9, 28) && !sv->isExpert() && sv->getTime() < 25200) { - normalRush = true; - if (isExpertUnlocked()) unlockExpert = true; - needToSave = true; - } - if (sv->getCoffre(9, 28) && sv->isExpert() && (sv->getTime() < bestExpertTime || bestExpertTime == -1)) { - bestExpertTime = sv->getTime(); - needToSave = true; - } - if (!expertFull && sv->getCoffre(9, 28) && sv->isExpert() && sv->getCompletion() == 100) { - expertFull = true; - if (isOniLinkUnlocked()) unlockOniLink = true; - needToSave = true; - } - if (!expertUlti && sv->getCoffre(9, 28) && sv->isExpert() && !sv->getDeaths()) { - expertUlti = true; - if (isOniLinkUnlocked()) unlockOniLink = true; - needToSave = true; - } - if (!expertRush && sv->getCoffre(9, 28) && sv->isExpert() && sv->getTime() < 25200) { - expertRush = true; - if (isOniLinkUnlocked()) unlockOniLink = true; - needToSave = true; - } - if (!glass && sv->getCoffre(9, 28)) { - unlockLink = true; - glass = true; - needToSave = true; - } - } - - if (needToSave) { - save(); - } -} - -int GlobalSave::getScoreArc() {return scoreArc;} -int GlobalSave::getBestNormalTime() {return bestNormalTime;} -bool GlobalSave::isNormalFull() {return normalFull;} -bool GlobalSave::isNormalUlti() {return normalUlti;} -bool GlobalSave::isNormalRush() {return normalRush;} -int GlobalSave::getBestExpertTime() {return bestExpertTime;} -bool GlobalSave::isExpertFull() {return expertFull;} -bool GlobalSave::isExpertUlti() {return expertUlti;} -bool GlobalSave::isExpertRush() {return expertRush;} -bool GlobalSave::isHolydaysLinkUnlock() {return glass;} -bool GlobalSave::isExpertUnlocked() {return normalFull && normalUlti && normalRush;} -bool GlobalSave::isOniLinkUnlocked() {return expertFull && expertUlti && expertRush;} - -bool GlobalSave::haveUnlockLink() {return unlockLink;} -bool GlobalSave::haveUnlockExpert() {return unlockExpert;} -bool GlobalSave::haveUnlockOniLink() {return unlockOniLink;} - -void GlobalSave::resetUnlock() { - unlockLink = false; - unlockExpert = false; - unlockOniLink = false; -} diff --git a/src/game/GlobalSave.h b/src/game/GlobalSave.h deleted file mode 100644 index 68735c8..0000000 --- a/src/game/GlobalSave.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __GLOBALSAVE_H__ -#define __GLOBALSAVE_H__ - -#include "Save.h" - -class GlobalSave { - public : - static GlobalSave* getInstance(); - - void save(); - - void update(Save* save, bool endGame); - - int getScoreArc(); - int getBestNormalTime(); - bool isNormalFull(); - bool isNormalUlti(); - bool isNormalRush(); - int getBestExpertTime(); - bool isExpertFull(); - bool isExpertUlti(); - bool isExpertRush(); - - bool isHolydaysLinkUnlock(); - bool isExpertUnlocked(); - bool isOniLinkUnlocked(); - - bool haveUnlockLink(); - bool haveUnlockExpert(); - bool haveUnlockOniLink(); - void resetUnlock(); - - private : - GlobalSave(); - ~GlobalSave(); - static GlobalSave instance; - - void init(); - void load(); - - int scoreArc; - int bestNormalTime; - bool normalFull; - bool normalUlti; - bool normalRush; - int bestExpertTime; - bool expertFull; - bool expertUlti; - bool expertRush; - bool glass; - - bool unlockLink; - bool unlockExpert; - bool unlockOniLink; - -}; - -#endif // GlobalSave.h diff --git a/src/game/MainController.cpp b/src/game/MainController.cpp deleted file mode 100644 index d2d71dc..0000000 --- a/src/game/MainController.cpp +++ /dev/null @@ -1,124 +0,0 @@ -#include "MainController.h" - -MainController MainController::instance=MainController(); - -MainController::MainController() : step(LOGO) { - nextStep = step; -} - -MainController::~MainController() { -} - -MainController* MainController::getInstance() { - return &instance; -} - -void MainController::init() { - logo = new LogoController(); - title = new TitleController(); - menu = new MenuController(); - opening = new OpeningController(); - game = new GameController(); - ending = new EndingController(); -} - -void MainController::close() { - delete logo; - delete title; - delete menu; - delete opening; - delete game; - delete ending; -} - -void MainController::control(Event* event) { - - if (!transition.isRunning()) { - handleEvents(event); - loop(); - } - draw(); - - if (transition.isRunning()) { - transition.loop(); - transition.draw(); - - if (transition.isWaiting()) { - setInternalStep(nextStep); - transition.restart(); - } else if (transition.isAchieved()) { - transition.reset(); - } - } - -} - -void MainController::handleEvents(Event* event) { - switch(step) { - case LOGO : logo->handleEvents(event); break; - case TITRE : title->handleEvents(event); break; - case MENU : menu->handleEvents(event); break; - case OPENING : opening->handleEvents(event); break; - case GAME : game->handleEvents(event); break; - case ENDING : ending->handleEvents(event); break; - default : break; - } -} - -void MainController::loop() { - switch(step) { - case LOGO : logo->loop(); break; - case TITRE : title->loop(); break; - case MENU : menu->loop(); break; - case OPENING : opening->loop(); break; - case GAME : game->loop(); break; - case ENDING : ending->loop(); break; - default : break; - } -} - -void MainController::draw() { - switch(step) { - case LOGO : logo->draw(); break; - case TITRE : title->draw(); break; - case MENU : menu->draw(); break; - case OPENING : opening->draw(); break; - case GAME : game->draw(); break; - case ENDING : ending->draw(); break; - default : break; - } -} - -void MainController::setInternalStep(MainStep newStep) { - step = newStep; - switch(step) { - case LOGO : logo->launch(); break; - case TITRE : title->launch(); break; - case MENU : menu->launch(); break; - case OPENING : opening->launch(); break; - case GAME : game->launch(); break; - case ENDING : ending->launch(); break; - default : break; - } -} - -void MainController::setStep(MainStep newStep) { - nextStep = newStep; - transition.start(); -} - -MenuController* MainController::getMenuController() { - return menu; -} - -GameController* MainController::getGameController() { - return game; -} - -OpeningController* MainController::getOpeningController() { - return opening; -} - -EndingController* MainController::getEndingController() { - return ending; -} diff --git a/src/game/MainController.h b/src/game/MainController.h deleted file mode 100644 index d96cb9b..0000000 --- a/src/game/MainController.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __MAINCONTROLLER_H__ -#define __MAINCONTROLLER_H__ - -#include "../engine/common/Common.h" -#include "../engine/window/Event.h" -#include "../engine/renderer/SimpleTransition.h" - -#include "logo/LogoController.h" -#include "title/TitleController.h" -#include "menu/MenuController.h" -#include "opening/OpeningController.h" -#include "game/GameController.h" -#include "ending/EndingController.h" - -enum MainStep {LOGO, TITRE, MENU, OPENING, GAME, ENDING}; - -class MainController { - public : - static MainController* getInstance(); - - void init(); - void close(); - - void control(Event* event); // dispatch event, display scene, etc. - void setStep(MainStep newStep); - - void setInternalStep(MainStep newStep); // set step without transition - - MenuController* getMenuController(); - GameController* getGameController(); - OpeningController* getOpeningController(); - EndingController* getEndingController(); - - private : - MainController(); - ~MainController(); - static MainController instance; - - void handleEvents(Event* event); - void loop(); - void draw(); - - - MainStep step; - MainStep nextStep; - - SimpleTransition transition; - - LogoController* logo; - TitleController* title; - MenuController* menu; - GameController* game; - OpeningController* opening; - EndingController* ending; -}; - -#endif // MainController.h diff --git a/src/game/Save.cpp b/src/game/Save.cpp deleted file mode 100644 index fb7afe7..0000000 --- a/src/game/Save.cpp +++ /dev/null @@ -1,324 +0,0 @@ -#include "Save.h" - -#include "GlobalSave.h" - -Save::Save(int i) : id (i), loaded(false) { - init(); - load(); -} - -Save::~Save() { -} - -void Save::init() { - // set default values - map = 1; - x = 16 * 87; - y = 16 * 48; - direction = S; - tunique = 1; - epee = 0; - bouclier = 0; - life = 0;//6; - maxLife = 6; - magic = 0; - maxMagic = 0;//32; - naviMagic = 0; - naviMaxMagic = 0; // set to 20 after the tutoriel - lvlHeal = 1; - lvlAtt = 1; - lvlDef = 1; - rupees = 0; - maxRupees = 0;//99; - arrows = 0; - maxArrows = 0;//30; - recupArrows = 0; - bombs = 0; - maxBombs = 0;//10; - recupBombs = 0; - lifeToAdd = 0; - magicToAdd = 0; - rupeesToAdd = 0; - deaths = 0; - avancement = AV_START; - time = 0; - - for (int i = 0; i < NB_EQPMT; i++) { - equipment[i] = 0; - } - - for (int i = 0; i < NB_FLACON; i++) { - flacons[i] = 0; - } - - for (int i = 0; i < NB_QUART_COEUR; i++) { - quartCoeur[i] = 0; - } - - for (int i = 0; i < NB_COEUR; i++) { - coeur[i] = 0; - } - - for (int i = 0; i < NB_GEMME_FORCE; i++) { - gemmeForce[i] = 0; - } - - for (int i = 0; i < NB_COQUILLAGES; i++) { - coquillages[i] = 0; - } - - for (int i = 0; i < NB_MEDAILLONS; i++) { - medaillons[i] = 0; - } - - for (int i = 0; i < NB_TROC; i++) { - troc[i] = -1; - } - - for (int j = 0; j < COFFRES_MAX_SIZE; j++) { - for (int i = 0; i < NB_COFFRES; i++) { - coffres[i][j] = 0; - } - } - - for (int i = 0; i < NB_FAIRIES; i++) { - fees[i] = 0; - } - - for (int j = 0; j < MAX_ROOMS_Y; j++) { - for (int i = 0; i < MAX_ROOMS_X; i++) { - for (int d = 0; d < NB_DONJON; d++) { - rooms[d][i][j] = 0; - } - } - } - - expert = false; -} - -void Save::load() { - ostringstream im; - im << id; - ifstream f(("saves/znq" + im.str() + ".dat").c_str(), ios::in | ios::binary); - if(!f.is_open()) { - return; - } - f.read((char *)&map,sizeof(int)); - f.read((char *)&x,sizeof(int)); - f.read((char *)&y,sizeof(int)); - f.read((char *)&direction,sizeof(int)); - f.read((char *)&tunique,sizeof(int)); - f.read((char *)&epee,sizeof(int)); - f.read((char *)&bouclier,sizeof(int)); - f.read((char *)&life,sizeof(int)); - f.read((char *)&maxLife,sizeof(int)); - f.read((char *)&magic,sizeof(int)); - f.read((char *)&maxMagic,sizeof(int)); - f.read((char *)&naviMagic,sizeof(int)); - f.read((char *)&naviMaxMagic,sizeof(int)); - f.read((char *)&lvlHeal,sizeof(int)); - f.read((char *)&lvlAtt,sizeof(int)); - f.read((char *)&lvlDef,sizeof(int)); - f.read((char *)&rupees,sizeof(int)); - f.read((char *)&maxRupees,sizeof(int)); - f.read((char *)&arrows,sizeof(int)); - f.read((char *)&maxArrows,sizeof(int)); - f.read((char *)&recupArrows,sizeof(int)); - f.read((char *)&bombs,sizeof(int)); - f.read((char *)&maxBombs,sizeof(int)); - f.read((char *)&recupBombs,sizeof(int)); - f.read((char *)&lifeToAdd,sizeof(int)); - f.read((char *)&magicToAdd,sizeof(int)); - f.read((char *)&rupeesToAdd,sizeof(int)); - f.read((char *)&deaths,sizeof(int)); - f.read((char *)&avancement,sizeof(int)); - f.read((char *)&time,sizeof(int)); - for (int i = 0; i < NB_EQPMT - 1; i++) f.read((char *)&equipment[i],sizeof(int)); - for (int i = 0; i < NB_FLACON; i++) f.read((char *)&flacons[i],sizeof(int)); - for (int i = 0; i < NB_QUART_COEUR; i++) f.read((char *)&quartCoeur[i],sizeof(int)); - for (int i = 0; i < NB_COEUR; i++) f.read((char *)&coeur[i],sizeof(int)); - for (int i = 0; i < NB_GEMME_FORCE; i++) f.read((char *)&gemmeForce[i],sizeof(int)); - for (int i = 0; i < NB_COQUILLAGES; i++) f.read((char *)&coquillages[i],sizeof(int)); - for (int i = 0; i < NB_MEDAILLONS; i++) f.read((char *)&medaillons[i],sizeof(int)); - for (int i = 0; i < NB_TROC; i++) f.read((char *)&troc[i],sizeof(int)); - for (int i = 0; i < NB_FAIRIES; i++) f.read((char *)&fees[i],sizeof(int)); - for (int j = 0; j < COFFRES_MAX_SIZE; j++) for (int i = 0; i < NB_COFFRES; i++) f.read((char *)&coffres[i][j],sizeof(int)); - for (int j = 0; j < MAX_ROOMS_Y; j++) for (int i = 0; i < MAX_ROOMS_X; i++) for (int d = 0; d < NB_DONJON; d++) f.read((char *)&rooms[d][i][j],sizeof(int)); - f.read((char *)&expert,sizeof(bool)); - f.close(); - loaded = true; -} - -void Save::save(bool endGame) { - ostringstream im; - im << id; - ofstream f(("saves/znq" + im.str() + ".dat").c_str(), ios::out | ios::binary); - f.write((char *)&map,sizeof(int)); - f.write((char *)&x,sizeof(int)); - f.write((char *)&y,sizeof(int)); - f.write((char *)&direction,sizeof(int)); - f.write((char *)&tunique,sizeof(int)); - f.write((char *)&epee,sizeof(int)); - f.write((char *)&bouclier,sizeof(int)); - f.write((char *)&life,sizeof(int)); - f.write((char *)&maxLife,sizeof(int)); - f.write((char *)&magic,sizeof(int)); - f.write((char *)&maxMagic,sizeof(int)); - f.write((char *)&naviMagic,sizeof(int)); - f.write((char *)&naviMaxMagic,sizeof(int)); - f.write((char *)&lvlHeal,sizeof(int)); - f.write((char *)&lvlAtt,sizeof(int)); - f.write((char *)&lvlDef,sizeof(int)); - f.write((char *)&rupees,sizeof(int)); - f.write((char *)&maxRupees,sizeof(int)); - f.write((char *)&arrows,sizeof(int)); - f.write((char *)&maxArrows,sizeof(int)); - f.write((char *)&recupArrows,sizeof(int)); - f.write((char *)&bombs,sizeof(int)); - f.write((char *)&maxBombs,sizeof(int)); - f.write((char *)&recupBombs,sizeof(int)); - f.write((char *)&lifeToAdd,sizeof(int)); - f.write((char *)&magicToAdd,sizeof(int)); - f.write((char *)&rupeesToAdd,sizeof(int)); - f.write((char *)&deaths,sizeof(int)); - f.write((char *)&avancement,sizeof(int)); - f.write((char *)&time,sizeof(int)); - for (int i = 0; i < NB_EQPMT - 1; i++) f.write((char *)&equipment[i],sizeof(int)); - for (int i = 0; i < NB_FLACON; i++) f.write((char *)&flacons[i],sizeof(int)); - for (int i = 0; i < NB_QUART_COEUR; i++) f.write((char *)&quartCoeur[i],sizeof(int)); - for (int i = 0; i < NB_COEUR; i++) f.write((char *)&coeur[i],sizeof(int)); - for (int i = 0; i < NB_GEMME_FORCE; i++) f.write((char *)&gemmeForce[i],sizeof(int)); - for (int i = 0; i < NB_COQUILLAGES; i++) f.write((char *)&coquillages[i],sizeof(int)); - for (int i = 0; i < NB_MEDAILLONS; i++) f.write((char *)&medaillons[i],sizeof(int)); - for (int i = 0; i < NB_TROC; i++) f.write((char *)&troc[i],sizeof(int)); - for (int i = 0; i < NB_FAIRIES; i++) f.write((char *)&fees[i],sizeof(int)); - for (int j = 0; j < COFFRES_MAX_SIZE; j++) for (int i = 0; i < NB_COFFRES; i++) f.write((char *)&coffres[i][j],sizeof(int)); - for (int j = 0; j < MAX_ROOMS_Y; j++) for (int i = 0; i < MAX_ROOMS_X; i++) for (int d = 0; d < NB_DONJON; d++) f.write((char *)&rooms[d][i][j],sizeof(int)); - f.write((char *)&expert,sizeof(bool)); - f.close(); - GlobalSave::getInstance()->update(this, endGame); - loaded = true; -} - -void Save::erase() { - ostringstream im; - im << id; - remove(("saves/znq" + im.str() + ".dat").c_str()); - init(); - loaded = false; -} - -bool Save::isLoaded() {return loaded;} - -int Save::getMap() {return map;} -int Save::getX() {return x;} -int Save::getY() {return y;} -Direction Save::getDirection() {return direction;} -int Save::getTunique() {return tunique;} -int Save::getEpee() {return epee;} -int Save::getBouclier() {return bouclier;} -int Save::getLife() {return life;} -int Save::getMaxLife() {return maxLife;} -int Save::getMagic() {return magic;} -int Save::getMaxMagic() {return maxMagic;} -int Save::getNaviMagic() {return naviMagic;} -int Save::getNaviMaxMagic() {return naviMaxMagic;} -int Save::getLvlHeal() {return lvlHeal;} -int Save::getLvlAtt() {return lvlAtt;} -int Save::getLvlDef() {return lvlDef;} -int Save::getRupees() {return rupees;} -int Save::getMaxRupees() {return maxRupees;} -int Save::getArrows() {return arrows;} -int Save::getMaxArrows() {return maxArrows;} -int Save::getRecupArrows() {return recupArrows;} -int Save::getBombs() {return bombs;} -int Save::getMaxBombs() {return maxBombs;} -int Save::getRecupBombs() {return recupBombs;} -int Save::getLifeToAdd() {return lifeToAdd;} -int Save::getMagicToAdd() {return magicToAdd;} -int Save::getRupeesToAdd() {return rupeesToAdd;} -int Save::getDeaths() {return deaths;} -Avancement Save::getAvancement() {return avancement;} -int Save::getTime() {return time;} -int Save::getEquipment(int i) {return equipment[i];} -int Save::getFlacons(int i) {return flacons[i];} -int Save::getQuartCoeur(int i) {return quartCoeur[i];} -int Save::getCoeur(int i) {return coeur[i];} -int Save::getGemmeForce(int i) {return gemmeForce[i];} -int Save::getCoquillages(int i) {return coquillages[i];} -int Save::getMedaillons(int i) {return medaillons[i];} -int Save::getTroc(int i) {return troc[i];} -int Save::getCoffre(int i, int j) {return coffres[i][j];} -int Save::getFees(int i) {return fees[i];} -int Save::getRooms(int d, int i, int j) {return rooms[d][i][j];} -bool Save::isExpert() {return expert;} - -void Save::setMap(int i) {map = i;} -void Save::setX(int i) {x = i;} -void Save::setY(int i) {y = i;} -void Save::setDirection(Direction dir) {direction = dir;} -void Save::setTunique(int i) {tunique = i;} -void Save::setEpee(int i) {epee = i;} -void Save::setBouclier(int i) {bouclier = i;} -void Save::setLife(int i) {life = i;} -void Save::setMaxLife(int i) {maxLife = i;} -void Save::setMagic(int i) {magic = i;} -void Save::setMaxMagic(int i) {maxMagic = i;} -void Save::setNaviMagic(int i) {naviMagic = i;} -void Save::setNaviMaxMagic(int i) {naviMaxMagic = i;} -void Save::setLvlHeal(int i) {lvlHeal = i;} -void Save::setLvlAtt(int i) {lvlAtt = i;} -void Save::setLvlDef(int i) {lvlDef = i;} -void Save::setRupees(int i) {rupees = i;} -void Save::setMaxRupees(int i) {maxRupees = i;} -void Save::setArrows(int i) {arrows = i;} -void Save::setMaxArrows(int i) {maxArrows = i;} -void Save::setRecupArrows(int i) {recupArrows = i;} -void Save::setBombs(int i) {bombs = i;} -void Save::setMaxBombs(int i) {maxBombs = i;} -void Save::setRecupBombs(int i) {recupBombs = i;} -void Save::setLifeToAdd(int i) {lifeToAdd = i;} -void Save::setMagicToAdd(int i) {magicToAdd = i;} -void Save::setRupeesToAdd(int i) {rupeesToAdd = i;} -void Save::setDeaths(int i) {deaths = i;} -void Save::setAvancement(Avancement av) {avancement = av;} -void Save::setTime(int i) {time = i;} -void Save::setEquipment(int i, int value) {equipment[i] = value;} -void Save::setFlacons(int i, int value) {flacons[i] = value;} -void Save::setQuartCoeur(int i, int value) {quartCoeur[i] = value;} -void Save::setCoeur(int i, int value) {coeur[i] = value;} -void Save::setGemmeForce(int i, int value) {gemmeForce[i] = value;} -void Save::setCoquillages(int i, int value) {coquillages[i] = value;} -void Save::setMedaillons(int i, int value) {medaillons[i] = value;} -void Save::setTroc(int i, int value) {troc[i] = value;} -void Save::setCoffre(int i, int j, int value) {coffres[i][j] = value;} -void Save::setFees(int i, int value) {fees[i] = value;} -void Save::setRooms(int d, int i, int j, int value) {rooms[d][i][j] = value;} -void Save::setExpert(bool b) {expert = b;} - -int Save::getCompletion() { - int tmp = 0; - - for (int i = 0; i < NB_QUART_COEUR; i++) if (quartCoeur[i] != 0) tmp++; - for (int i = 0; i < NB_GEMME_FORCE; i++) if (gemmeForce[i] != 0) tmp++; - for (int i = 0; i < NB_COQUILLAGES; i++) if (coquillages[i] != 0) tmp++; - for (int i = 0; i < NB_TROC; i++) if (troc[i] != -1) tmp++; - tmp += ((naviMaxMagic - 15) / 5); - for (int i = 0; i < NB_EQPMT - 1; i++) if (equipment[i] != 0) tmp++; - tmp += bouclier; - tmp += tunique - 1; - tmp += epee; - if (epee == 5) tmp--; - if (maxMagic > 32) tmp++; - tmp += (maxArrows - 30) / 5; - tmp += (maxBombs - 10) / 2; - if (maxRupees > 0) tmp++; - if (maxRupees > 99) tmp++; - if (maxRupees > 250) tmp++; - if (maxRupees > 500) tmp++; - for (int i = 0; i < NB_MEDAILLONS; i++) if (medaillons[i] != 0) tmp++; - for (int j = 1; j < NB_DONJON; j++) for (int i = 0; i < 3; i++) if (coffres[j][i] != 0) tmp++; - - return ((double)((double)tmp * 100)) / 247; -} - diff --git a/src/game/Save.h b/src/game/Save.h deleted file mode 100644 index 0518c4d..0000000 --- a/src/game/Save.h +++ /dev/null @@ -1,177 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __SAVE_H__ -#define __SAVE_H__ - -#include "../engine/common/Common.h" - -#include "content/CommonGame.h" - -class Save { - public : - Save(int i); - ~Save(); - - void save(bool endGame = false); - void erase(); - - bool isLoaded(); - - int getCompletion(); - - int getMap(); - int getX(); - int getY(); - Direction getDirection(); - int getTunique(); - int getEpee(); - int getBouclier(); - int getLife(); - int getMaxLife(); - int getMagic(); - int getMaxMagic(); - int getNaviMagic(); - int getNaviMaxMagic(); - int getLvlHeal(); - int getLvlAtt(); - int getLvlDef(); - int getRupees(); - int getMaxRupees(); - int getLifeToAdd(); - int getMagicToAdd(); - int getRupeesToAdd(); - int getDeaths(); - int getEquipment(int i); - int getFlacons(int i); - int getQuartCoeur(int i); - int getCoeur(int i); - int getGemmeForce(int i); - int getCoquillages(int i); - int getMedaillons(int i); - int getTroc(int i); - int getArrows(); - int getMaxArrows(); - int getRecupArrows(); - int getBombs(); - int getMaxBombs(); - int getRecupBombs(); - Avancement getAvancement(); - int getTime(); - int getCoffre(int i, int j); - int getFees(int i); - int getRooms(int d, int i, int j); - bool isExpert(); - - void setMap(int i); - void setX(int i); - void setY(int i); - void setDirection(Direction dir); - void setTunique(int i); - void setEpee(int i); - void setBouclier(int i); - void setLife(int i); - void setMaxLife(int i); - void setMagic(int i); - void setMaxMagic(int i); - void setNaviMagic(int i); - void setNaviMaxMagic(int i); - void setLvlHeal(int i); - void setLvlAtt(int i); - void setLvlDef(int i); - void setRupees(int i); - void setMaxRupees(int i); - void setLifeToAdd(int i); - void setMagicToAdd(int i); - void setRupeesToAdd(int i); - void setDeaths(int i); - void setEquipment(int i, int value); - void setFlacons(int i, int value); - void setQuartCoeur(int i, int value); - void setCoeur(int i, int value); - void setGemmeForce(int i, int value); - void setCoquillages(int i, int value); - void setMedaillons(int i, int value); - void setTroc(int i, int value); - void setArrows(int i); - void setMaxArrows(int i); - void setRecupArrows(int i); - void setBombs(int i); - void setMaxBombs(int i); - void setRecupBombs(int i); - void setAvancement(Avancement avancement); - void setTime(int t); - void setCoffre(int i, int j, int val); - void setFees(int i, int value); - void setRooms(int d, int i, int j, int val); - void setExpert(bool b); - - private : - - void init(); - void load(); - - int id; - bool loaded; - - - int map; - int x; - int y; - Direction direction; - int tunique; - int epee; - int bouclier; - - int life; - int maxLife; - int magic; - int maxMagic; - int naviMagic; - int naviMaxMagic; - int lvlHeal; - int lvlAtt; - int lvlDef; - int rupees; - int maxRupees; - int arrows; - int maxArrows; - int recupArrows; - int bombs; - int maxBombs; - int recupBombs; - - int lifeToAdd; - int magicToAdd; - int rupeesToAdd; - - int deaths; - - Avancement avancement; - - int time; - - int equipment[NB_EQPMT]; - int flacons[NB_FLACON]; - int quartCoeur[NB_QUART_COEUR]; - int coeur[NB_COEUR]; - int gemmeForce[NB_GEMME_FORCE]; - int coquillages[NB_COQUILLAGES]; - int medaillons[NB_MEDAILLONS]; - int troc[NB_TROC]; - int coffres[NB_COFFRES][COFFRES_MAX_SIZE]; - int fees[NB_FAIRIES]; - int rooms[NB_DONJON][MAX_ROOMS_X][MAX_ROOMS_Y]; - - bool expert; - -}; - -#endif // Save.h diff --git a/src/game/algo/AStar.cpp b/src/game/algo/AStar.cpp deleted file mode 100644 index 3ddf43b..0000000 --- a/src/game/algo/AStar.cpp +++ /dev/null @@ -1,204 +0,0 @@ -#include "AStar.h" - -#include "../../engine/util/geometry/BoundingBox.h" - -#include "cstdlib" - -#include "../MainController.h" - -#include "../game/scene/Scene.h" - -AStar AStar::instance=AStar(); - -AStar::AStar() { -} - -AStar::~AStar() { -} - -AStar* AStar::getInstance() { - return &instance; -} - -pair AStar::resolvePath(Collisionable* object, int dstX, int dstY, Direction direction, int lvl) { - - l_node opened; - l_node closed; - - BoundingBox* bb = object->getBoundingBox(); - BoundingBox box(bb->getX(), bb->getY(), bb->getW(), bb->getH()); - int x = box.getX(); - int y = box.getY(); - int dx = box.getW() / 2; - int dy = box.getH(); - - BoundingBox dst(dstX - 8, dstY - 16, 16, 16); - - // create and add the start point to the opened list - pair coords(x, y); - node start; - start.cost_g = 0; - start.cost_h = simpleDistance(x + dx, y + dy, dstX, dstY); - start.cost_f = start.cost_g + start.cost_h; - - opened[coords] = start; - - pair current = coords; - int count = 0; - - node nd = start; - bool begin = !object->isIdle(); - while (count < lvl && !opened.empty()) { - - // 1 -> retrieve best node from opened list - current = retrieveBestNode(&opened); - box.setX(current.first); - box.setY(current.second); - nd = opened[current]; - if (nd.cost_h <= 8*2-1 || box.intersect(&dst)) { - break; - } - - // 2 -> switch the best node to the closed list - closed[current] = nd; - opened.erase(current); - - if (++count >= lvl) { - //return pair (0, 0); - break; - } - - // 3 -> add new nodes from the current - addNodes(&opened, &closed, current, nd, dx, dy, dstX, dstY, object, &box, direction, begin); - begin = false; - } - - // 4 -> find the way from the result - - int nx = x; - int ny = y; - - while (current != coords) { - - nx = current.first; - ny = current.second; - - current = nd.parent; - nd = closed[current]; - } - - pair result; - - - if (nx < x) result.first = -1; - else if (nx > x) result.first = 1; - if (ny < y) result.second = -1; - else if (ny > y) result.second = 1; - - return result; -} - -int AStar::simpleDistance(int x1, int y1, int x2, int y2) { - return abs(x1 - x2) + abs(y1 - y2); -} - -pair AStar::retrieveBestNode(l_node* list) { - - pair node = list->begin()->first; - int cost = list->begin()->second.cost_f; - - for (l_node::iterator i = list->begin(); i!=list->end(); i++) { - if (i->second.cost_f< cost){ - cost = i->second.cost_f; - node = i->first; - } - } - return node; -} - -void AStar::addNodes(l_node* opened, l_node* closed, pair current, node nd, - int dx, int dy, int dstX, int dstY, Collisionable* object, - BoundingBox* box, Direction direction, bool begin) { - - node tmp; - - Scene* scene = MainController::getInstance()->getGameController()->getSceneController()->getScene(); - - int x0 = current.first; - int y0 = current.second; - - int firstX = x0; - int firstY = y0; - int lastX; - int lastY; - - int mod = firstX % 8; - if (mod != 0) { - firstX -= mod; - lastX = firstX + 8; - } else { - firstX -= 8; - lastX = firstX + 16; - } - - mod = firstY % 8; - if (mod != 0) { - firstY -= mod; - lastY = firstY + 8; - } else { - firstY -= 8; - lastY = firstY + 16; - } - - for (int j = firstY; j <= lastY; j += 8) { - for (int i = firstX; i <= lastX; i += 8) { - - if (i == x0 && j == y0) { - continue; - } - - box->setX(i); - box->setY(j); - if (!scene->checkCollisions(box, object, true, true, false)) { - continue; - } - - int surcost = 0; - if (!scene->checkCollisions(box, object, false, true, true)) { - surcost += 999; // <- should never want to take this path - } - - pair it(i, j); - - if (closed->find(it) == closed->end()) { - - //int surcost = 0; - if (begin) { - if ( (j == firstY && direction == S) - || (j == lastY && direction == N) - || (i == firstX && direction == E) - || (i == lastX && direction == W)) { - surcost += 32; - } - } - - - tmp.cost_g = nd.cost_g + (simpleDistance(i, j, x0, y0) / 2); - tmp.cost_h = simpleDistance(i + dx, j + dy, dstX, dstY) + surcost; - tmp.cost_f = tmp.cost_g + tmp.cost_h; - tmp.parent = current; - - if (opened->find(it) != opened->end()) { - if (tmp.cost_f < (*opened)[it].cost_f) { - (*opened)[it] = tmp; - } - } else { - - (*opened)[pair (i, j)] = tmp; - - } - } - } - } - -} diff --git a/src/game/algo/AStar.h b/src/game/algo/AStar.h deleted file mode 100644 index 2f34d16..0000000 --- a/src/game/algo/AStar.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#ifndef __ASTAR_H__ -#define __ASTAR_H__ - -#include "../../engine/common/Common.h" - -#include "../../engine/util/geometry/BoundingBox.h" - -#include "../content/types/Collisionable.h" - -#include - -struct node { - int cost_g; - int cost_h; - int cost_f; - std::pair parent; -}; - -typedef map, node> l_node; - -class AStar { - public : - static AStar* getInstance(); - - pair resolvePath(Collisionable* object, int dstX, int dstY, Direction direction, int lvl = 50); - - private : - AStar(); - ~AStar(); - static AStar instance; - - int simpleDistance(int x1, int y1, int x2, int y2); - pair retrieveBestNode(l_node* list); - void addNodes(l_node* opened, l_node* closed, pair current, node nd, - int dx, int dy, int dstX, int dstY, Collisionable* object,BoundingBox* box, Direction direction, bool begin); -}; - -#endif // AStar.h diff --git a/src/main.cpp b/src/main.cpp deleted file mode 100644 index 83a6d8e..0000000 --- a/src/main.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - - Zelda Navi's Quest - - Copyright (C) 2013-2014 Vincent Jouillat - - Please send bugreports with examples or suggestions to www.zeldaroth.fr - -*/ - -#include -#include -#include - -#include "engine/window/WindowManager.h" -#include "engine/audio/AudioManager.h" - -#include "config/ConfigurationManager.h" - -#include "game/MainController.h" - -#include "game/content/helper/ItemHelper.h" - -int main(int argc, char** argv) { - if (argc && argv); //pour éviter un warning..... - - std::srand(std::time(NULL)); - - if (WindowManager::getInstance()->createWindow("Zelda Navi's Quest", "data/images/logos/navi.ico") < 0) { - exit(-1); - } - - ConfigurationManager::getInstance()->init("config/system.dat", "config/keys.dat"); - - MainController* controller = MainController::getInstance(); - - controller->init(); - - controller->setInternalStep(LOGO); - - Event* event; - - while(WindowManager::getInstance()->isOpened()) { - - event = WindowManager::getInstance()->getEvent(); - - controller->control(event); - - if (event->isPushed(QUIT) || event->isPushed(kEscape) || event->isPushed(QUIT_FORCED)) { - - WindowManager::getInstance()->close(); - continue; - } - - WindowManager::getInstance()->display(); - } - - ItemHelper::getInstance()->close(); - - controller->close(); - - ConfigurationManager::getInstance()->close(); - AudioManager::getInstance()->close(); - - WindowManager::getInstance()->exit(); - - return 0; -}