コード例 #1
0
void classMap::move_npcs() /// @TODO - check out of screen
{
	int i = 0;
	std::list<classnpc*>::iterator npc_it;
	//std::cout << "*************** classMap::showMap - npc_list.size: " << npc_list.size() << std::endl;
	for (npc_it = npc_list.begin(); npc_it != npc_list.end(); npc_it++) {
		//std::cout << ">>>>>>>>>>>>>>>>>> classMap::showMap - executing npc[" << i << "] '" << (*npc_it)->getName() << "'" << std::endl;
		bool temp_is_boss = (*npc_it)->is_boss();

		if (freeze_weapon_effect == false) {
			(*npc_it)->execute(); // TODO: must pass scroll map to npcs somwhow...
		}
		//(*npc_it)->show();
		if ((*npc_it)->is_dead() == true) {
			std::string temp_name = (*npc_it)->getName();
			if (!temp_is_boss) {
				add_animation(ANIMATION_STATIC, std::string("explosion_32.png"), st_position((*npc_it)->getPosition().x, (*npc_it)->getPosition().y), st_position(-8, -8), 80, 2, (*npc_it)->get_direction(), st_size(32, 32));
			}
			//std::cout << "Stage[" << stage_number << "].map[" << number << "] - Killed npc[" << i << "] '" << (*npc_it)->getName() << "'" << ", is_boss: " << temp_is_boss << std::endl;
			st_position npc_pos = (*npc_it)->get_real_position();
			delete (*npc_it);
			npc_list.erase(npc_it);
			if (temp_is_boss) {
				//std::cout << "classMap::showMap - killed boss" << std::endl;
				gameControl.draw_explosion(npc_pos.x, npc_pos.y, true);
				gameControl.got_weapon(temp_name);
			}
			return;
		}
		i++;
	}
}
コード例 #2
0
void classPlayer::death()
{
    std::cout << "PLAYER::death" << std::endl;
    map->print_objects_number();
    reset_charging_shot();
	map->clear_animations();
    map->print_objects_number();
    map->reset_objects();
    map->print_objects_number();
	dead = true;
	state.jump_state = NO_JUMP;
    freeze_weapon_effect = FREEZE_EFFECT_NONE;
    clear_move_commands();
	input.clean();
	state.direction = ANIM_DIRECTION_RIGHT;
	gameControl.draw_explosion(realPosition.x, realPosition.y, false);
    if (game_save.items.lifes == 0) {
        game_save.items.lifes = 3;
        std::cout << "GAME OVER" << std::endl;
        gameControl.game_over();
        return;
    }
    game_save.items.lifes--;
}