comparison eclviewer.py @ 119:fad7b44cebf2

Switch from pygame + PyOpenGL to pyglet
author Thibaut Girka <thib@sitedethib.com>
date Wed, 07 Sep 2011 18:12:24 +0200
parents 2a03940deea3
children 174324a4da51
comparison
equal deleted inserted replaced
118:c596a1a69402 119:fad7b44cebf2
13 ## GNU General Public License for more details. 13 ## GNU General Public License for more details.
14 ## 14 ##
15 15
16 import sys 16 import sys
17 import os 17 import os
18
19 import pygame
20 18
21 from pytouhou.resource.loader import Loader 19 from pytouhou.resource.loader import Loader
22 from pytouhou.game.background import Background 20 from pytouhou.game.background import Background
23 from pytouhou.opengl.gamerenderer import GameRenderer 21 from pytouhou.opengl.gamerenderer import GameRenderer
24 from pytouhou.game.game import Game 22 from pytouhou.game.game import Game
35 stage = resource_loader.get_stage('stage%d.std' % stage_num) 33 stage = resource_loader.get_stage('stage%d.std' % stage_num)
36 34
37 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage_num,)) 35 background_anm_wrapper = resource_loader.get_anm_wrapper(('stg%dbg.anm' % stage_num,))
38 background = Background(stage, background_anm_wrapper) 36 background = Background(stage, background_anm_wrapper)
39 37
40 # Renderer
41 renderer = GameRenderer(resource_loader, game, background)
42 renderer.start()
43
44 # Let's go! 38 # Let's go!
45 print(stage.name) 39 print(stage.name)
46 40
47 # Main loop 41 # Main loop
48 clock = pygame.time.Clock() 42 renderer = GameRenderer(resource_loader, game, background)
49 while True: 43 renderer.start()
50 # Check events
51 for event in pygame.event.get():
52 if event.type == pygame.QUIT or (event.type == pygame.KEYDOWN and event.key in (pygame.K_ESCAPE, pygame.K_q)):
53 sys.exit(0)
54 elif event.type == pygame.KEYDOWN:
55 if event.key == pygame.K_RETURN and event.mod & pygame.KMOD_ALT:
56 pygame.display.toggle_fullscreen()
57 keystate = 0 #TODO
58
59 # Update game
60 background.update(game.game_state.frame) #TODO
61 game.run_iter(keystate)
62
63 # Draw everything
64 renderer.render()
65
66 pygame.display.flip()
67
68 clock.tick(120)
69
70 44
71 45
72 try: 46 try:
73 file_path, stage_num = sys.argv[1:] 47 file_path, stage_num = sys.argv[1:]
74 stage_num = int(stage_num) 48 stage_num = int(stage_num)