changed code from sdl1 to sdl2