Beispiel #1
0
def draw_monsters():
    global my_map, monster_view, map_view, screen
    to_kill = []
    for monster in my_map.monsters:
        if map_view[0] - (2 * el_size[0]) <= monster.x * el_size[
                0] <= map_view[0] + width and map_view[1] - (2 * el_size[
                    1]) <= monster.y * el_size[1] <= map_view[1] + height:
            pos = (monster.x * el_size[0] - map_view[0],
                   monster.y * el_size[1] - map_view[1])
            screen.blit(
                sprites[monster.type][int(monster_view) %
                                      len(sprites[monster.type])], pos)
            if monster.type == 'Monster':
                draw_text(screen, pos[0] + el_size[0] - 15, pos[1],
                          str(monster.life))
            if monster.type == 'SmallMonster' or monster.type == 'ShootingMonster':
                draw_text(screen, pos[0] - el_size[0] / 2 - 7, pos[1],
                          str(monster.life))
        if monster.to_be_removed:
            to_kill.append(monster)
    for k in to_kill:
        my_map.monsters.remove(k)
        my_map.collidable_objects.remove(k)
        if k.type == 'Bullet' or k.type == 'SmallMonster' or k.type == 'Monster':
            my_map.tickable_objects.remove(k)
Beispiel #2
0
	def draw(self, screen):
		#self.camera.draw_bg(screen, resources.leafy)

		for vine in self.vines:
			vine.draw(screen)
		for ground in self.grounds:
			ground.draw(screen)
		for obj in self.objects:
			obj.draw(screen)

		self.player.draw(screen)

		self.player.gui(screen)

		for i, message in enumerate(self.messages):
			gui.draw_text(screen, message[0], (20, screen.get_height()-30-30*i), "red")

		if game.get_key_pressed(pygame.K_F1):
			self.show_info = not self.show_info
		if self.show_info:
			gui.draw_text(screen, str(1/self.delta))
Beispiel #3
0
def game_draw():
    global knight
    global screen, background, width, height, monster_view, tree_view, map_view, my_map
    global go_to_play_mode, go_to_menu_mode, is_ticking_freezed
    if not is_ticking_freezed:
        for o in my_map.tickable_objects:
            o.tick(knight, move, map_view, my_map)
    background = create_background(screen, width, height)
    screen.blit(background, (0, 0))
    screen.blit(sprites[knight.type][0], (knight.x, knight.y))
    draw_monsters()
    draw_trees()
    my_map.draw_question_marks(screen, map_view)

    draw_text(screen, 2, 0, 'HP: ' + str(knight.life) + '/100')
    draw_text(screen, 2, 20, 'Ammo: ' + str(knight.ammo))
    if is_ticking_freezed:
        draw_text(screen, 2, 40, 'Monsters are freezed')
    if knight.life < 1:
        print('The player died!')
        go_to_menu()

    monster_view += 0.125
    tree_view += 0.25
    if monster_view >= 2.0:
        monster_view = 0
    if tree_view >= 8.0:
        tree_view = 0

    if go_to_play_mode == True:
        go_to_play_mode = False
        # wyświetlam animację znikania menu
        for y in range(int(height / 20)):
            screen.blit(background, (0, 0))
            screen.blit(sprites[knight.type][0], (knight.x, knight.y))
            draw_monsters()
            draw_trees()
            my_map.draw_question_marks(screen, map_view)

            screen.blit(image_menu, (0, y * (-20.0)))
            pygame.display.flip()
            pygame.time.wait(1)
    elif go_to_menu_mode == False:
        pygame.display.flip()
Beispiel #4
0
	def gui(self, screen):
		if self.health <= 0:
			gui.draw_big_text(screen, "YOU DIED! :(", (198, 298), "white")
			gui.draw_big_text(screen, "YOU DIED! :(", (200, 300), "black")
			return gui.draw_text(screen, "press escape", (300, 400))

		gui.draw_box(screen, (20, 20, 20+max(min(self.hunger, 100), 0)*2, 50), "blue")
		gui.draw_box(screen, (screen.get_width()-(20+max(min(self.health, 100), 0)*2), 20, max(min(self.health, 100), 0)*2, 50), "green")



		if self.upgrade_attack > 0:
			if gui.Button(screen, "upgrade_attack", "a", (300, 20, 50, 50), draw=False):
				if self.menu:
					self.menu = None
				else:
					self.menu = MENU_ATTACK
			gui.draw_image(screen, resources.attack_icon, (300, 20))
		if self.upgrade_utility > 0:
			if gui.Button(screen, "upgrade_utility", "u", (360, 20, 50, 50), draw=False):
				if self.menu:
					self.menu = None
				else:
					self.menu = MENU_UTILITY
			gui.draw_image(screen, resources.utility_icon, (360, 20))
		if self.upgrade_movement > 0:
			if gui.Button(screen, "upgrade_movement", "m", (420, 20, 50, 50), draw=False):
				if self.menu:
					self.menu = None
				else:
					self.menu = MENU_MOVEMENT
			gui.draw_image(screen, resources.movement_icon, (420, 20))


		if self.menu == MENU_ATTACK:
			selection = gui.Menu(screen, "upgrade_attack", "evolve", ["ranged", "melee"], (300, 80, 170, 180))
			if selection == 1:
				if self.ranged_damage < 50:
					self.ranged_damage += 10
					self.game.send_message("more ranged damage!")
				else:
					if self.ranged_attack_speed > self.minattackspeed:
						self.ranged_attack_speed -= .1
						self.game.send_message("more ranged attack speed!")
				self.upgrade_attack -= 1
				self.grow(self.growth)
				self.menu = None
			if selection == 2:
				if self.melee_damage < 60:
					self.melee_damage += 10
					self.game.send_message("more melee damage!")
				else:
					if self.melee_damage_speed > self.minattackspeed-.1:
						self.melee_damage_speed -= .1
						self.game.send_message("more melee attack speed!")
				self.upgrade_attack -= 1
				self.grow(self.growth)
				self.menu = None

		if self.menu == MENU_UTILITY:
			selection = gui.Menu(screen, "upgrade_utility", "evolve", ["health"], (300, 80, 170, 120))
			if selection == 1:
				self.health += 10
				self.maxhealth += 10
				self.game.send_message("more health!")
				self.upgrade_utility -= 1
				self.grow(self.growth)
				self.menu = None

		if self.menu == MENU_MOVEMENT:
			selection = gui.Menu(screen, "upgrade_movement", "evolve", ["jumping", "running"], (300, 80, 170, 180))
			if selection == 1:
				if self.maxjumps == 1:
					self.jumpheight *= 2
					self.maxjumps += 1
					self.game.send_message("double jumps!")
				elif self.maxjumps == 2:
					self.maxjumps = 100000
					self.game.send_message("infinite jumps!")
				else:
					self.jumpheight += 10
					self.airspeed += 30
					self.game.send_message("better flying!")
				self.upgrade_movement -= 1
				self.grow(self.growth)
				self.menu = None
			if selection == 2:
				self.speed += 50
				self.game.send_message("faster running!")
				self.upgrade_movement -= 1
				self.grow(self.growth)
				self.menu = None
			if selection == 3:
				self.swimspeed += 50
				self.upgrade_movement -= 1
				self.grow(self.growth)
				self.menu = None
Beispiel #5
0
def modal(text="hello"):
    draw_text(text)