Enter and ESC keys

Ok, so what I am trying to do works fine but I can't capture the Enter key and the ESC key.

What I have is a menu state and a game state. What I want to happen is when a player presses "ENTER" on the game menu it then moves to the game state.

If the player presses "ESC" while in the game state it will go back to the menu state.

Now if the player presses "ESC" during the menu state it will quit the program.

Problem I am having is that the program will read other keys but no the "ENTER" key, so it just wont work at all. The other problem is that "ESC" won't switch back to case 0 in my switch statement but will exit the program entirely no matter where I am. Please help.

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
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// we give the x,y coord's variables so that when we assign them to an object we can adjust them and manouver the object
	int ballposx = 120; 
	int ballposy = 300;
	int ballspeedx = 10;
	int Screen = 0;
	

	do 
	{
		switch (Screen)
		{
			case 0:
		ClearScreen();

				if ( IsKeyDown('CR'))
				{

					Screen = 1;
				}
				DrawSprite(gamemenu);
				MoveSprite( gamemenu, 640, 370 );
				break;

			case 1:


		ClearScreen();



			if ( IsKeyDown('ESC'))
			{

					Screen = 0;
			}


		ballposx += ballspeedx;
		MoveSprite( iPlayerSprite, ballposx, ballposy );

		if( ballposx + ballw > screenw ||  ballposx < 0 ) 
		{
		 ballspeedx *= -1;
		}

	
		
		
		DrawSprite(iPlayerSprite);

		break;
		}
	} while ( FrameworkUpdate() == false );

	Shutdown();

	return 0;
}
What about replacing the 'CR' and 'ESC'?
IsKeyDown(ENTER)
IsKeyDown(ESCAPE)
Topic archived. No new replies allowed.