Beispiel #1
0
std::unique_ptr<Weapon> 
ObjectManager::create_extra_weapon(int player, PlayerState player_state)
{
    std::unique_ptr<Weapon> w;

    if (player_state.extra_weapon(player) == "Rocket Weapon") {
        sdlc::Sound& sfx = snd[ObjSnd::rocket];
        Owner own = Object::parse_owner(player);
        w = std::unique_ptr<Weapon>(new WeaponRocket(sfx, own));
        w->set_count(player_state.extra_weapon_count(player));
    }

    return w;
}
Beispiel #2
0
void Interface::draw_weapons(int x, int y, PlayerState& ps, int player, 
        sdlc::Font& font, sdlc::Screen& screen)
{
    auto length1 = (ps.main_weapon(player)).length();
    std::string text1 = (ps.main_weapon(player)).substr(0, length1 - 7);
    auto length2 = (ps.extra_weapon(player)).length();
    std::string text2 = (ps.extra_weapon(player)).substr(0, length2 - 7);

    screen.print(x, y, text1 + " level " 
            + std::to_string(ps.main_weapon_level(player)), font);
    if (ps.extra_weapon(player) != "none") {
        screen.print(x, y + 20, text2 + " count: " 
                + std::to_string(ps.extra_weapon_count(player)), font);
    }
}