-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a "loading map" state that does nothing
but draw a blank screen while loading the map.
- Loading branch information
Showing
8 changed files
with
131 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2013-2015 Rohit Nirmal | ||
This file is part of Clonepoint. | ||
Clonepoint is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Clonepoint is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Clonepoint. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "loadingmapstate.h" | ||
|
||
LoadingMapState::LoadingMapState(StateManager* sm) : BaseState(sm) | ||
{ | ||
_mapFilename = ""; | ||
_timer = 0; | ||
_loaded = false; | ||
} | ||
|
||
LoadingMapState::~LoadingMapState() | ||
{ | ||
} | ||
|
||
void LoadingMapState::update(unsigned int dT) | ||
{ | ||
_timer += dT; | ||
|
||
if (_timer > 50 && ! _loaded) | ||
{ | ||
_manager->initSceneAndMap(_mapFilename.c_str()); | ||
_manager->makeStartSave(); | ||
Locator::getAudio()->playMusic("groove_grove.ogg"); | ||
_loaded = true; | ||
} | ||
|
||
if (_timer > 100) | ||
{ | ||
//give a little extra time before displaying to avoid seeing the last | ||
//game (if you exited to the main menu and loaded another map). | ||
_manager->switchToState(GAME_SCREEN); | ||
} | ||
} | ||
|
||
void LoadingMapState::handleKeyDown(SDL_Keycode){} | ||
void LoadingMapState::handleKeyUp(SDL_Keycode){} | ||
void LoadingMapState::handleMouseDown(SDL_MouseButtonEvent event){} | ||
void LoadingMapState::handleMouseUp(SDL_MouseButtonEvent event){} | ||
|
||
void LoadingMapState::setMap(std::string mapFilename) | ||
{ | ||
_mapFilename = mapFilename; | ||
_timer = 0; | ||
_loaded = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright 2013-2015 Rohit Nirmal | ||
This file is part of Clonepoint. | ||
Clonepoint is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Clonepoint is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Clonepoint. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef LOADINGMAPSTATE_H | ||
#define LOADINGMAPSTATE_H | ||
#include "state.h" | ||
#include "statemanager.h" | ||
|
||
class LoadingMapState : public BaseState | ||
{ | ||
public: | ||
LoadingMapState(StateManager* sm); | ||
~LoadingMapState(); | ||
void update(unsigned int dT); | ||
void handleKeyDown(SDL_Keycode); | ||
void handleKeyUp(SDL_Keycode); | ||
void handleMouseDown(SDL_MouseButtonEvent event); | ||
void handleMouseUp(SDL_MouseButtonEvent event); | ||
void setMap(std::string mapFilename); | ||
private: | ||
std::string _mapFilename; | ||
unsigned int _timer; | ||
bool _loaded; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters