示例#1
0
	def __init__(self, title='Lobby', x=0, y=0, batch=None, group=1):
		super(lobby, self).__init__(width=10, height=10, alpha=0, batch=batch)

		self.sprites['background'] = generic_sprite(game_data.images[261].to_png(game_data.colorPalettes[260]), moveable=False, clickable=False, batch=batch, group=0)
		
		self.sprites['cancel_lobby'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=self.abort_lobby, batch=batch, group=1)
		self.sprites['cancel_lobby'].x = 10
		self.sprites['cancel_lobby'].y = 10
		self.sprites['cancel_lobby'].text = 'Cancel Lobby'

		self.sprites['start_game'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=start_game, batch=batch, group=1)
		self.sprites['start_game'].x = self.sprites['cancel_lobby'].x
		self.sprites['start_game'].y = self.sprites['cancel_lobby'].y + self.sprites['cancel_lobby'].height + 10
		self.sprites['start_game'].text = 'Start Game'

		self.sprites['lobby_background'] = generic_sprite(batch=batch, width=185, height=115, group=1, alpha=128)
		self.sprites['lobby_background'].x = self.sprites['start_game'].x + self.sprites['start_game'].width + 20
		self.sprites['lobby_background'].y = self.sprites['cancel_lobby'].y

		raw_group = group
		if type(group) == int:
			group = cosmic['pages'][cosmic['active_page']]['layers'][group]


		print(title, self.sprites['lobby_background'].x+(self.sprites['lobby_background'].width/2), self.sprites['lobby_background'].y+self.sprites['lobby_background'].height-30, self.batch, cosmic['pages'][cosmic['active_page']]['layers'][raw_group+1] if group else None)
		self.titleTxt = pyglet.text.Label(title, x=self.sprites['lobby_background'].x+(self.sprites['lobby_background'].width/2), y=self.sprites['lobby_background'].y+self.sprites['lobby_background'].height-30, anchor_x='center', anchor_y='center', batch=self.batch, group=cosmic['pages'][cosmic['active_page']]['layers'][raw_group+1] if group else None)
示例#2
0
	def __init__(self, race, batch=None):
		super(gameUI, self).__init__(width=conf['resolution'].width(), height=conf['resolution'].height(), alpha=0, batch=batch)

		self.race = race

		self.sprites['minimap'] = generic_sprite(getTexture(conf['ui'][self.race]['sidebars']['left']['minimap']['empty']), bind=start_game)
		self.sprites['minimap'].x = 0
		self.sprites['minimap'].y = conf['resolution'].height() - self.sprites['minimap'].height

		self.sprites['left_bar'] = generic_sprite(getTexture(conf['ui'][self.race]['sidebars']['left']['normal']), bind=start_game)
		self.sprites['left_bar'].x = 0
		self.sprites['left_bar'].y = conf['resolution'].height() - self.sprites['minimap'].height - self.sprites['left_bar'].height

		self.sprites['top_bar'] = generic_sprite(getTexture(conf['ui'][self.race]['sidebars']['top']['normal']), bind=start_game)
		self.sprites['top_bar'].x = self.sprites['minimap'].width
		self.sprites['top_bar'].y = conf['resolution'].height() - self.sprites['top_bar'].height

		self.sprites['right_bar'] = generic_sprite(getTexture(conf['ui'][self.race]['sidebars']['right']['normal']), bind=start_game)
		self.sprites['right_bar'].x = self.sprites['minimap'].width + self.sprites['top_bar'].width
		self.sprites['right_bar'].y = conf['resolution'].height() - self.sprites['right_bar'].height

		self.sprites['bottom_bar'] = generic_sprite(getTexture(conf['ui'][self.race]['sidebars']['bottom']['normal']), bind=start_game)
		self.sprites['bottom_bar'].x = self.sprites['minimap'].width
		self.sprites['bottom_bar'].y = 0

		# grass = tile_set 189 & 190
示例#3
0
	def multiplayer(self, *args, **kwargs):
		print('Pressed multiplayer! :D Lets rock!')

		if not 'multiplayer_menu' in cosmic['pages']:
			cosmic['pages']['multiplayer_menu'] = generate_batch()

		cosmic['active_page'] = 'multiplayer_menu'

		self.sprites['MP_username'] = text_input(game_data.images[239].to_png(game_data.colorPalettes[217]), batch=cosmic['pages']['multiplayer_menu']['batch'], group=1)
		self.sprites['MP_username'].x = conf['resolution'].width()/2 - self.sprites['MP_username'].width/2
		self.sprites['MP_username'].y = conf['resolution'].height()/2 #+((self.sprites['MP_username'].height+10)*3)
		#self.sprites['MP_username'].text = 'Enter a username'
		cosmic['pages']['multiplayer_menu']['sprites']['MP_username'] = self.sprites['MP_username']

		self.sprites['find_games'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=find_servers, batch=cosmic['pages']['multiplayer_menu']['batch'], group=1)
		self.sprites['find_games'].position_offset(self.sprites['MP_username'], 0, 10)
		#self.sprites['find_games'].x = conf['resolution'].width()/2 - self.sprites['find_games'].width/2
		#self.sprites['find_games'].y = conf['resolution'].height()/2
		self.sprites['find_games'].text = 'Connect to multiplayer server'
		cosmic['pages']['multiplayer_menu']['sprites']['find_games'] = self.sprites['find_games']

		self.sprites['create_multiplayer'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=create_lobby, batch=cosmic['pages']['multiplayer_menu']['batch'], group=1)
		self.sprites['create_multiplayer'].position_offset(self.sprites['find_games'], 0, 10)
		#self.sprites['create_multiplayer'].x = self.sprites['create_multiplayer'].x
		#self.sprites['create_multiplayer'].y = self.sprites['create_multiplayer'].y + self.sprites['create_multiplayer'].height + 10
		self.sprites['create_multiplayer'].text = 'Create a lobby'
		cosmic['pages']['multiplayer_menu']['sprites']['create_multiplayer'] = self.sprites['create_multiplayer']

		self.sprites['back'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=self.main, batch=cosmic['pages']['multiplayer_menu']['batch'], group=1)
		self.sprites['back'].x = conf['resolution'].width()/2 - self.sprites['back'].width/2
		self.sprites['back'].y = self.sprites['replay_introduction'].y -50
		self.sprites['back'].text = 'Back'
		cosmic['pages']['multiplayer_menu']['sprites']['back'] = self.sprites['back']

		self.sprites['background'].batch = cosmic['pages']['multiplayer_menu']['batch']
示例#4
0
	def main(self, *args, **kwargs):
		cosmic['active_page'] = 'main_menu'

		self.sprites['background'].batch = cosmic['pages']['main_menu']['batch']

		self.sprites['start_game'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=start_game, batch=cosmic['pages']['main_menu']['batch'], group=1)
		self.sprites['start_game'].x = conf['resolution'].width()/2 - self.sprites['start_game'].width/2
		self.sprites['start_game'].y = conf['resolution'].height()/2 - self.sprites['start_game'].height/2 -10
		self.sprites['start_game'].text = 'Start Game'

		self.sprites['load_existing_game'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=start_game, batch=cosmic['pages']['main_menu']['batch'], group=1)
		self.sprites['load_existing_game'].x = conf['resolution'].width()/2 - self.sprites['load_existing_game'].width/2
		self.sprites['load_existing_game'].y = self.sprites['start_game'].y -50
		self.sprites['load_existing_game'].text = 'Load Game'

		self.sprites['multiplayer'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=self.multiplayer, batch=cosmic['pages']['main_menu']['batch'], group=1)
		self.sprites['multiplayer'].x = conf['resolution'].width()/2 - self.sprites['load_existing_game'].width/2
		self.sprites['multiplayer'].y = self.sprites['load_existing_game'].y -50
		self.sprites['multiplayer'].text = 'Multiplayer :D'

		self.sprites['replay_introduction'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=start_game, batch=cosmic['pages']['main_menu']['batch'], group=1)
		self.sprites['replay_introduction'].x = conf['resolution'].width()/2 - self.sprites['replay_introduction'].width/2
		self.sprites['replay_introduction'].y = self.sprites['multiplayer'].y -50
		self.sprites['replay_introduction'].text = 'Replay Introduction'

		self.sprites['quit'] = generic_sprite(game_data.images[239].to_png(game_data.colorPalettes[217]), bind=self.quit, batch=cosmic['pages']['main_menu']['batch'], group=1)
		self.sprites['quit'].x = conf['resolution'].width()/2 - self.sprites['quit'].width/2
		self.sprites['quit'].y = self.sprites['replay_introduction'].y -50
		self.sprites['quit'].text = 'Quit'
示例#5
0
	def __init__(self, batch=None):
		super(main_menu, self).__init__(width=10, height=10, alpha=0, batch=batch)
		self.layers = OrderedDict()
		#self.layers['background'] = pyglet.graphics.OrderedGroup(0)
		#self.layers['foreground'] = pyglet.graphics.OrderedGroup(0)
		self.sprites['background'] = generic_sprite(game_data.images[261].to_png(game_data.colorPalettes[260]), moveable=False, clickable=False, group=0)
		self.main()
示例#6
0
	def load_image(self, index):
		print('Loading Image:', int(index))
		self.flush_sprites()
		x = 0
		y = 0
		for palette_id in game_data.colorPalettes.keys():
			if not game_data.colorPalettes[palette_id].corrupted:
				self.add_sprite('main_menu', 'id:{}_pal:{}'.format(index, palette_id), generic_sprite(game_data.images[index].to_png(game_data.colorPalettes[palette_id]), moveable=True, x=x, y=y))
				x += (game_data.images[index].width * conf['resolution'].scale()) + 5
				if x+(game_data.images[index].width * conf['resolution'].scale()) > self.width:
					x = 0
					y += (game_data.images[int(index)].height*conf['resolution'].scale())+5