-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgm_winscreen.c
65 lines (59 loc) · 1.91 KB
/
gm_winscreen.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* gm_winscreen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lchenut <lchenut@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/03/01 19:00:17 by lchenut #+# #+# */
/* Updated: 2015/03/01 19:00:20 by lchenut ### ########.fr */
/* */
/* ************************************************************************** */
#include "game.h"
static void gm_winscreen_message(int y, int x)
{
int start;
start = x / 2 - 33 / 2;
y = (((y - 6) / 4) * 4 + 5) / 4;
mvprintw(2 * y - 2, start, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
mvprintw(2 * y - 1, start, "Hey fool, guess what ! You won !");
mvprintw(2 * y, x / 2 - 4, "Retry : R");
mvprintw(2 * y + 1, x / 2 - 6, "Continue : C");
mvprintw(2 * y + 2, x / 2 - 4, "Exit : E");
mvprintw(2 * y + 3, start, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
}
static int gm_reset(int ***tab, int *test)
{
gm_erase_tab(tab);
*tab = gm_init_tab();
*test = 0;
clear();
return (1);
}
int gm_winscreen(WINDOW *screen, int ***tab, int *test)
{
int x;
int y;
int kc;
clear();
getmaxyx(screen, y, x);
gm_winscreen_message(y, x);
while (1)
{
refresh();
kc = getch();
getmaxyx(screen, y, x);
gm_winscreen_message(y, x);
if (kc == 'e' || kc == 'E' || kc == 27)
return (0);
if (kc == 'r' || kc == 'R')
return (gm_reset(tab, test));
if (kc == 'c' || kc == 'C')
{
*test = 1;
clear();
return (2);
}
}
return (0);
}