c++ - SDL_Event e; passing to function -
what e in
sdl_event e;
how pass e 1 function function function. possible?
basically e bool or int
bool x_out_window() { bool quit = false; sdl_event e; while( !quit ) { while( sdl_pollevent( &e ) != 0 ) { if( e.type == sdl_quit ) quit = true; else detect_key_press(e.type); } } } bool detect_key_press(e.type) { //sdl_event e; if( e.type == sdl_keydown ) { //select surfaces based on key press switch( e.key.keysym.sym ) { case sdlk_up: gcurrentsurface = gkeypresssurfaces[ key_press_surface_up ]; break; case sdlk_down: gcurrentsurface = gkeypresssurfaces[ key_press_surface_down ]; break; case sdlk_left: gcurrentsurface = gkeypresssurfaces[ key_press_surface_left ]; break; case sdlk_right: gcurrentsurface = gkeypresssurfaces[ key_press_surface_right ]; break; default: gcurrentsurface = gkeypresssurfaces[ key_press_surface_default ]; break; } sdl_blitsurface( gxout, null, gscreensurface, null ); sdl_updatewindowsurface( gwindow ); } }
i sorry if silly question unable understand concept, novice in coding.
just declare function 2 as
void funtion2(sdl_event e){ //... }
in c++ need provide type both function (probably void
here) , parameters (a sdl_event
named e
here)
Comments
Post a Comment