@@ -9,13 +9,63 @@ extern void restoreConsoleMode(void);
99extern void restoreConsole (void );
1010extern void getCursorPosition (int * row , int * col );
1111
12+ typedef unsigned char sshort ;
13+
1214typedef enum ColorButtons {
1315 GREEN = 1 ,
1416 RED ,
1517 YELLOW ,
1618 BLUE
1719}Color ;
1820
21+ void display (int button , bool zero , int screenSize [2 ])
22+ {
23+ setupConsole ();
24+ if (zero == true)
25+ {
26+ moveTo (0 , 0 );
27+
28+ for (int row = 0 ; row <= screenSize [0 ]/2 ; row ++ )
29+ {
30+ setBackgroundColorRGB (30 , 50 , 40 ); // shadow green
31+ for (int greenCol = 0 ; greenCol <= (screenSize [1 ] / 2 ) - 1 ; greenCol ++ )
32+ printf (" " );
33+
34+ if (screenSize [1 ] % 2 != 0 )
35+ printf (" " );
36+
37+ setBackgroundColorRGB (50 , 30 , 40 ); // shadow red
38+ for (int rednCol = 0 ; rednCol <= (screenSize [1 ] / 2 ) - 1 ; rednCol ++ )
39+ printf (" " );
40+
41+ printf ("\n" );
42+ }
43+
44+ if (screenSize [0 ] % 2 != 0 )
45+ printf ("\n" );
46+
47+ for (int row = 0 ; row <= screenSize [0 ]/2 ; row ++ )
48+ {
49+ setBackgroundColorRGB (50 , 50 , 0 ); // shadow yellow
50+ for (int greenCol = 0 ; greenCol <= (screenSize [1 ] / 2 ) - 1 ; greenCol ++ )
51+ printf (" " );
52+
53+ if (screenSize [1 ] % 2 != 0 )
54+ printf (" " );
55+
56+ setBackgroundColorRGB (40 , 30 , 50 ); // shadow blue
57+ for (int rednCol = 0 ; rednCol <= (screenSize [1 ] / 2 ) - 1 ; rednCol ++ )
58+ printf (" " );
59+
60+ printf ("\n" );
61+ }
62+
63+ }
64+
65+
66+ restoreConsoleMode ();
67+ }
68+
1969void rng (int * sequence , int level )
2070{
2171 unsigned int sequenceSize = level ;
@@ -42,26 +92,33 @@ int main(int argc, char** argv)
4292{
4393 int level = 2 ;
4494 int windowSize [2 ];
45- int sequence [4000 ];
95+ sshort sequence [4000 ];
4696 char trashcan [10 ];
4797
4898 srand (time (NULL ));
4999
50- printf ("Starting Simon. Do you wish to:\n(P) play now\nor \n (T)see the tutorial?\n" );
100+ printf ("Starting Simon. Do you wish to:\n(P) play now\nor \n(T)see the tutorial?\n" );
51101 fgets (trashcan , 5 , stdin );
52102
53- if (trashcan [0 ] == 'T' )
103+ if (trashcan [0 ] == 'T' || trashcan [ 0 ] == 't' )
54104 {
55105 //teach how to play
56106 }
57107
58- if (trashcan [0 ] == 'P' )
108+ if (trashcan [0 ] == 'P' || trashcan [ 0 ] == 'p' )
59109 {
60110 for (bool replay = true; replay == true;)
61111 {
62- clearScreenToBottom ();
112+ setupConsole ();
113+ moveTo (999 , 999 );
63114 getCursorPosition (& windowSize [0 ], & windowSize [1 ]);
64115 clearScreenToTop ();
116+ restoreConsoleMode ();
117+ display (1 , true, windowSize );
118+ resetColor ();
119+ break ;
65120 }
66121 }
122+
123+ return 0 ;
67124}
0 commit comments