def display_quit(self): self.remove_all() self.append( ui.Box(self, (10, 39), (80, 22), constants.button_box_color)) self.append( ui.Text(self, i18n.get_text(self.language, 1105), (10, 40), (80, 10), self.fonts, constants.text_color, 1)) self.quit_yes = ui.TextBox(self, i18n.get_text(self.language, 100), (10, 50), (40, 10), self.fonts, constants.text_color, 11, constants.stop_icon) self.quit_no = ui.TextBox(self, i18n.get_text(self.language, 101), (50, 50), (40, 10), self.fonts, constants.text_color, 11, constants.go_next_icon) self.append(self.quit_yes) self.append(self.quit_no) self.page_type = "DIALOG_BOX_QUIT" self.draw() return [self.screen.get_rect()]
def draw(self, win): x_offset = 0 j = 0 for x in range(len(self.numbers)): pygame.draw.rect(win, self.border_colour, (self.x + x_offset, self.y, self.sector_width, self.sector_height)) if self.active_number < self.numbers[j]: pygame.draw.rect(win, self.low_colour, (self.x + x_offset + self.border_width / 2, self.y + self.border_width / 2, self.sector_width - self.border_width, self.sector_height - self.border_width)) current_number = ui.TextBox(x=self.x + x_offset + self.sector_width / 3, y=self.y + self.sector_height / 4, font_size=128, font_colour=(200, 200, 200), text=str(self.numbers[j])) elif self.active_number > self.numbers[j]: pygame.draw.rect(win, self.high_colour, (self.x + x_offset + self.border_width / 2, self.y + self.border_width / 2, self.sector_width - self.border_width, self.sector_height - self.border_width)) current_number = ui.TextBox(x=self.x + x_offset + self.sector_width / 3, y=self.y + self.sector_height / 4, font_size=128, font_colour=(150, 150, 150), text=str(self.numbers[j])) else: pygame.draw.rect(win, self.passive_colour, (self.x + x_offset + self.border_width / 2, self.y + self.border_width / 2, self.sector_width - self.border_width, self.sector_height - self.border_width)) current_number = ui.TextBox(x=self.x + x_offset + self.sector_width / 3, y=self.y + self.sector_height / 4, font_size=128, font_colour=(150, 150, 150), text=str(self.numbers[j])) current_number.draw(win) x_offset += self.sector_width j += 1 panel_3 = ui.Panel(x=1255 + x_scaler, y=25, width=805 + x_scaler, height=670 + y_scaler) panel_3.draw(win) pygame.draw.polygon(win, self.passive_colour, [(500, self.y - 75), (600, self.y - 75), (550, self.y - 25)])
def __init__(self,items,player): self.player = player self.parent = player.map.parent self.screen = ui.Box(parent = globals.screen_root, pos = Point(0.06,0.1), tr = Point(0.94,0.9), colour = (0.8,0.8,0.8,0.6)) self.screen.title = ui.TextBox(self.screen, bl = Point(0,0.8), tr = Point(1,0.99), text = 'Inventory', textType = drawing.texture.TextTypes.SCREEN_RELATIVE, colour = (0,0,0,1), scale = 5) self.screen.current_name = ui.TextBox(self.screen, bl = Point(0,0), tr = Point(1,0.08), text = ' ', textType = drawing.texture.TextTypes.SCREEN_RELATIVE, colour = (1,0,0,1), scale = 4, alignment = drawing.texture.TextAlignments.CENTRE) self.screen.selected = ui.Box(parent = self.screen, pos = Point(0,0), tr = Point(0,0), colour = drawing.constants.colours.red, extra = 2) self.screen.slots = [] self.width = 5 self.height = 3 box_width = 0.1 interbox_width = (1.0-self.width*box_width)/(self.width+1) box_height = 0.2 interbox_height = (1.0-self.height*box_height)/(self.height+1) inter = Point(interbox_width,interbox_height) box_size = Point(box_width,box_height) self.selected_coords = [] for i in xrange(self.width * self.height): x = i%self.width ypos = i/self.width if ypos >= self.height: break y = self.height-1-ypos bl = Point((interbox_width*(x+1)) + (box_width*x), (interbox_height*(y+1)) + (box_height*y)) tr = bl + box_size box = ui.Box(parent = self.screen, pos = bl, tr = tr, colour = (0.4,0.4,0.4,1),extra = 1) self.selected_coords.append( (Point(bl.x,bl.y-0.2*box_height),Point(tr.x,bl.y-0.05*box_height)) ) self.screen.slots.append(box) self.items = [item for item in items][:len(self.screen.slots)] if len(items) < len(self.screen.slots): self.items += [None]*(len(self.screen.slots)-len(items)) self.SetSelected(0) self.screen.Disable() self.num_items = 0
def draw(self, win): x_col = 0 y_col = 0 j = 0 row_count = math.ceil(13 / self.max_columns) for row in range(row_count): for column in range(self.max_columns): if j > len(wheel.numbers) - 1: j = len(wheel.numbers) - 1 break pygame.draw.rect(win, self.border_colour, (self.x + x_col, self.y + y_col, self.sector_width, self.sector_height)) if wheel.active_number < wheel.numbers[j]: pygame.draw.rect(win, wheel.low_colour, (self.x + x_col + self.border_width / 2, self.y + y_col + self.border_width / 2, self.sector_width - self.border_width, self.sector_height - self.border_width)) current_number = ui.TextBox( x=self.x + x_col + self.sector_width / 3, y=self.y + y_col + self.sector_height / 4, font_size=30, font_colour=(200, 200, 200), text=str(wheel.numbers[j])) if wheel.active_number > wheel.numbers[j]: pygame.draw.rect(win, wheel.high_colour, (self.x + x_col + self.border_width / 2, self.y + y_col + self.border_width / 2, self.sector_width - self.border_width, self.sector_height - self.border_width)) current_number = ui.TextBox( x=self.x + x_col + self.sector_width / 3, y=self.y + y_col + self.sector_height / 4, font_size=30, font_colour=(150, 150, 150), text=str(wheel.numbers[j])) current_number.draw(win) j += 1 y_col += self.sector_height x_col += self.sector_width y_col = 0
def __init__(self): self.dish_door = None self.atlas = globals.atlas = drawing.texture.TextureAtlas( 'tiles_atlas_0.png', 'tiles_atlas.txt') self.map = GameMap('level1.txt', self) self.map.world_size = self.map.size * globals.tile_dimensions self.viewpos = Viewpos(Point(915, 0)) self.player_direction = Point(0, 0) self.game_over = False self.computer = None self.info_box = ui.Box(parent=globals.screen_root, pos=Point(0, 0), tr=Point(1, 0.05), colour=(0, 0, 0, 0.9)) self.info_box.text = ui.TextBox( self.info_box, bl=Point(0, 0), tr=Point(1, 0.7), text='Space to interact, I for inventory, DEL to toggle music', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(1, 1, 0, 1), scale=3, alignment=drawing.texture.TextAlignments.CENTRE) self.info_box.Disable() #pygame.mixer.music.load('music.ogg') self.music_playing = False super(GameView, self).__init__(Point(0, 0), globals.screen) #skip titles for development of the main game self.mode = modes.Titles(self) #self.mode = modes.LevelOne(self) super(GameView, self).__init__(Point(0, 0), Point(*self.map.world_size))
def __init__(self, parent): self.parent = parent self.blurb = self.blurb self.blurb_text = None self.handlers = { TitleStages.TEXT: self.TextDraw, TitleStages.SCROLL: self.Wait, TitleStages.WAIT: self.Wait } self.backdrop = ui.Box(parent=globals.screen_root, pos=Point(0, 0), tr=Point(1, 1), colour=(0, 0, 0, 0.6)) bl = self.parent.GetRelative(Point(0, 0)) tr = bl + self.parent.GetRelative(globals.screen) self.blurb_text = ui.TextBox( parent=globals.screen_root, bl=bl, tr=tr, text=self.blurb, textType=drawing.texture.TextTypes.SCREEN_RELATIVE, scale=3) self.start = None self.blurb_text.EnableChars(0) self.stage = TitleStages.TEXT self.played_sound = False self.skipped_text = False self.letter_duration = 20 self.continued = False
def __init__(self, parent): self.parent = parent self.blurb = self.blurb self.blurb_text = None pygame.mixer.music.load('end_music.ogg') pygame.mixer.music.play(-1) pygame.mixer.music.set_volume(0.6) self.handlers = { TitleStages.TEXT: self.TextDraw, TitleStages.SCROLL: self.Wait, TitleStages.WAIT: self.Wait } self.backdrop = ui.Box(parent=globals.screen_root, pos=Point(0, 0), tr=Point(1, 1), colour=(0, 0, 0, 0.6)) bl = Point(0.3, 0.5) tr = Point(0.7, 0.7) self.blurb_text = ui.TextBox( parent=globals.screen_root, bl=bl, tr=tr, text=self.blurb, textType=drawing.texture.TextTypes.SCREEN_RELATIVE, scale=3) self.start = None self.blurb_text.EnableChars(0) self.stage = TitleStages.TEXT self.played_sound = False self.skipped_text = False self.letter_duration = 20 self.continued = False
def create_graphical_goal(self, page, index_goal, map_image): if (cmp(self.game.type_to_associate, "image_on_map") <> 0): goal = self.game.goals[index_goal] if (goal.text != None): goal = ui.TextBox(page, goal.text, goal.pos, goal.size, page.fonts, constants.text_color, 1) else: goal = ui.Image(page, goal.pos, goal.size, goal.image_file) if (self.selected_item_to_associate in self.image_sounds): goal.associated_sounds = self.image_sounds[ self.selected_item_to_associate] else: goal = self.associated_goal goal.place_on_map(map_image) # TODO : implement textbox # goal = ui.TextBox(page, goal.text, goal.pos, goal.size, page.fonts, constants.text_color, 1, goal.image_file, 0) goal = ui.Image(page, goal.pos, goal.size, goal.image_file) goal.set_associated_object(self) return goal
def __init__(self): self.start_time_hours = 0 self.tutorial = False self.atlas = globals.atlas = drawing.texture.TextureAtlas( 'tiles_atlas_0.png', 'tiles_atlas.txt') self.game_over = False self.sky = LoopingQuad(Point(0, 0), 0, 'sky.png', 0.1) self.hills = LoopingQuad(Point(0, -50), 0.05, 'hills.png', 0.6) self.tracks = LoopingQuad(Point(0, -84), 0.1, 'tracks.png', 1.0) self.start_time = globals.time self.incline = 0 self.train = Train(self) self.last = None self.box = ui.Box(parent=globals.screen_root, pos=Point(0.005, 0.74), tr=Point(0.995, 0.99), colour=(1, 1, 1, 0.5), z=5) self.text = ui.TextBox( parent=globals.screen_root, bl=Point(-0.045, 0.71), tr=Point(1.2, 0.81), text= 'Pressure Speed Regulator Brake Coal Health Reverser Time Distance', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=drawing.constants.colours.black, scale=2) self.tutorial_text = ui.TextBox( parent=globals.screen_root, bl=Point(-0.02, 0), tr=Point(1, 0.1), text=' ', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=drawing.constants.colours.white, scale=2, alignment=drawing.texture.TextAlignments.LEFT) self.tutorial_text.Disable() self.text.Disable() #pygame.mixer.music.load('music.ogg') #self.music_playing = False super(GameView, self).__init__(Point(0, 0), globals.screen) #skip titles for development of the main game self.mode = modes.MainMenu(self) self.StartMusic() self.Reset()
def __init__(self): self.atlas = globals.atlas = drawing.texture.TextureAtlas( 'tiles_atlas_0.png', 'tiles_atlas.txt') self.sentry_lights = [] self.enemies = [] globals.ui_atlas = drawing.texture.TextureAtlas('ui_atlas_0.png', 'ui_atlas.txt', extra_names=False) self.enemy_positions = [] self.map = GameMap('level1.txt', self) self.map.world_size = self.map.size * globals.tile_dimensions self.viewpos = Viewpos(Point(100, 400)) self.player_direction = Point(0, 0) self.game_over = False self.mouse_world = Point(0, 0) self.mouse_pos = Point(0, 0) #pygame.mixer.music.load('music.ogg') #self.music_playing = False super(GameView, self).__init__(Point(0, 0), globals.screen) #skip titles for development of the main game self.mode = modes.Titles(self) self.light = drawing.Quad(globals.light_quads) self.light.SetVertices(Point(0, 0), globals.screen_abs - Point(0, 0), 0) self.nightlight = drawing.Quad(globals.nightlight_quads) self.nightlight.SetVertices(Point(0, 0), globals.screen_abs - Point(0, 0), 0.01) self.timeofday = TimeOfDay(0.1) #self.mode = modes.LevelOne(self) self.StartMusic() self.fixed_light = actors.FixedLight(Point(11, 38), Point(26, 9)) self.interact_box = ui.Box(parent=globals.screen_root, pos=Point(0.3, 0.0), tr=Point(0.5, 0.08), colour=(0.5, 0.5, 0.5, 0.7)) self.interact_box.title = ui.TextBox( self.interact_box, bl=Point(0, 0), tr=Point(1, 1), text='Opening...', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(0, 0, 0, 1), scale=9, alignment=drawing.texture.TextAlignments.CENTRE) self.interact_box.progress = ui.PowerBar( self.interact_box, pos=Point(0.1, 0.3), tr=Point(0.9, 0.6), level=0.6, bar_colours=(drawing.constants.colours.red, drawing.constants.colours.yellow, drawing.constants.colours.green), border_colour=drawing.constants.colours.white) self.interact_box.Disable() for pos in self.enemy_positions: self.enemies.append(actors.Enemy(self.map, pos))
def __init__(self, parent): self.parent = parent self.pos = Point(20, 43) self.size = globals.atlas.SubimageSprite(self.name).size self.quad = drawing.Quad(globals.quad_buffer, tc=globals.atlas.TextureSpriteCoords( self.name)) self.flag_quad = drawing.Quad( globals.quad_buffer, tc=globals.atlas.TextureSpriteCoords('flag.png')) self.flag_size = globals.atlas.SubimageSprite('flag.png').size self.bars = [ drawing.Quad( globals.quad_buffer, tc=globals.atlas.TextureSpriteCoords('wheel_bar.png')), drawing.Quad(globals.quad_buffer, tc=globals.atlas.TextureSpriteCoords('mid_bar.png')), drawing.Quad( globals.quad_buffer, tc=globals.atlas.TextureSpriteCoords('piston_bar.png')) ] self.pressure_gauge = PressureGauge(self) self.speedo = Speedo(self) self.regulator = Regulator(self) self.reverser = Reverser(self) self.brake = Brake(self) self.coal_dial = CoalDial(self) self.clock = Clock(self) self.clouds = [] self.distance_text = ui.TextBox(globals.screen_root, Point(0.9, 0.83), Point(1.0, 0.93), '????.??', scale=2, colour=(0, 0, 0, 1.0)) self.Reset() self.health_dial = HealthDial(self, self.health) self.wheels = [ Wheel(self, 20 + x, y, r) for (x, y, r) in ((99, 43, 0), (141, 43, math.pi)) ] self.add_coal_text = ui.TextBoxButton(globals.screen_root, 'Add', Point(0.475, 0.770), Point(0.575, 0.83), size=2, callback=self.add_coal_button, colour=(0.0, 0.0, 0.0, 1.0)) self.Disable() self.spout_pos = self.pos + Point(53, 67) self.vent_pos = self.pos + Point(133, 49)
def __init__(self, main): self.main = main res.play_music('underfoot.ogg') self.ui = pygame.sprite.LayeredUpdates() self.selection = ' ' self.event = None self.turn_count = 0 self.queue = [] self.skillbuttons = [] self.tooltip = None self.field = Field(self, 0, 41, 10, 5, stage.Sewer) self.turn_indicator = TurnIndicator(self) self.player_panel = PlayerPanel(self) self.enemy_panel = EnemyPanel(self) self.player_effects = [] self.enemy_effects = [] self.select(self.main.data[0]) self.message = ui.TextBox( 0, self.turn_indicator.rect.height + self.field.rect.height, 640, 480 - self.turn_indicator.rect.height - self.field.rect.height, [' ']) self.ui.add(self.player_panel, self.enemy_panel, self.turn_indicator, self.field, PressAny(self)) self.main.data[0].enter_field(0, 0, self.field) monster1 = character.Character('Lugaru', avatar=avatar.Lugaru(), basestat=character.LugaruStat()) monster1.learn_skill(skill.Swing) monster1.learn_skill(skill.Thrust) monster2 = character.Character('Clay Golem', avatar=avatar.ClayGolem(), basestat=character.ClayGolemStat()) monster2.learn_skill(skill.Swing) monster2.learn_skill(skill.Thrust) monster2.learn_skill(skill.Anger) monster1.enter_field(4, 1, self.field) monster2.enter_field(4, 2, self.field) self.select(monster1)
def __init__(self, parent): self.parent = parent self.start = pygame.time.get_ticks() self.stage = TitleStages.STARTED self.handlers = { TitleStages.STARTED: self.Startup, TitleStages.COMPLETE: self.Complete } bl = self.parent.GetRelative(Point(0, 0)) tr = bl + self.parent.GetRelative(globals.screen) self.blurb_text = ui.TextBox( parent=self.parent, bl=bl, tr=tr, text=self.blurb, textType=drawing.texture.TextTypes.GRID_RELATIVE, colour=(1, 1, 1, 1), scale=4) self.backdrop = ui.Box(parent=globals.screen_root, pos=Point(0, 0), tr=Point(1, 1), colour=(0, 0, 0, 0)) self.backdrop.Enable()
def __init__(self, pos, combination, parent): super(Locker, self).__init__(pos) self.combination = [c for c in combination[:4]] self.parent = parent self.screen = ui.Box(parent=globals.screen_root, pos=Point(0.415, 0.465), tr=Point(0.585, 0.54), colour=drawing.constants.colours.white) self.current = ['0', '0', '0', '0'] self.screen.combo = ui.TextBox( parent=self.screen, bl=Point(0, 0), tr=Point(1, 1), text=''.join(self.current), textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(0, 0, 0, 1), scale=8) self.selected = 0 self.screen.selected = ui.Box(parent=self.screen, pos=Point(0, -0.05), tr=Point(0.25, 0.15), colour=drawing.constants.colours.red, extra=2) self.screen.Disable()
def __init__(self, map, pos): self.mouse_pos = Point(0, 0) self.has_key = False super(Player, self).__init__(map, pos) self.light = ActorLight(self) self.tilium = False self.flare = None self.comms = None self.last_damage_sound = 0 self.torch = Torch( self, Point(-(self.width / globals.tile_dimensions.x) * 0.6, 0)) self.info_box = ui.Box(parent=globals.screen_root, pos=Point(0, 0), tr=Point(1, 0.08), colour=(0, 0, 0, 0.7)) self.info_box.health_text = ui.TextBox( self.info_box, bl=Point(0.8, 0), tr=Point(1, 0.7), text='\x81:%d' % self.initial_health, textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(1, 0, 0, 1), scale=10, alignment=drawing.texture.TextAlignments.CENTRE) self.info_box.torch_data = ui.UIElement(self.info_box, pos=Point(0.5, 0), tr=Point(0.85, 1)) self.info_box.torch_data.text = ui.TextBox( self.info_box.torch_data, bl=Point(0, 0), tr=Point(0.57, 0.7), text='Torch power:', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(1, 0, 0, 1), scale=8, alignment=drawing.texture.TextAlignments.CENTRE) self.info_box.torch_data.power = ui.PowerBar( self.info_box.torch_data, pos=Point(0.5, 0.36), tr=Point(1, 0.66), level=0.6, bar_colours=(drawing.constants.colours.red, drawing.constants.colours.yellow, drawing.constants.colours.green), border_colour=drawing.constants.colours.white) self.info_box.torch_data.Disable() self.inv_quads = [ drawing.Quad(globals.screen_texture_buffer, tc=globals.ui_atlas.TextureUiCoords('empty.png')) for i in xrange(4) ] self.sel_quads = [ drawing.Quad(globals.screen_texture_buffer, tc=globals.ui_atlas.TextureUiCoords('selected.png')) for i in xrange(4) ] box_size = 48 sep_x = int((self.info_box.absolute.size.x * 0.2 - box_size * 3) / 4) sep_y = int((self.info_box.absolute.size.y - box_size) / 2) for i in xrange(4): bl = self.info_box.absolute.bottom_left + Point( self.info_box.absolute.size.x * 0.03, 0) + Point( ((i + 1) * sep_x) + (i * box_size), sep_y) tr = bl + Point(box_size, box_size) self.inv_quads[i].SetVertices(bl, tr, 9000) self.sel_quads[i].SetVertices(bl, tr, 9001) self.inv_quads[i].Enable() self.sel_quads[i].Disable() self.inventory = [None, None, None, None] self.num_items = 0 self.current_item = 0 self.attacking = False self.AddItem(Hand(self)) #self.AddItem(CommsItem(self)) self.Select(self.num_items - 1) self.weapon = self.inventory[self.current_item] self.interacting = None
def create_draggable_item(self, page): # items are organized left to right # they go down after the right limit is reached ((draggable_area_pos, draggable_area_size), amount_x, amount_y, spacing_x, spacing_y ) = self.game.draggable_items_areas[page.index_draggable_area] step_x = draggable_area_size[0] / amount_x step_y = draggable_area_size[1] / amount_y x_pos = page.index_draggable_item % amount_x y_pos = page.index_draggable_item // amount_x offset_x = (step_x * x_pos) + spacing_x offset_y = (step_y * y_pos) + spacing_y page.index_draggable_item = page.index_draggable_item + 1 if (page.index_draggable_item >= amount_x * amount_y): page.index_draggable_item = 0 page.index_draggable_area = page.index_draggable_area + 1 if (cmp(self.game.type_to_drag, "text") == 0): # TODO implement spacing here textbox = ui.TextBox( page, self.selected_item_to_drag, (draggable_area_pos[0] + offset_x, draggable_area_pos[1] + offset_y), (draggable_area_size[0] // amount_x, self.game.text_height), page.fonts, constants.text_color, 11) textbox.set_associated_object(self) if (self.selected_item_to_drag in self.text_sounds): textbox.associated_sounds = self.text_sounds[ self.selected_item_to_drag] return textbox elif (cmp(self.game.type_to_drag, "image") == 0): image_file = self.selected_item_to_drag (image_pos, image_size) = ((draggable_area_pos[0] + offset_x, draggable_area_pos[1] + offset_y), ((draggable_area_size[0] // amount_x) - (2 * spacing_x), (draggable_area_size[1] // amount_y) - (2 * spacing_y))) image = ui.Image(page, image_pos, image_size, image_file) image.set_associated_object(self) if (image_file in self.image_sounds): image.associated_sounds = self.image_sounds[image_file] if (image_file in self.image_text_legends): # MAYBETODO : allow various text legends ? image.set_associated_text( self.image_text_legends[image_file][0]) page.listen_to_mouse_over(image) return image else: error("Incorrect value for type_to_drag" + self.game.type_to_drag) error("Correct values are: text, image") return None
"Highest ELO: " ] tags_data = [ user_data["name"], user_data["elo"], user_data["games_played"], user_data["wins"], user_data["avg_rank"], user_data["high_score"], user_data["highest_elo"] ] while run: y_offset = 0 stats = [] bg = ui.Background(colour=(255, 255, 255)) menu_label = ui.TextBox(x=500, y=50, font_size=60, text="Reckless Rina's Casino") player_stats_label = ui.TextBox(x=50, y=50, font_size=60, text="Player Stats") panel_1 = ui.Panel(x=25, y=25, width=400, height=670 + y_scaler) panel_2 = ui.Panel(x=450, y=25, width=805 + x_scaler, height=670 + y_scaler) play_button = ui.Button(x=1100 + x_scaler, y=wheel.y - 75, width=500, height=150,
def __init__(self, parent): self.parent = parent self.items = [] self.played_sounds = [False] * 10 self.power_box = ui.PowerBar( globals.screen_root, pos=Point(0.45, 0.05), tr=Point(0.55, 0.1), level=0.6, bar_colours=(drawing.constants.colours.green, drawing.constants.colours.yellow, drawing.constants.colours.red), border_colour=drawing.constants.colours.white) self.fe_level = ui.PowerBar( globals.screen_root, pos=Point(0.8, 0.05), tr=Point(0.9, 0.1), level=1.0, bar_colours=(drawing.constants.colours.red, drawing.constants.colours.yellow, drawing.constants.colours.green), border_colour=drawing.constants.colours.white) self.fe_level.title = ui.TextBox(parent=self.fe_level, bl=Point(-0.03, 1.0), tr=Point(1.1, 1.5), text='Foam Level', scale=3) self.power_box.Disable() self.fe_level.Disable() self.extra_help_box = ui.Box(globals.screen_root, pos=Point(0.35, 0.0), tr=Point(0.65, 0.04), colour=drawing.constants.colours.black) self.extra_help_box.text = ui.TextBox(parent=self.extra_help_box, bl=Point(0, 0), tr=Point(1, 1), text='Press SPACE to reset', scale=4) self.help_box = ui.Box(globals.screen_root, pos=Point(0.6, 0.6), tr=Point(1, 1), colour=drawing.constants.colours.black) self.help_box.title = ui.TextBox(parent=self.help_box, bl=Point(0.22, 0.8), tr=Point(1, 1), text='Controls', scale=4) p = 0.7 self.help_box.help = [] height = 0.08 for i, (key, action) in enumerate( (('left click', 'grab/push/spray'), ('left hold(while grabbed)', 'push'), ('right click', 'cancel/detach'), ('right hold(with item)', 'throw'), ('h', 'toggle help'), ('middle drag', 'move screen'), ('middle scroll', 'zoom'), ('space', 'reset'), ('tab', 'switch players'), ('DEL', 'toggle music'))): self.help_box.help.append( ui.TextBox(parent=self.help_box, bl=Point(-0.2, p), tr=Point(1.2, p + height), text=('%30s %s' % (key, action)), scale=3)) p -= height self.help_box.Enable() #for name,pos in ((self.shuttle_name,globals.screen*2), #(self.debris_name,globals.screen*Point(0.3,0.3)), #(self.debris_name,globals.screen*Point(0.3,0.6)), # (self.debris_name,globals.screen*Point(0.6,0.3))): # obj = parent.atlas.SubimageSprite(name) # self.items.append(actors.DynamicBox(self.parent.physics, # bl = pos, # tr = pos + obj.size, # tc = parent.atlas.TextureSpriteCoords(name))) self.ResetSceneOne()
def __init__(self, parent): self.parent = parent #bl = self.parent.GetRelative(self.parent.viewpos.pos) #self.parent.viewpos.Follow(globals.time,self.parent.map.player) self.backdrop = drawing.Quad( globals.screen_texture_buffer, tc=globals.atlas.TextureSpriteCoords('parchment.png')) self.backdrop_size = globals.atlas.SubimageSprite('parchment.png').size backdrop_bl = Point(40, 0) backdrop_tr = backdrop_bl + self.backdrop_size self.backdrop.SetVertices(backdrop_bl, backdrop_tr, 10) self.keydownmap = 0 self.playing = False self.current_level = 0 self.pause_time = 0 self.level_inclines = [] for i, level_heights in enumerate(self.level_heights): inclines = [0] for j in xrange(len(level_heights) - 1): current = level_heights[j] next = level_heights[j + 1] diff = next - current incline = float(diff) / chunk_width r, a = cmath.polar(1 + incline * 1j) inclines.append(-a) self.level_inclines.append(inclines) self.frame = ui.UIElement(globals.screen_root, globals.screen_root.GetRelative(backdrop_bl), globals.screen_root.GetRelative(backdrop_tr)) self.skull = drawing.Quad( globals.screen_texture_buffer, tc=globals.atlas.TextureSpriteCoords('skull.png')) self.skull.SetVertices(Point(128, 58), Point(128 + 64, 58 + 64), 10.1) self.skull.Disable() #tr = bl + self.parent.GetRelative(globals.screen) self.blurb_text = ui.TextBox( parent=self.frame, bl=Point(0.0, 0.72), tr=Point(1, 1), text=self.blurb, textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(0, 0, 0, 1), scale=3, alignment=drawing.texture.TextAlignments.CENTRE, ) self.underline = ui.TextBox( parent=self.frame, bl=Point(0.0, 0.67), tr=Point(1, 0.95), text='**********', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(0, 0, 0, 1), scale=3, alignment=drawing.texture.TextAlignments.CENTRE, ) self.content_boxes = [ ui.TextBox(parent=self.frame, bl=Point(0.2, 0.65 - i * 0.05), tr=Point(0.9, 0.72 - i * 0.05), text=' ', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(0, 0, 0, 1), scale=2, alignment=drawing.texture.TextAlignments.LEFT) for i in xrange(7) ] self.content_boxes_right = [ ui.TextBox(parent=self.frame, bl=Point(0.6, 0.65 - i * 0.05), tr=Point(0.9, 0.72 - i * 0.05), text=' ', textType=drawing.texture.TextTypes.SCREEN_RELATIVE, colour=(0, 0, 0, 1), scale=2, alignment=drawing.texture.TextAlignments.LEFT) for i in xrange(7) ] for box in itertools.chain(self.content_boxes, self.content_boxes_right): box.Disable() self.level_ok_button = ui.TextBoxButton(self.frame, 'OK', Point(0.4, 0.15), Point(0.5, 0.22), size=2, callback=self.click_ok, colour=(0.0, 0.0, 0.0, 1.0)) self.level_back_button = ui.TextBoxButton(self.frame, 'Back', Point(0.5, 0.15), Point(0.6, 0.22), size=2, callback=self.click_back, colour=(0.0, 0.0, 0.0, 1.0)) self.quit_button = ui.TextBoxButton(self.frame, 'QUIT', Point(0.45, 0.1), Point(0.55, 0.17), size=2, callback=self.click_quit, colour=(0.0, 0.0, 0.0, 1.0)) self.back_to_game = ui.TextBoxButton(self.frame, 'Cancel', Point(0.6, 0.1), Point(0.7, 0.17), size=2, callback=self.click_cancel, colour=(0.0, 0.0, 0.0, 1.0)) self.level_callbacks = [ self.click_tutorial, self.click_level_one, self.click_level_two, self.click_level_three, self.click_level_four ] self.level_buttons = [ ui.TextBoxButton(self.frame, self.level_names[i], Point(0.4, 0.6 - 0.075 * i), Point(0.6, 0.66 - 0.075 * i), size=2, callback=self.level_callbacks[i], colour=(0.0, 0.0, 0.0, 1.0)) for i in xrange(5) ] self.show_main_menu()
def update(self): ui.Page.update(self) # finish the background self.omnitux_logo_image = ui.Image(self, (35, 25), (30, 30), constants.omnitux_logo) self.append_back(self.omnitux_logo_image) self.append_back( ui.Image(self, constant_topimage_pos, constant_topimage_size, constant_topimage_file, 255, 100, "FILL")) self.append_back( ui.Image(self, constant_bottomimage_pos, constant_bottomimage_size, constant_bottomimage_file, 255, 100, "FILL")) self.draw_back() self.go_back_icon = ui.Image(self, constants.go_left_icon_pos, constants.go_left_icon_size, constants.go_left_icon) self.append(self.go_back_icon) # screen resolution self.append( ui.Text(self, i18n.get_text(self.language, 200), constant_resolution_text_pos, constant_resolution_text_size, self.fonts, constant_hud_color, 2)) self.resolution_minus = ui.TextBox(self, "-", constant_resolution_minus_pos, constant_resolution_minus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_minus) (self.globalvars.screen_width, self.globalvars.screen_height) = (self.screen.get_size()) self.resolution_value = ui.TextBox( self, str(self.globalvars.screen_width) + "x" + str(self.globalvars.screen_height), constant_resolution_value_pos, constant_resolution_value_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_value) self.resolution_plus = ui.TextBox(self, "+", constant_resolution_plus_pos, constant_resolution_plus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.resolution_plus) self.available_resolutions = pygame.display.list_modes() self.current_resolution_index = self.available_resolutions.index( (self.globalvars.screen_width, self.globalvars.screen_height)) # music volume self.append( ui.Text(self, i18n.get_text(self.language, 201), constant_music_text_pos, constant_music_text_size, self.fonts, constant_hud_color, 2)) self.music_minus = ui.TextBox(self, "-", constant_music_minus_pos, constant_music_minus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_minus) self.music_value = ui.TextBox( self, str(int(self.globalvars.music_volume * 100)) + "%", constant_music_value_pos, constant_music_value_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_value) self.music_plus = ui.TextBox(self, "+", constant_music_plus_pos, constant_music_plus_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.music_plus) # igloo yes/no self.append( ui.Text(self, i18n.get_text(self.language, 1020), constant_igloo_text_pos, constant_igloo_text_size, self.fonts, constant_hud_color, 2)) self.display_igloo = ui.TextBox( self, i18n.bool_to_text(self.language, self.globalvars.display_igloo), constant_display_igloo_pos, constant_display_igloo_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) self.append(self.display_igloo) # "no stress" vs "arcade" => commented until the feature will be developped #### self.append(ui.Text(self, i18n.get_text(self.language, 220), constant_arcade_mode_text_pos, constant_arcade_mode_text_size, self.fonts, constant_hud_color, 2)) self.arcade_mode = ui.TextBox( self, i18n.bool_to_text(self.language, self.globalvars.arcade_mode), constant_arcade_mode_pos, constant_arcade_mode_size, self.fonts, constant_negative_hud_color, 1, None, 255, constant_hud_color) #### self.append(self.arcade_mode) self.draw()