/* Include libraries */ #include /* Include header files */ #include "fractData.hh" #include "mansdl.hh" void mansdl::checkEvent(fractData* fd, SDL_Event* event) { const Uint8* keyState = SDL_GetKeyboardState(NULL); bool ctrl = keyState[SDL_SCANCODE_LCTRL] || keyState[SDL_SCANCODE_RCTRL]; switch(event->type) { case SDL_QUIT: quit = true; break; case SDL_MOUSEWHEEL: if(event->wheel.y > 0) { switch(ctrl) { case true: { unsigned int result = fd->maxIter * 2; if(result > 2) { fd->maxIter = result; doGenerate = true; } break; } case false: fd->zoom = fd->zoom * 1.25; doGenerate = true; break; } } else if(event->wheel.y < 0) { switch(ctrl) { case true: { unsigned int result = fd->maxIter / 2; if(result >= 2) { fd->maxIter = result; doGenerate = true; } break; } case false: fd->zoom = fd->zoom / 1.25; doGenerate = true; break; } } break; case SDL_KEYDOWN: switch(ctrl) { case true: if(keyState[SDL_SCANCODE_X]) quit = true; if(fd->fract == julia) { if(keyState[SDL_SCANCODE_W]) { fd->julia_imag = fd->julia_imag - 0.005; doGenerate = true; } if(keyState[SDL_SCANCODE_S]) { fd->julia_imag = fd->julia_imag + 0.005; doGenerate = true; } if(keyState[SDL_SCANCODE_A]) { fd->julia_real = fd->julia_real - 0.005; doGenerate = true; } if(keyState[SDL_SCANCODE_D]) { fd->julia_real = fd->julia_real + 0.005; doGenerate = true; } } break; case false: if(keyState[SDL_SCANCODE_A]) { fd->real = fd->real - 0.1 / fd->zoom; doGenerate = true; } if(keyState[SDL_SCANCODE_D]) { fd->real = fd->real + 0.1 / fd->zoom; doGenerate = true; } if(keyState[SDL_SCANCODE_W]) { fd->imag = fd->imag - 0.1 / fd->zoom; doGenerate = true; } if(keyState[SDL_SCANCODE_S]) { fd->imag = fd->imag + 0.1 / fd->zoom; doGenerate = true; } break; } break; } }