menu system moving wayyyy to fast

making a menu system for my game and i got it to work but for some reason my selector icon/arrow moves a million miles per hour and i cant seem to slow it down any help?

below is the .cpp and .h files that contain the menu system
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139

#include "MenuState.h"
#include "GL_Functions.h"
#include "Game.h"
#include "PlayGameState.h"
#include "InstructionsState.h"

class Game;

bool bReturnKeyDown = true;
bool bKeepPlaying = true;


MenuState::MenuState(Game* pMenuState)
{
	m_pOwningGame = pMenuState;	
	m_iMenu;
	m_iArrow;
	m_iTitleScreen;
	m_eCurrentState;
	m_eCurrentState = MENU_STATE;

}

MenuState::~MenuState()
{
	
}

void MenuState::OnLoad()
{
	m_iTitleScreen = LoadTexture("./Bin/Images/TitleScreen.png");
	m_iMenu = LoadTexture("./Bin/Images/Menu.png");
	m_iArrow = LoadTexture("./Bin/Images/arrow.png");
}

void MenuState::OnUnload()
{
	FreeTexture(m_iMenu);
	FreeTexture(m_iArrow);
	FreeTexture(m_iTitleScreen);
}

void MenuState::Update()
{
{
	if(IsKeyDown(' ') == true)
	{
		m_pOwningGame->ChangeState(Game::PLAY_GAME_STATE);
	}
	if(IsKeyDown(KEY_LALT) == true)
	{
		m_pOwningGame->ChangeState(Game::INSTRUCTIONS_STATE);
	}
}
	DrawSprite(m_iMenu,0,0,1024,768);
	{
	if (IsKeyDown(KEY_UP) && m_iMenuCounter <= 0)
	{
		m_iMenuSwitch--;
		m_iMenuCounter = 30;
	}
	else if (IsKeyDown(KEY_DOWN) && m_iMenuCounter <= 0)
	{
		m_iMenuSwitch++;
		m_iMenuCounter = 30;
	}
	if (m_iMenuSwitch > 5)
	{
		m_iMenuSwitch = 1;
	}
	else if (m_iMenuSwitch < 1)
	{
		m_iMenuSwitch = 5;
	}
		m_iMenuCounter--;
	}

}

void MenuState::Draw()
{
	DrawSprite(m_iMenu,0,0,1024,768);
		switch (m_iMenuSwitch)
	{
	case 1:
		DrawSprite(m_iArrow,90,100, 40, 40);
		if(IsKeyDown(KEY_RETURN))
		{
			m_pOwningGame->ChangeState(Game::PLAY_GAME_STATE);	
		}
		else
		if(IsKeyDown(KEY_ESCAPE))
		{
			m_pOwningGame->ChangeState(Game::MENU_STATE);	
		}
		break;
	case 2:
		DrawSprite(m_iArrow,90,200, 40, 40);
		if(IsKeyDown(KEY_RETURN))
		{
			m_pOwningGame->ChangeState(Game::HIGHSCORE_STATE);
		}
		else	
		if(IsKeyDown(KEY_ESCAPE))
		{
			m_pOwningGame->ChangeState(Game::MENU_STATE);
		}
		break;
	case 3:
		DrawSprite(m_iArrow,90,275, 40, 40);
		if(IsKeyDown(KEY_RETURN))
		{
			m_pOwningGame->ChangeState(Game::INSTRUCTIONS_STATE);
		}
		else
		if(IsKeyDown(KEY_ESCAPE))
		{
			m_pOwningGame->ChangeState(Game::MENU_STATE);
		}
		break;
	case 4:
		DrawSprite(m_iArrow,90,370, 40, 40);
		break;
	case 5:
		DrawSprite(m_iArrow,90,445, 40, 40);
		if(IsKeyDown(KEY_RETURN))
		{
			exit(0);
		}
		break;		
	default:
		break;
	}
}
	





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

#ifndef _MENU_STATE_H_
#define _MENU_STATE_H_

class Game;

class MenuState
{
public:
	enum STATE_TYPES
	{
		MENU_STATE,
		PLAY_GAME_STATE,
		INSTRUCTIONS_STATE,
		HIGHSCORE_STATE
	};

	MenuState(Game* pMenuState);
	~MenuState();

	int m_iMenuCounter;
	int m_iMenuSwitch;
	
	void OnLoad();
	void OnUnload();
	
	void Update();
	void Draw();
	void ChangeState(STATE_TYPES eType);
private:
	Game* m_pOwningGame;
	int m_iMenu;
	int m_iArrow;
	int m_iTitleScreen;
	STATE_TYPES m_eCurrentState;
};

#endif


Topic archived. No new replies allowed.