Reputation: 9
Hi, I have to create a HUD for a Supermario Project with C++ and Qt. I have to recreate Supermario Bros 3 World 2 - Level 1 . So I wrote all the "static elements" like the "M" of Mario and the "World 2" element. Now I want to ask you how can I write dynamic writings like timer level (300 s) or the points counter?
This is my Hud.cpp file, in which I create the Hud panel.
Hud::Hud(const QPoint & position)
{
setPos(position);
// create collage texture
QPixmap collage(16 * 16 + 4, 3 * 16);
QPainter painter(&collage);
painter.fillRect(collage.rect(), Qt::black);
painter.drawPixmap(10, 5, Sprites::instance()->get("hud"));
painter.drawPixmap(49, 11, Sprites::instance()->get("font-2"));
painter.drawPixmap(14, 18, Sprites::instance()->get("font-Mario"));
//lifes
//AT THE BEGININNG MARIO HAS 3 LIFES
//THIS IS A STATIC WRITING
//HOW CAN I MAKE IT DYNAMIC? (if mario dies, show he has 2 lifes? )
painter.drawPixmap(45, 19, Sprites::instance()->get("font-3"));
painter.end();
setPixmap(collage);
}
Upvotes: 0
Views: 218