Commit 8308ba85 authored by Konrad McClure's avatar Konrad McClure

Tested pausing and resuming states

parent 1f502886
......@@ -47,9 +47,8 @@ class CGameState
// only ever one copy of a gviven state
protected:
CGameState() {}
private:
string stateName;
};
#endif
\ No newline at end of file
#include <iostream>
#include "TestState1.h"
#include "TestState2.h"
#include "TestState3.h"
CTestState1 CTestState1::m_TestState1;
void CTestState1::Init()
{
cout << " TestState1 Init" << endl;
stateName = "TestState1";
}
void CTestState1::Pause()
......@@ -34,6 +36,11 @@ void CTestState1::Update(CGameEngine* game)
{
cout << " TestState1 Update" << endl;
if (runtimes == 2)
{
game->PushState(CTestState3::Instance());
}
if (runtimes >= 3)
{
game->ChangeState(CTestState2::Instance());
......
......@@ -24,7 +24,6 @@ class CTestState1 : public CGameState
private:
static CTestState1 m_TestState1;
string stateName = "TestState1";
int runtimes = 0;
};
......
......@@ -6,6 +6,7 @@ CTestState2 CTestState2::m_TestState2;
void CTestState2::Init()
{
cout << " TestState2 Init" << endl;
stateName = "TestState2";
}
void CTestState2::Pause()
......
......@@ -24,7 +24,6 @@ class CTestState2 : public CGameState
private:
static CTestState2 m_TestState2;
string stateName = "TestState2";
int runtimes = 0;
};
......
#include <iostream>
#include "TestState3.h"
CTestState3 CTestState3::m_TestState3;
void CTestState3::Init()
{
cout << " TestState3 Init" << endl;
stateName = "TestState3";
}
void CTestState3::Pause()
{
cout << " TestState3 Pause" << endl;
}
void CTestState3::Resume()
{
cout << " TestState3 Resume" << endl;
}
void CTestState3::Cleanup()
{
cout << " TestState3 Cleanup" << endl;
}
void CTestState3::HandleEvents(CGameEngine* game)
{
cout << " TestState3 Handle Events" << endl;
runtimes++;
}
void CTestState3::Update(CGameEngine* game)
{
cout << " TestState3 Update" << endl;
if (runtimes >= 3)
{
game->PopState();
}
}
void CTestState3::Draw(CGameEngine* game)
{
cout << " TestState3 Draw" << endl;
}
#ifndef TESTSTATE3_H
#define TESTSTATE3_H
#include "GameState.h"
#include <iostream>
class CTestState3 : public CGameState
{
public:
void Init();
void Cleanup();
void Pause();
void Resume();
void HandleEvents(CGameEngine* game);
void Update(CGameEngine* game);
void Draw(CGameEngine* game);
static CTestState3* Instance() { return &m_TestState3; }
protected:
CTestState3() {}
private:
static CTestState3 m_TestState3;
int runtimes = 0;
};
#endif
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment