-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Rushwind13/develop
Dungeon Generation
- Loading branch information
Showing
29 changed files
with
1,134 additions
and
546 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
.DS_Store | ||
*.png | ||
*.txt | ||
*.psd | ||
#*.png | ||
#*.txt | ||
Scores.txt | ||
|
||
# XCode | ||
*.xcodeproj | ||
|
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,115 @@ | ||
// | ||
// ClockStepState.cpp | ||
// JMoria | ||
// | ||
// Created by Jimbo S. Harris on 12/16/17. | ||
// Copyright © 2017 Jimbo S. Harris. All rights reserved. | ||
// | ||
|
||
#include "ClockStepState.h" | ||
|
||
#include "DungeonTile.h" | ||
#include "DisplayText.h" | ||
#include "Game.h" | ||
|
||
#include "FileParse.h" | ||
|
||
extern CGame *g_pGame; | ||
|
||
CClockStepState::CClockStepState() | ||
: m_dwClock(0), | ||
m_dwStep(1) | ||
{ | ||
m_pKeyHandlers[CLOCKSTEP_INIT] = &CClockStepState::OnHandleInit; | ||
m_pKeyHandlers[CLOCKSTEP_TICK] = &CClockStepState::OnHandleTick; | ||
|
||
m_eCurModifier = CLOCKSTEP_INIT; | ||
m_pCurKeyHandler = m_pKeyHandlers[m_eCurModifier]; | ||
} | ||
|
||
CClockStepState::~CClockStepState() | ||
{ | ||
} | ||
|
||
int CClockStepState::OnHandleKey(SDL_Keysym *keysym) | ||
{ | ||
int retval; | ||
retval = ((*this).*(m_pCurKeyHandler))(keysym); | ||
return retval; | ||
} | ||
|
||
int CClockStepState::OnHandleTick( SDL_Keysym *keysym ) | ||
{ | ||
int retval; | ||
printf( "Handling TICK modifier\n" ); | ||
retval = OnBaseHandleKey( keysym ); | ||
|
||
if( retval == JRESETSTATE ) | ||
{ | ||
return 0; | ||
} | ||
|
||
if( retval == JCOMPLETESTATE ) | ||
{ | ||
printf( "TICK modifier complete, CLOCKSTEP state to next TICK\n"); | ||
DoTick(); | ||
m_eCurModifier = CLOCKSTEP_TICK; | ||
m_pCurKeyHandler = m_pKeyHandlers[m_eCurModifier]; | ||
} | ||
|
||
if( retval != JSUCCESS ) | ||
{ | ||
printf( "CLOCK still waiting for a valid key.\n" ); | ||
return 0; | ||
} | ||
|
||
// We got a valid key | ||
printf( "TICK modifier got a valid key\n" ); | ||
g_pGame->GetEnd()->Clear(); | ||
DoTick(); | ||
|
||
return 0; | ||
} | ||
|
||
int CClockStepState::OnHandleInit( SDL_Keysym *keysym ) | ||
{ | ||
printf( "Initializing CLOCKSTEP state...\n" ); | ||
|
||
g_pGame->GetStats()->Clear(); | ||
DoTick(); | ||
m_eCurModifier = CLOCKSTEP_TICK; | ||
m_pCurKeyHandler = m_pKeyHandlers[m_eCurModifier]; | ||
return 0; | ||
} | ||
|
||
int CClockStepState::OnBaseHandleKey( SDL_Keysym *keysym ) | ||
{ | ||
if( keysym->sym == SDLK_RETURN || keysym->sym == SDLK_SPACE ) | ||
{ | ||
return JCOMPLETESTATE; | ||
} | ||
|
||
return -1; | ||
} | ||
|
||
void CClockStepState::ResetToState( int newstate ) | ||
{ | ||
g_pGame->SetState(newstate); | ||
m_cCommand = NULL; | ||
m_eCurModifier = CLOCKSTEP_INIT; | ||
m_pCurKeyHandler = m_pKeyHandlers[m_eCurModifier]; | ||
} | ||
|
||
|
||
////////////////////////////////////// | ||
/// command-specific fcns go below | ||
|
||
//// Tick commands | ||
bool CClockStepState::DoTick() | ||
{ | ||
m_dwClock += m_dwStep; | ||
g_pGame->GetStats()->Printf("Tick! %d\n", m_dwClock); | ||
g_pGame->SetReadyForUpdate(true); | ||
g_pGame->GetDungeon()->Tick(m_dwClock); | ||
return true; | ||
} |
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,56 @@ | ||
// | ||
// ClockStepState.h | ||
// JMoria | ||
// | ||
// Created by Jimbo S. Harris on 12/16/17. | ||
// Copyright © 2017 Jimbo S. Harris. All rights reserved. | ||
// | ||
|
||
#ifndef ClockStepState_h | ||
#define ClockStepState_h | ||
#include "JMDefs.h" | ||
#include "StateBase.h" | ||
|
||
#include "Dungeon.h" | ||
|
||
class CClockStepState; | ||
typedef int (CClockStepState::*ClockStepKeyHandler)(SDL_Keysym *keysym); | ||
enum eClockStepModifier | ||
{ | ||
CLOCKSTEP_INVALID=-1, | ||
CLOCKSTEP_INIT=0, | ||
CLOCKSTEP_TICK=1, | ||
CLOCKSTEP_MAX | ||
}; | ||
class CClockStepState : public CStateBase | ||
{ | ||
// Member Variables | ||
public: | ||
protected: | ||
char m_cCommand; | ||
ClockStepKeyHandler m_pKeyHandlers[CLOCKSTEP_MAX]; | ||
ClockStepKeyHandler m_pCurKeyHandler; | ||
|
||
eClockStepModifier m_eCurModifier; | ||
private: | ||
int m_dwClock; | ||
int m_dwStep; | ||
|
||
// Member Functions | ||
public: | ||
CClockStepState(); | ||
~CClockStepState(); | ||
|
||
virtual void OnUpdate() {}; | ||
virtual int OnBaseHandleKey( SDL_Keysym *keysym ); | ||
virtual int OnHandleKey( SDL_Keysym *keysym ); | ||
protected: | ||
private: | ||
int OnHandleTick( SDL_Keysym *keysym ); | ||
int OnHandleInit( SDL_Keysym *keysym ); | ||
|
||
void ResetToState( int newstate ); | ||
|
||
bool DoTick(); | ||
}; | ||
#endif /* ClockStepState_h */ |
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
Oops, something went wrong.