comparison eosd @ 512:b39ad30c6620

Add a pure SDL backend.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 05 Dec 2013 01:55:39 +0100
parents 1bc014f9d572
children 5e3e0b09a531
comparison
equal deleted inserted replaced
511:2e8ceaa85d5c 512:b39ad30c6620
47 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.') 47 parser.add_argument('--verbosity', metavar='VERBOSITY', choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], help='Select the wanted logging level.')
48 parser.add_argument('--game', metavar='GAME', choices=['EoSD'], default='EoSD', help='Select the game engine to use.') 48 parser.add_argument('--game', metavar='GAME', choices=['EoSD'], default='EoSD', help='Select the game engine to use.')
49 parser.add_argument('--port', metavar='PORT', type=int, default=0, help='Local port to use for netplay') 49 parser.add_argument('--port', metavar='PORT', type=int, default=0, help='Local port to use for netplay')
50 parser.add_argument('--remote', metavar='REMOTE', default=None, help='Remote address') 50 parser.add_argument('--remote', metavar='REMOTE', default=None, help='Remote address')
51 parser.add_argument('--no-friendly-fire', action='store_false', help='Allow friendly-fire during netplay.') 51 parser.add_argument('--no-friendly-fire', action='store_false', help='Allow friendly-fire during netplay.')
52 parser.add_argument('--backend', metavar='BACKEND', choices=['opengl', 'sdl'], default='opengl', help='Which backend to use (opengl or sdl for now).')
52 53
53 args = parser.parse_args() 54 args = parser.parse_args()
54 55
55 56
56 import sys 57 import sys
57 import logging 58 import logging
59
60 if args.backend == 'opengl':
61 from pytouhou.ui.gamerenderer import GameRenderer
62 opengl = True
63 elif args.backend == 'sdl':
64 from pytouhou.ui.sdl.gamerenderer import GameRenderer
65 opengl = False
58 66
59 from pytouhou.lib.sdl import SDL 67 from pytouhou.lib.sdl import SDL
60 from pytouhou.ui.window import Window 68 from pytouhou.ui.window import Window
61 from pytouhou.resource.loader import Loader 69 from pytouhou.resource.loader import Loader
62 from pytouhou.ui.gamerunner import GameRunner 70 from pytouhou.ui.gamerunner import GameRunner
63 from pytouhou.ui.gamerenderer import GameRenderer
64 from pytouhou.game.player import GameOver 71 from pytouhou.game.player import GameOver
65 from pytouhou.formats.t6rp import T6RP, Level 72 from pytouhou.formats.t6rp import T6RP, Level
66 from pytouhou.utils.random import Random 73 from pytouhou.utils.random import Random
67 from pytouhou.vm.msgrunner import NextStage 74 from pytouhou.vm.msgrunner import NextStage
68 from pytouhou.formats.hint import Hint 75 from pytouhou.formats.hint import Hint
165 hints = Hint.read(file) 172 hints = Hint.read(file)
166 173
167 game_class = GameBossRush if boss_rush else Game 174 game_class = GameBossRush if boss_rush else Game
168 175
169 common = Common(resource_loader, characters, continues, stage_num - 1) 176 common = Common(resource_loader, characters, continues, stage_num - 1)
170 renderer = GameRenderer(resource_loader, window.use_fixed_pipeline) 177 renderer = GameRenderer(resource_loader, window)
171 runner = GameRunner(window, renderer, common, resource_loader, skip_replay, con) 178 runner = GameRunner(window, renderer, common, resource_loader, skip_replay, con)
172 window.set_runner(runner) 179 window.set_runner(runner)
173 180
174 while True: 181 while True:
175 first_player = common.players[0] 182 first_player = common.players[0]
248 255
249 256
250 with SDL(): 257 with SDL():
251 window = Window(double_buffer=(not args.single_buffer), 258 window = Window(double_buffer=(not args.single_buffer),
252 fps_limit=args.fps_limit, 259 fps_limit=args.fps_limit,
253 fixed_pipeline=args.fixed_pipeline) 260 fixed_pipeline=args.fixed_pipeline, opengl=opengl)
254 261
255 main(window, args.path, tuple(args.data), args.stage, args.rank, 262 main(window, args.path, tuple(args.data), args.stage, args.rank,
256 args.character, args.replay, args.save_replay, args.skip_replay, 263 args.character, args.replay, args.save_replay, args.skip_replay,
257 args.boss_rush, args.debug, args.no_background, args.no_particles, 264 args.boss_rush, args.debug, args.no_background, args.no_particles,
258 args.no_music, args.hints, args.verbosity, args.port, args.remote, 265 args.no_music, args.hints, args.verbosity, args.port, args.remote,