comparison pytouhou/lib/sdl.pyx @ 464:36bc577b2392

Make the window resizable, and scale its content correctly.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 11 Sep 2013 15:55:19 +0200
parents ec327e58b477
children 2276229282fd
comparison
equal deleted inserted replaced
463:11708a1d0a1a 464:36bc577b2392
18 GL_DEPTH_SIZE = SDL_GL_DEPTH_SIZE 18 GL_DEPTH_SIZE = SDL_GL_DEPTH_SIZE
19 19
20 WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED 20 WINDOWPOS_CENTERED = SDL_WINDOWPOS_CENTERED
21 WINDOW_OPENGL = SDL_WINDOW_OPENGL 21 WINDOW_OPENGL = SDL_WINDOW_OPENGL
22 WINDOW_SHOWN = SDL_WINDOW_SHOWN 22 WINDOW_SHOWN = SDL_WINDOW_SHOWN
23 WINDOW_RESIZABLE = SDL_WINDOW_RESIZABLE
23 24
24 SCANCODE_Z = SDL_SCANCODE_Z 25 SCANCODE_Z = SDL_SCANCODE_Z
25 SCANCODE_X = SDL_SCANCODE_X 26 SCANCODE_X = SDL_SCANCODE_X
26 SCANCODE_LSHIFT = SDL_SCANCODE_LSHIFT 27 SCANCODE_LSHIFT = SDL_SCANCODE_LSHIFT
27 SCANCODE_UP = SDL_SCANCODE_UP 28 SCANCODE_UP = SDL_SCANCODE_UP
29 SCANCODE_LEFT = SDL_SCANCODE_LEFT 30 SCANCODE_LEFT = SDL_SCANCODE_LEFT
30 SCANCODE_RIGHT = SDL_SCANCODE_RIGHT 31 SCANCODE_RIGHT = SDL_SCANCODE_RIGHT
31 SCANCODE_LCTRL = SDL_SCANCODE_LCTRL 32 SCANCODE_LCTRL = SDL_SCANCODE_LCTRL
32 SCANCODE_ESCAPE = SDL_SCANCODE_ESCAPE 33 SCANCODE_ESCAPE = SDL_SCANCODE_ESCAPE
33 34
35 WINDOWEVENT_RESIZED = SDL_WINDOWEVENT_RESIZED
36
34 KEYDOWN = SDL_KEYDOWN 37 KEYDOWN = SDL_KEYDOWN
35 QUIT = SDL_QUIT 38 QUIT = SDL_QUIT
39 WINDOWEVENT = SDL_WINDOWEVENT
36 40
37 41
38 class SDLError(Exception): 42 class SDLError(Exception):
39 pass 43 pass
40 44
205 while SDL_PollEvent(&event): 209 while SDL_PollEvent(&event):
206 if event.type == SDL_KEYDOWN: 210 if event.type == SDL_KEYDOWN:
207 ret.append((event.type, event.key.keysym.scancode)) 211 ret.append((event.type, event.key.keysym.scancode))
208 elif event.type == SDL_QUIT: 212 elif event.type == SDL_QUIT:
209 ret.append((event.type,)) 213 ret.append((event.type,))
214 elif event.type == SDL_WINDOWEVENT:
215 ret.append((event.type, event.window.event, event.window.data1, event.window.data2))
210 return ret 216 return ret
211 217
212 218
213 cdef const Uint8* get_keyboard_state() nogil: 219 cdef const Uint8* get_keyboard_state() nogil:
214 return SDL_GetKeyboardState(NULL) 220 return SDL_GetKeyboardState(NULL)