def __init__(self): self.camera.position = Vector(0., 0.) self.my_font = Font(os.path.join('demos', 'assets', 'fonts', 'DejaVuSans.ttf')) self.text_node = TextNode(font=self.my_font, content="Hello World", font_size=1.) self.root.add_child(self.text_node) self.text_buffer = [] self.input.register_callback(Event.keyboard_key, handle_quit)
def __init__(self): self.camera.position = Vector(0., 0.) self.my_font = Font( "kaacore/demos/assets/fonts/Roboto/Roboto-Regular.ttf") self.text_node = TextNode(font=self.my_font, content="Hello World", font_size=1.) self.root.add_child(self.text_node)
def __init__(self): self.camera.position = Vector(0., 0.) self.my_font = Font( "kaacore/demos/assets/fonts/Roboto/Roboto-Regular.ttf") self.text_node = TextNode(font=self.my_font, content="Hello World", font_size=1.) self.root.add_child(self.text_node) self.text_buffer = [] self.input.register_callback(Event.keyboard_key, handle_quit)
def __init__(self): self.font = Font( os.path.join('demos', 'assets', 'fonts', 'DejaVuSans.ttf')) self.controller_id_to_slot_index = { } # key = controller id, value = index, between 0 to 3 indicating controller "slot" self.slot_nodes = [] for i in range(0, 4): if i == 0: pos = Vector(10, 10) elif i == 1: pos = Vector(910, 10) elif i == 2: pos = Vector(10, 460) elif i == 3: pos = Vector(910, 460) controller_slot_info_node = ControllerSlotInfoNode(i, self.font, position=pos) self.slot_nodes.append(controller_slot_info_node) self.root.add_child(controller_slot_info_node)
def __init__(self, samples_paths): self.font = Font(FONT_PATH) self.samples = [] for idx, path in enumerate(samples_paths): print("Loading... {}".format(path)) name = os.path.basename(path) playback = SoundPlayback(Sound(path)) ui_node = self.root.add_child( TextNode( font_size=5., font=self.font, # simple multiline positioning position=Vector(10, 10 + idx * 8), origin_alignment=Alignment.top_left, ) ) self.samples.append( SampleEntry(name, playback, ui_node, idx) ) self.active_ui_entry_index = 0 self._update_ui_nodes()
def __init__(self, player_state, root_node): self.player_state = player_state self.ui_root = root_node.add_child(Node(position=Vector(0, 240), )) self.soap_meter = self.ui_root.add_child( Node( position=Vector(320, 20), origin_alignment=Alignment.left, sprite=SPRITE_SOAP_METER, z_index=50, )) self.soap_meter_label = self.ui_root.add_child( TextNode( # scale=Vector(1.1, 1), position=Vector(320, -15), origin_alignment=Alignment.top_left, font=Font('hope_in_soap/assets/Pixeled_0.ttf'), font_size=42., text="Soap-o-meter", z_index=50, )) self.score = self.ui_root.add_child( TextNode( # scale=Vector(1.1, 1), position=Vector(-470, -15), origin_alignment=Alignment.top_left, font=Font('hope_in_soap/assets/Pixeled_0.ttf'), font_size=36., text="Score: 123", z_index=50, )) self.liquid_soap_powerup_status = self.ui_root.add_child( CounterStatusUINode( position=Vector(450, -130), powerup_sprite=SPRITE_LIQUID_SOAP, max_count=3, )) self.antivirus_powerup_status = self.ui_root.add_child( CounterStatusUINode( position=Vector(530, -130), powerup_sprite=SPRITE_ANTIVIRUS, max_count=3, )) self.people_label = self.ui_root.add_child( TextNode( # scale=Vector(1.1, 1), position=Vector(-620, -15), origin_alignment=Alignment.top_left, font=Font('hope_in_soap/assets/Pixeled_0.ttf'), font_size=36., text="People:", z_index=50, )) self.people_status = self.ui_root.add_child( CounterStatusUINode( position=Vector(-620, 10), powerup_sprite=SPRITE_FRAMES_PEOPLE, max_count=500, break_count=40, minor_sep=Vector(7, 0), major_sep=Vector(0, 12), )) self.game_over_background = root_node.add_child( Node( shape=Polygon.from_box(Vector(1400, 1000)), color=Color(0, 0, 0, 0), visible=False, z_index=150, )) self.game_over_text = self.game_over_background.add_child( TextNode( font_size=56., font=Font('hope_in_soap/assets/Pixeled_0.ttf'), text="GAME OVER", color=Color(0, 0, 0, 0), z_index=151, ))
def __init__(self): # Load images: self.background_img = Sprite( os.path.join('assets', 'gfx', 'background.png')) self.title_screen_background_img = Sprite( os.path.join('assets', 'gfx', 'title-screen.png')) self.player_img = Sprite(os.path.join('assets', 'gfx', 'player.png')) self.machine_gun_img = Sprite( os.path.join('assets', 'gfx', 'machine-gun.png')) self.force_gun_img = Sprite( os.path.join('assets', 'gfx', 'force-gun.png')) self.grenade_launcher_img = Sprite( os.path.join('assets', 'gfx', 'grenade-launcher.png')) self.machine_gun_bullet_img = Sprite( os.path.join('assets', 'gfx', 'machine-gun-bullet.png')) self.force_gun_bullet_img = Sprite( os.path.join('assets', 'gfx', 'force-gun-bullet.png')) self.grenade_launcher_bullet_img = Sprite( os.path.join('assets', 'gfx', 'grenade-launcher-bullet.png')) self.enemy_stagger_img = Sprite( os.path.join('assets', 'gfx', 'enemy-stagger.png')) # few variants of bloodstains, put them in the same list so we can pick them randomly later self.bloodstain_imgs = [ Sprite(os.path.join('assets', 'gfx', f'bloodstain{i}.png')) for i in range(1, 5) ] # Load spritesheets self.enemy_spritesheet = Sprite( os.path.join('assets', 'gfx', 'enemy.png')) self.blood_splatter_spritesheet = Sprite( os.path.join('assets', 'gfx', 'blood-splatter.png')) self.explosion_spritesheet = Sprite( os.path.join('assets', 'gfx', 'explosion.png')) # enemy-death.png has a few death animations, so make this a list self.enemy_death_spritesheet = Sprite( os.path.join('assets', 'gfx', 'enemy-death.png')) # use the spritesheets to create framesets self.enemy_frames = split_spritesheet(self.enemy_spritesheet, frame_dimensions=Vector(33, 74)) self.blood_splatter_frames = split_spritesheet( self.blood_splatter_spritesheet, frame_dimensions=Vector(50, 50)) self.explosion_frames = split_spritesheet(self.explosion_spritesheet, frame_dimensions=Vector( 100, 100), frames_count=75) self.enemy_death_frames = [ split_spritesheet(self.enemy_death_spritesheet.crop( Vector(0, i * 74), Vector(103 * 9, 74)), frame_dimensions=Vector(103, 74)) for i in range(0, 5) ] # Load all sounds self.mg_shot_sound = Sound(os.path.join('assets', 'sfx', 'mg-shot.wav')) self.force_gun_shot_sound = Sound( os.path.join('assets', 'sfx', 'force-gun-shot.wav')) self.grenade_launcher_shot_sound = Sound( os.path.join('assets', 'sfx', 'grenade-launcher-shot.wav')) self.explosion_sound = Sound( os.path.join('assets', 'sfx', 'explosion.wav')) # Load all music tracks self.music_track_1 = Music( os.path.join('assets', 'music', 'track_1.wav')) # Load all fonts self.font_1 = Font( os.path.join('assets', 'fonts', 'paladise-script.ttf')) self.font_2 = Font(os.path.join('assets', 'fonts', 'DejaVuSans.ttf'))