Klasa Ice - Inf512-MotorolaScienceCup/gra-PANG GitHub Wiki

Klasa Ice

Odpowiada za lód. Jego tekstura wyświetlana jest w rzeczywistości lekko poniżej faktycznych rozmiarów obiektu dla poprawnej detekcji kolizji z Player’em.

class Ice : public Sprite {
public:
    Ice(Game* game, float x, float y, float width, float height);
    Ice(Game* game, std::ifstream&);
    virtual void Draw();
    virtual void Save(std::ofstream&);

private:
    Texture2D* texture;
    Rectangle textRec;
};

Ice::Ice(Game *game, float x, float y, float width, float height)
    : Sprite(game, Position(x, y, width, height), Type::ICE) {
    texture = &game->textures[ICE];
}

Ice::Ice(Game *game, std::ifstream& s)
    : Sprite(game, s, Type::ICE) {
    texture = &game->textures[ICE];
}

void Ice::Draw() {
    DrawTextureTiled(*texture, { 0, 0, 15, 30 }, position.rectangle, { 0, -7 }, 0, 1, WHITE);
}

void Ice::Save(std::ofstream& s) {
    Write(s, &type);
    position.Save(s);
}
⚠️ **GitHub.com Fallback** ⚠️