void intro(void){ int i, sound = 0; time_t begin, now; float speed[6]; circle *planet[6], *moon1; camera *cam = new_camera(0.0, 0.0, 800.0, 800.0); surface *dark_weaver = new_image("dark_weaver.png"); surface *credits = new_image("credits.png"); for(i = 0; i < 6; i ++){ speed[i] = ((rand() % 20) + 10) / 1000.0; planet[i] = new_circle(450.0 + i*50, 450.0 + i*50, (rand() % 20) + 10.0); } moon1 = new_circle(planet[2] -> x + 40.0, planet[2] -> y + 40.0, 10.0); limit_camera(cam, window_width / 2 - 400, window_height / 2 - 400, 800, 800); begin = time(NULL); initialize_star(); for(;;){ now = time(NULL); if(now - begin > 3){ draw_surface(dark_weaver, window, (window_width - dark_weaver -> width) / 2, (window_height - dark_weaver -> height) / 2); draw_surface(credits, window, (window_width - credits -> width) / 2, 0); if(sound == 0){ sound = 1; play_sound("weaver.ogg"); } if(now - begin > 5) break; } for(i = 0; i < 6; i ++) erase_fullcircle(cam, planet[i]); erase_fullcircle(cam, moon1); for(i = 0; i < 6; i ++) rotate_circle(planet[i], 400.0, 400.0, speed[i]); rotate_circle(moon1, planet[2] -> x, planet[2] -> y, speed[2]*10.0); film_fullcircle(cam, planet[0], 0x220000); film_fullcircle(cam, planet[1], 0x002200); film_fullcircle(cam, planet[2], 0x000022); film_fullcircle(cam, planet[3], 0x002222); film_fullcircle(cam, planet[4], 0x220022); film_fullcircle(cam, planet[5], 0x222222); film_fullcircle(cam, moon1, 0x444400); update_star(); weaver_rest(10000000); } destroy_surface(dark_weaver); destroy_surface(credits); destroy_star(); }
int main(int argc, char **argv){ awake_the_weaver(); // Initializing Weaver API camera *cam = new_camera(0.0, 0.0, 100.0, 100.0); circle *star = new_circle(50.0, 50.0, 20.0); circle *planet = new_circle(90.0, 90.0, 5.0); rectangle *trash = new_rectangle(75.0, 50.0, 1.25, 2.5); rectangle *ufo = new_rectangle(25.0, 50.0, 1.5, 1.5); film_fullcircle(cam, star, YELLOW); film_fullcircle(cam, planet, BLUE); film_rectangle(cam, trash, GREEN); film_fullrectangle(cam, ufo, WHITE); int camera_moved = 0; // Main loop for(;;){ get_input(); if(keyboard[ESC]){ break; } if(keyboard[UP] || keyboard[DOWN] || keyboard[LEFT] || keyboard[RIGHT] || keyboard[MINUS] || keyboard[PLUS] || keyboard[ENTER]){ film_fullcircle(cam, star, BLACK); film_fullcircle(cam, planet, BLACK); film_rectangle(cam, trash, BLACK); film_fullrectangle(cam, ufo, BLACK); camera_moved = 1; } if(keyboard[UP]) cam -> y -= 1.0; if(keyboard[DOWN]) cam -> y += 1.0; if(keyboard[LEFT]) cam -> x -= 1.0; if(keyboard[RIGHT]) cam -> x += 1.0; if(keyboard[PLUS]) zoom_camera(cam, 1.01); if(keyboard[MINUS]) zoom_camera(cam, 0.99); if(keyboard[ENTER]) center_camera(cam, 50.0, 50.0); film_fullcircle(cam, planet, BLACK); rotate_circle(planet, 50.0, 50.0, 0.01); film_fullcircle(cam, planet, BLUE); if(camera_moved){ film_fullcircle(cam, star, YELLOW); film_rectangle(cam, trash, GREEN); film_fullrectangle(cam, ufo, WHITE); camera_moved = 0; } weaver_rest(10000000); } may_the_weaver_sleep(); return 0; }