Beispiel #1
0
void main_menu() {
	/* Play a simulated game in the background */
	unsigned char _;
	initialize();
	while (1) {
		unsigned char key;

		screen_clear(screen);
		draw_actors();
		draw_string(screen, 28, 0, "-- Pong --");
		draw_string(screen, 8, 10, "Press ENTER to begin");
		screen_draw(screen);
		update_ai(&left_paddle);
		update_ai(&right_paddle);
		update_ball();

		key = app_get_key(&_);
		switch (key) {
		case KEY_ENTER:
			return;
		case KEY_MODE:
			exit(0);
			break;
		}
		
		ksleep(5);
	}
}
Beispiel #2
0
void score(bool player) {
	if (player) {
		left_score++;
	} else {
		right_score++;
	}

	ball_motion.x = -ball_motion.x;

	if (ball_motion.y > 1) {
		ball_motion.y = 1;
	} else if (ball_motion.y < -1) {
		ball_motion.y = -1;
	}

	ball.x = DISPLAY_WIDTH / 2 - (ball_width / 2);
	ball.y = DISPLAY_HEIGHT / 2 - (ball_height / 2);

	if (game_running) {
		screen_clear(screen);
		draw_actors();
		draw_score();
		draw_string(screen, 40, 10, "SCORE");
		screen_draw(screen);
		ksleep(1000);
	}
}
Beispiel #3
0
bool render_game()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    mat4 t = ident;
    draw_maps(t);

    draw_player();
    draw_actors();
    draw_ui();
    return true;
}
Beispiel #4
0
void draw() {
	screen_clear(screen);
	draw_actors();
	draw_score();
	screen_draw(screen);
}