1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:27:45 +00:00

Breakout: Only paint areas that needs to be updated

This commit is contained in:
Karol Kosek 2021-07-12 01:11:31 +02:00 committed by Andreas Kling
parent 2e3df52862
commit 67e3daa679
2 changed files with 42 additions and 11 deletions

View file

@ -7,6 +7,7 @@
#pragma once
#include <LibGUI/Widget.h>
#include <LibGfx/Font.h>
namespace Breakout {
@ -76,6 +77,20 @@ private:
}
};
Gfx::IntRect lives_left_rect() const
{
int msg_width = font().width(String::formatted("Lives: {}", m_lives));
return { (game_width - msg_width - 2), 2, msg_width, font().glyph_height() };
}
Gfx::IntRect pause_rect() const
{
const char* msg = m_cheater ? "C H E A T E R" : "P A U S E D";
int msg_width = font().width(msg);
int msg_height = font().glyph_height();
return { (game_width / 2) - (msg_width / 2), (game_height / 2) - (msg_height / 2), msg_width, msg_height };
}
bool m_paused;
int m_lives;
int m_board;