The SDL_PollEvent(@event) call looks fishy to me. You're passing a pointer to a PSDL_Event (PPSDL_Event) and the function expects a PSDL_Event. Replace event variable declaration from PSDL_event to SDL_event and it should work.