예제 #1
0
/* --- Kernel entrypoint --- */
int
kernel_main(mbinfo_t *mbinfo, int argc, char **argv, char **envp)
{
    if(handler_install(tick) < 0) {
      panic("oh noes! where are my handlers");
    }

    enable_interrupts();

    clear_console();

    show_cursor();

    set_term_color(FGND_GREEN | BGND_BLACK);

    set_cursor(12, 34);
    printf("Hello World!\n");
    set_cursor(15, 34);
    printf("Type \"cat\" now: \n");

    wait_char('c'); putbyte('d');
    wait_char('a'); putbyte('o');
    wait_char('t'); putbyte('g');
    set_cursor(16, 25);
    printf("That took %d seconds\n", seconds);
    printf("Yay kitties! - now what if you type \"dog\"?");
    while(1)
      continue;
}
예제 #2
0
// This is my primary Event Loop. This is where most of the fun stuff happens ;)
void Megamaniac() {
    // WTF does this do? Something to do with my Data Structure I assume...
    Game game;

	while (true) {
	    // Let's run our initial setup to get everything for the game ready.
	    SetupGame(&game);

	    // Do we need to change the level? Not really but we should probably start at Level 1.
	    ChangeLevel(&game);

		// This is where the Event Loop actually starts. This will run repeatedly until our game is over.
	    while (!game.game_over) {
		    clear_screen();
		    GameStats(&game);
			int userInput = UserInput(&game);
		    MovementPlayer(&game, userInput);
			MovementMissiles(&game, userInput);
		    MovementAliens(&game);
			MovementBombs(&game);
			MovementBonuses(&game);

			CollisionMissiles(&game);
			CollisionAliens(&game);
		    CollisionBombs(&game);
			CollisionBonuses(&game);

			UpdateScreen(&game);
		    show_screen();
		    timer_pause(25);
	    }

		GameOver(&game);

		int userInput = wait_char();
		while (userInput != 'r' && userInput >= 0) {
			if (userInput == 'q') {
				exit(0);
			}
			if (userInput == 'r') {
				Megamaniac();
			}
			userInput = wait_char();
		}
	}
}
예제 #3
0
int main( void )
{
    Game game;
    setup_screen();
    game.dog = create_sprite( 0, 0, 1, 1, "D" );
    draw_sprite( game.dog );
    wait_char();
    cleanup_screen();
}
예제 #4
0
int main() {
	setup_screen();

	draw_paddles();

	draw_string(0, screen_height( ) - 1, "Press any key to finish...");
	wait_char();
	cleanup_screen();
	
	return 0;
}
예제 #5
0
void zombie_racer(int start_x, int start_y) {
	sprite_id racetrack = generate_racetrack();
	int x = start_x;
	int y = start_y;

	int dir = 0; // Start facing North.

	bool alive = on_racetrack(x, y);
	update_view(racetrack, x, y, alive);
	int key = wait_char();

	while ((key != 'q') && (key >= 0) && alive) {
		switch (key) {
			case '1':
				dir = (dir + 7) % 8;
				break;
			case '3':
				dir = (dir + 1) % 8;
				break;
		}
		
		switch (dir) {
			case 0:
				y--;
				break;
			case 1:
				y--;
				x++;
				break;
			case 2:
				x++;
				break;
			case 3:
				x++;
				y++;
				break;
			case 4:
				y++;
				break;
			case 5:
				y++;
				x--;
				break;
			case 6:
				x--;
				break;
			case 7:
				x--;
				y--;
				break;
		}

		alive = on_racetrack(x, y);
		update_view(racetrack, x, y, alive);
		timer_pause(100);
		key = wait_char();
	}
	
	free(racetrack->bitmap);
	racetrack->bitmap = NULL;
	destroy_sprite(racetrack);
	
	timer_pause(1000);
}
예제 #6
0
void play_ten_squares() {
	clear_screen();
	draw_string( 0, screen_height() - 1, "Press any key to continue..." );
	show_screen();
	wait_char();

	char bitmap1[] =
		"11111111"
		"1      1"
		"1      1"
		"1      1"
		"1      1"
		"1      1"
		"1      1"
		"11111111"
		;

	char bitmap2[] =
		"11111"
		"1   1"
		"1   1"
		"1   1"
		"11111"
		;

	char bitmap3[] = {
		"111111111111"
		"1          1"
		"1          1"
		"1          1"
		"1          1"
		"1          1"
		"1          1"
		"111111111111"
	};

	char *bitmaps[3] = { bitmap1, bitmap2, bitmap3 };
	char widths[] = { 8, 5, 12 };
	char heights[] = { 8, 5, 8 };

#define SPR_COUNT (10)

	sprite_id sprites[SPR_COUNT];

	setup_ten_squares(
		sprites, bitmaps, widths, heights,
		SPR_COUNT,
		sizeof( bitmaps ) / sizeof( bitmaps[0] )
		);

	int key = 0;

	while ( key != 'q' ) {
		clear_screen();

		update_ten_squares( sprites );
		draw_ten_squares( sprites );
		draw_string( 0, screen_height() - 1, "Press 'q' to exit..." );
		show_screen();

		timer_pause( 50 );
		key = get_char();
	}

	cleanup_ten_squares( sprites );
}