예제 #1
0
파일: event.c 프로젝트: mimusangel/wolf3d
int				loop_hook(t_event *e)
{
	if (e->menu == MAIN_MENU)
		control_menu(e);
	else if (e->menu == GAME)
		control_player(e);
	else if (e->menu == TEXTURE_EDITOR)
		control_edit_tex(e);
	clear(e);
	if (e->menu == GAME)
	{
		render_map(e);
		render_minimap(e);
	}
	else if (e->menu == TEXTURE_EDITOR)
		render_edit_tex(e);
	mlx_put_image_to_window(e->mlx, e->win, e->img.addr, 0, 0);
	if (e->menu == GAME)
		mlx_string_put(e->mlx, e->win, 5, e->height - 22, 0xffffff,
			"Arrow or WASD to move and rotate");
	if (e->menu == MAIN_MENU)
		render_menu(e);
	else if (e->menu == TEXTURE_EDITOR)
		render_edit_tex_gui(e);
	return (0);
}
예제 #2
0
파일: render.c 프로젝트: xyphor/cave9
void render_frame (Render* render, Game* game)
{
	display_start_frame (0,0,0);

	if (game != NULL) {
		float hit = ship_hit(&game->player);
		if(hit < .9) { // avoid drawing the cave from outside
			glPushMatrix();
				render_world_transform (render, &game->player);
				cave_model (render, &game->cave, DISPLAYMODE_NORMAL, 0);
				monolith_model (render, game);
			glPopMatrix();
		}

		if(hit) {
			glDisable (GL_DEPTH_TEST);
			glEnable  (GL_BLEND);
			glDisable (GL_TEXTURE_2D);
			glDisable (GL_LIGHTING);

			glColor4f(1,0,0,hit/2.);
			glBegin (GL_QUADS);
			glVertex3f(-1,-1,-1);
			glVertex3f(+1,-1,-1);
			glVertex3f(+1,+1,-1);
			glVertex3f(-1,+1,-1);
			glEnd();
		}

		ship_model (render, &game->player);
		render_minimap (render, game);
		render_hud (render, game);
	}

	display_text_box (&render->display, &render->msg_id, 
			render->font, render_message_buf, 
			.5,.5,1,.25, 1,1,1,1);

	display_end_frame();
}