void unload_room (void) { /* modules */ unload_floor (); unload_broken_floor (); unload_skeleton_floor (); unload_loose_floor (); unload_opener_floor (); unload_closer_floor (); unload_spikes_floor (); unload_wall (); unload_pillar (); unload_big_pillar (); unload_door (); unload_level_door (); unload_chopper (); unload_bricks (); unload_torch (); unload_window (); unload_balcony (); unload_arch (); unload_carpet (); unload_stars (); unload_mirror (); }
int main( int argc, char *argv[] ) { int quit = 0; pthread_t render_loop_thread = -1; IDirectFBSurface *primary; IDirectFBEventBuffer *buffer; DFBSurfaceDescription dsc; srand((long)time(0)); DFBCHECK(DirectFBInit( &argc, &argv )); /* create the super interface */ DFBCHECK(DirectFBCreate( &dfb )); /* get an interface to the primary keyboard and create an input buffer for it */ DFBCHECK(dfb->CreateInputEventBuffer( dfb, DICAPS_ALL, DFB_FALSE, &buffer )); /* set our cooperative level to DFSCL_FULLSCREEN for exclusive access to the primary layer */ dfb->SetCooperativeLevel( dfb, DFSCL_FULLSCREEN ); /* get the primary surface, i.e. the surface of the primary layer we have exclusive access to */ dsc.flags = DSDESC_CAPS; dsc.caps = DSCAPS_PRIMARY | DSCAPS_DOUBLE; DFBCHECK(dfb->CreateSurface( dfb, &dsc, &primary )); DFBCHECK(primary->GetSize( primary, &xres, &yres )); /* load font */ { DFBFontDescription desc; desc.flags = DFDESC_HEIGHT; desc.height = yres/10; DFBCHECK(dfb->CreateFont( dfb, FONT, &desc, &font )); DFBCHECK(primary->SetFont( primary, font )); } projection = matrix_new_perspective( 400 ); camera = matrix_new_identity(); load_stars(); generate_starfield(); pthread_mutex_lock( &render_start ); pthread_mutex_lock( &render_finish ); pthread_create( &render_loop_thread, NULL, render_loop, (void*)primary ); /* main loop */ while (!quit) { static float translation[3] = { 0, 0, 0 }; DFBInputEvent evt; /* transform world to screen coordinates */ transform_starfield(); /* start rendering before waiting for events */ start_rendering(); buffer->WaitForEvent( buffer ); /* process event buffer */ while (buffer->GetEvent( buffer, DFB_EVENT(&evt)) == DFB_OK) { if (evt.type == DIET_KEYPRESS) { switch (evt.key_id) { case DIKI_ESCAPE: /* quit main loop */ quit = 1; break; case DIKI_LEFT: translation[0] = 10; break; case DIKI_RIGHT: translation[0] = -10; break; case DIKI_UP: translation[2] = -10; break; case DIKI_DOWN: translation[2] = 10; break; default: break; } } else if (evt.type == DIET_KEYRELEASE) { switch (evt.key_id) { case DIKI_LEFT: case DIKI_RIGHT: translation[0] = 0; break; case DIKI_UP: case DIKI_DOWN: translation[2] = 0; break; default: break; } } else if (evt.type == DIET_AXISMOTION && (evt.flags & DIEF_AXISREL)) { switch (evt.axis) { case DIAI_X: matrix_rotate( camera, Y, -evt.axisrel/80.0f ); break; case DIAI_Y: matrix_rotate( camera, X, evt.axisrel/80.0f ); break; default: break; } } } matrix_translate( camera, translation[0], translation[1], translation[2] ); /* finish rendering before retransforming the world */ finish_rendering(); } pthread_cancel( render_loop_thread ); pthread_mutex_unlock( &render_start ); pthread_join( render_loop_thread, NULL ); render_loop_thread = -1; unload_stars(); free( camera ); free( projection ); buffer->Release( buffer ); primary->Release( primary ); dfb->Release( dfb ); return 0; }