-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.h
71 lines (64 loc) · 2.31 KB
/
menu.h
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
int menuLoop()
{
int x,y;
bool mouseDown = false;
menu = 0;
while (menu==0)
{
while ( SDL_PollEvent(&event) )
{
if ( event.type == SDL_QUIT ) { done = 1; menu = 1; }
if( event.type == SDL_MOUSEBUTTONDOWN )
{
if( event.button.button == SDL_BUTTON_LEFT )
{
if(menuPlay.hilighted == true)
{
menu =1;
return 0;
}
if(menuQuit.hilighted == true)
{
menu =1;
done = 1;
return 0;
}
}
}
if ( event.type == SDL_MOUSEMOTION )
{
x = event.motion.x;
y = event.motion.y;
//If the mouse is over the button
if( ( x > menuPlay.xpos ) && ( x < menuPlay.xpos + menuPlay.w ) && ( y > menuPlay.ypos ) &&
( y < menuPlay.ypos + menuPlay.h ) )
{
menuPlay.face = menuPlay.faceIn;
menuPlay.hilighted = true;
}
else
{
menuPlay.face = menuPlay.faceOut;
menuPlay.hilighted = false;
}
//If the mouse is over the button
if( ( x > menuQuit.xpos ) && ( x < menuQuit.xpos + menuPlay.w ) && ( y > menuQuit.ypos ) &&
( y < menuQuit.ypos + menuQuit.h ) )
{
//Set the button sprite
menuQuit.face = menuQuit.faceIn;
menuQuit.hilighted = true;
}
else
{
menuQuit.face = menuQuit.faceOut;
menuQuit.hilighted = false;
}
}
}
draw();
SystemUse.DrawIMG(menuPlay.face,menuPlay.xpos,menuPlay.ypos,screen);
SystemUse.DrawIMG(menuQuit.face,menuQuit.xpos,menuQuit.ypos,screen);
SDL_Flip(screen);
}
}