Ejemplo n.º 1
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);
    }
}
Ejemplo n.º 2
0
std::unique_ptr<Weapon> 
ObjectManager::create_main_weapon(int player, PlayerState player_state) 
{
    std::unique_ptr<Weapon> w;

    if (player_state.main_weapon(player) == "Blaster Weapon") {
        sdlc::Sound& sfx = snd[ObjSnd::blaster];
        Owner own = Object::parse_owner(player);
        w = std::unique_ptr<Weapon>(new WeaponBlaster(sfx, own));
    }

    for (int j = 1; j < player_state.main_weapon_level(player); ++j)
        w->upgrade();

    return w;
}