예제 #1
0
def main():
	# config
	Config.backend = 'pyglet'
	Config.init()

	# init
	context_manager = ContextManager()
	universe.context_manager = context_manager
	resolution = Config.resolution
	context = Context("context")

	# status text
	# FIXME : had a shift to center text
	shift_x = 90
	text = Text('text', context, 4, '????', 'Times New Roman', 80)
	text.set_location(np.array([Config.resolution[0] / 2 - shift_x, 
				Config.resolution[1] / 32]))
	text.stop()

	# instruction text
	# FIXME : had a shift to center text
	shift_x = 60
	instr = Text('text', context, 4, 'hit SPACE bar', 'Times New Roman', 20)
	instr.set_location(np.array([Config.resolution[0] / 2 - shift_x, 
				(Config.resolution[1] * 7) / 8]))
	instr.stop()



	# background
	bg_left = create_bg_left(context, text, resolution)
	bg_right = create_bg_right(context, text, resolution)
	player = create_player(context, resolution)

	# collider manager
	collider_manager = CollisionManager()
	collider_manager.add_collidable_ref_sprite(player)
	collider_manager.add_collidable_sprites([bg_left, bg_right])

	signal = (KeyBoardDevice.constants.KEYDOWN,
			KeyBoardDevice.constants.K_SPACE)
	context.connect(signal, collider_manager,
			"on_collision", asynchronous=False)

	# context
	geometry = (0, 0, resolution[0], resolution[1])
	screen = VirtualScreenRealCoordinates('screen', geometry)
	context.add_screen(screen)
	context_manager.add_state(context)
	context_manager.set_initial_state(context)
	context_manager.start()

	# start
	event_loop = Config.get_event_loop()
	event_loop.start()
예제 #2
0
def main():
	# config
	Config.backend = 'pyglet'
	Config.init()

	# init
	context_manager = ContextManager()
	universe.context_manager = context_manager
	resolution = Config.resolution
	context = Context("context")
	bg = create_bg(context)

	# game context
	avatars = create_avatars(context)
	geometry = (0, 0, resolution[0], resolution[1])
	screen = VirtualScreenWorldCoordinates('screen', geometry)
	context.add_screen(screen)
	context_manager.add_state(context)
	context_manager.set_initial_state(context)
	context_manager.start()

	# avatar switch
	switcher = AvatarSwitcher(avatars[0], avatars[1])
        signal = (KeyBoardDevice.constants.KEYDOWN,
                  KeyBoardDevice.constants.K_SPACE)
        context.connect(signal, switcher, "on_space_press")

	# instruction text
	# FIXME : had a shift to center text
	shift_x = 60
	instr = Text('text', context, 4, 'hit SPACE bar', 'Times New Roman', 20)
	instr.set_location(np.array([Config.resolution[0] / 2 - shift_x,
		(Config.resolution[1] * 15) / 16]))

	# start
	event_loop = Config.get_event_loop()
	event_loop.start()
예제 #3
0
def main():
	# config
	Config.backend = 'pyglet'
	Config.init()

	# init
	context_manager = ContextManager()
	universe.context_manager = context_manager
	resolution = Config.resolution
	context = Context("context")

	# status text
	# FIXME : had a shift to center text
	shift_x = 90
	text = Text('text', context, 4, '????', 'Times New Roman', 80)
	text.set_location(np.array([Config.resolution[0] / 2 - shift_x, 
				Config.resolution[1] / 32]))
	text.stop()

	# instruction text
	# FIXME : had a shift to center text
	shift_x = 60
	instr = Text('text', context, 4, 'hit SPACE bar', 'Times New Roman', 20)
	instr.set_location(np.array([Config.resolution[0] / 2 - shift_x, 
				(Config.resolution[1] * 15) / 16]))
	instr.stop()


	# squares
	squares = []
	for (color, colorname) in [((64, 32, 32), 'red'),
				((32, 64, 32), 'green'), 
				((32, 32, 64), 'blue'), 
				((64, 64, 32), 'yellow')]:
		s = create_colored_square(context, text, color,
					colorname, resolution)
		squares.append(s)
	for square in squares: square.add_squares(squares)
	init_squares_locations(resolution)
	move_squares_randomly(squares)

	# player and nurse
	player = create_player(context, resolution)
	nurse = create_nurse(context, text, resolution)

	# collider manager
	collider_manager = CollisionManager()
	collider_manager.add_collidable_ref_sprite(player)
	collider_manager.add_collidable_sprite(nurse) # first in the check list
	collider_manager.add_collidable_sprites(squares)

	signal = (KeyBoardDevice.constants.KEYDOWN,
			KeyBoardDevice.constants.K_SPACE)
	context.connect(signal, collider_manager,
			"on_collision", asynchronous=False)

	# context
	geometry = (0, 0, resolution[0], resolution[1])
	screen = VirtualScreenRealCoordinates('screen', geometry)
	context.add_screen(screen)
	context_manager.add_state(context)
	context_manager.set_initial_state(context)
	context_manager.start()

	# start
	event_loop = Config.get_event_loop()
	event_loop.start()