Mercurial > sypikslang
diff gamelib/main.py @ 38:7e18a67995f6
fixed pep8 issues
author | Rizmari Versfeld <rizziepit@gmail.com> |
---|---|
date | Mon, 07 May 2012 00:13:11 +0200 |
parents | 9c4bf1f15431 |
children | d82d3e54a4ef |
line wrap: on
line diff
--- a/gamelib/main.py Sun May 06 22:05:40 2012 +0200 +++ b/gamelib/main.py Mon May 07 00:13:11 2012 +0200 @@ -27,44 +27,40 @@ # input variables MOUSE_DOWN = False - - + + def main(): - #print data.load('sample.txt').read() - clock = Clock() - screen = pygame.display.set_mode((800, 600)) - window = Window(screen) - window.background_colour = (0,0,0) - button1 = MainMenuButton(((800-128)/2, 200), 'Start') - window.add_child(button1) - WINDOW_STACK.append(window) - while GAME_IS_RUNNING: - process_input() - draw(screen) - clock.tick(FPS) + clock = Clock() + screen = pygame.display.set_mode((800, 600)) + window = Window(screen) + window.background_colour = (0, 0, 0) + button1 = BigButton(((800 - 128) / 2, 200), 'Start') + window.add_child(button1) + WINDOW_STACK.append(window) + while GAME_IS_RUNNING: + process_input() + draw(screen) + clock.tick(FPS) - + def draw(screen): - for view in WINDOW_STACK: - view.draw(screen) - pygame.display.flip() - - + for view in WINDOW_STACK: + view.draw(screen) + pygame.display.flip() + + def process_input(): - global MOUSE_DOWN - global GAME_IS_RUNNING - for event in pygame.event.get(): - if MOUSE_DOWN: - if event.type == MOUSEBUTTONUP: - MOUSE_DOWN = False - WINDOW_STACK[len(WINDOW_STACK)-1].on_mouse_up(event.pos) - elif event.type == MOUSEMOTION: - WINDOW_STACK[len(WINDOW_STACK)-1].on_mouse_move(event.pos) - elif not MOUSE_DOWN and event.type == MOUSEBUTTONDOWN: - MOUSE_DOWN = True - WINDOW_STACK[len(WINDOW_STACK)-1].on_mouse_down(event.pos) - elif event.type == QUIT: - GAME_IS_RUNNING = False - - - \ No newline at end of file + global MOUSE_DOWN + global GAME_IS_RUNNING + for event in pygame.event.get(): + if MOUSE_DOWN: + if event.type == MOUSEBUTTONUP: + MOUSE_DOWN = False + WINDOW_STACK[len(WINDOW_STACK) - 1].on_mouse_up(event.pos) + elif event.type == MOUSEMOTION: + WINDOW_STACK[len(WINDOW_STACK) - 1].on_mouse_move(event.pos) + elif not MOUSE_DOWN and event.type == MOUSEBUTTONDOWN: + MOUSE_DOWN = True + WINDOW_STACK[len(WINDOW_STACK) - 1].on_mouse_down(event.pos) + elif event.type == QUIT: + GAME_IS_RUNNING = False