-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainMenuState.cpp
86 lines (77 loc) · 2.1 KB
/
MainMenuState.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//////////////////////////////////////////////////////////////////////////
// Filename : MainMenuState.cpp
//
// Author : Ramon Johannessen (RJ)
//
// Purpose : The Main Menu will be the first menu loaded when the game
// starts. It will display all menu selections available.
//////////////////////////////////////////////////////////////////////////
#include "MainMenuState.h"
CMainMenuState* GetInstance()
{
static CMainMenuState menuState;
return &menuState;
}
bool CMainMenuState::Input()
{
if (m_pDI->KeyPressed(DIK_DOWN))
{
m_nCurrMenuSelection++;
if (m_nCurrMenuSelection == NULL_END)
m_nCurrMenuSelection = PLAY;
}
else if (m_pDI->KeyPressed(DIK_UP))
{
m_nCurrMenuSelection--;
if (m_nCurrMenuSelection < PLAY)
m_nCurrMenuSelection = NULL_END-1;
}
else if (m_pDI->KeyPressed(DIK_RETURN))
{
switch(m_nCurrMenuSelection)
{
case PLAY:
CGame::GetInstance()->ChangeState(CGamePlayState::GetInstance());
break;
case OPTIONS:
CGame::GetInstance()->ChangeState(COptionsMenuState::GetInstance());
break;
case HOWTOPLAY:
CGame::GetInstance ()->ChangeState(CHowToPlayMenuState::GetInstance ());
break;
case CREDITS:
CGame::GetInstance ()->ChangeState(CCreditsMenuState::GetInstance ());
break;
case EXIT:
CGame::GetInstance()->SetIsRunning(false);
break;
case LOAD:
CGame::GetInstance()->ChangeState(CLoadMenuState::GetInstance());
}
}
}
void CMainMenuState::Render()
{
CBaseMenuState::Render();
m_pD3D->Draw(m_nCursorImageID, m_nCursorX, m_nCursorY);
}
void CMainMenuState::Update(float fElapsedTime)
{
}
void CMainMenuState::Enter()
{
CBaseMenuState::Enter();
m_nBGImageID = m_pAssets->m_nMMBGimageID;
m_nImageWidth = m_pTM->GetImageWidth(m_nBGImageID);
m_nImageHeight = m_pTM->GetImageHeight(m_nBGImageID);
m_nCursorImageID = m_pAssets->m_nMMCursorImageID;
m_sBGMusicID = m_pAssets->m_sMMBGmusic;
m_nCurrMenuSelection = PLAY;
// TODO:: setup starting cursor position
m_nCursorX = 0;
m_nCursorY = 0;
}
void CMainMenuState::Exit()
{
CBaseMenuState::Exit();
}