let's play with C

This commit is contained in:
Gwenhael Le Moine 2011-06-30 15:17:21 +02:00
parent c4262eb414
commit e73d385170

40
star.c Normal file
View file

@ -0,0 +1,40 @@
#include <stdio.h>
#define LEVEL_HEIGHT 9
#define LEVEL_WIDTH 16
char* levels[] = { "WWWWWWWWWWWWWWWWWBWWVVVVVVVVGWCWWVVVVVVVVVVGVWWWWVVVVVVVWWGVVVVWWVVVWWVGVVVVVVWWWWVGVVGVVVVVGVVWWVGVVVVVVGWWVGVWWVVVVVWWGVVVVVGWWWWWWWWWWWWWWWWW" };
void display_level( char* lvl )
{
int i;
for( i = 0 ; i < LEVEL_HEIGHT * LEVEL_WIDTH ; i++ ) {
if ( ( i > 0 ) && ( i % LEVEL_WIDTH == 0 ) ) {
printf( "\n" );
}
switch( lvl[ i ] ) {
case 'W':
printf( "##" );
break;
case 'V':
printf( " " );
break;
case 'B':
printf( "()" );
break;
case 'C':
printf( "[]" );
break;
case 'G':
printf( "<>" );
break;
default: break;
}
}
printf( "\n" );
}
int main( int argc, char* argv[] )
{
display_level( levels[ 0 ] );
return 0;
}