parent
c8fa34634c
commit
2423ca3663
6 changed files with 44 additions and 22 deletions
@ -1,2 +1,9 @@ |
||||
#include <QPainter> |
||||
#include "Game.h" |
||||
|
||||
void Game::draw(QPixmap *output) { |
||||
QPainter p(output); |
||||
double w = output->size().width(); |
||||
double h = output->size().height(); |
||||
p.fillRect(w / 2 - 10, h / 2 - 10, 20, 20, Qt::red); |
||||
} |
||||
|
@ -1,5 +1,10 @@ |
||||
#pragma once |
||||
|
||||
#include "Queue.h" |
||||
|
||||
class Game { |
||||
GameQueue * eventQueue = new GameQueue; |
||||
|
||||
public: |
||||
void draw(QPixmap * output); |
||||
}; |
||||
|
@ -1,3 +1,24 @@ |
||||
#include "Window.h" |
||||
|
||||
|
||||
Window::Window() { |
||||
timer = new QTimer(this); |
||||
timer->setInterval(17); |
||||
connect(timer, &QTimer::timeout, this, [this](){ |
||||
update(); |
||||
}); |
||||
timer->start(); |
||||
|
||||
label = new QLabel(this); |
||||
label->resize(size()); |
||||
} |
||||
|
||||
void Window::paintEvent(QPaintEvent *) { |
||||
auto output = new QPixmap(label->size()); |
||||
game.draw(output); |
||||
label->setPixmap(*output); |
||||
} |
||||
|
||||
void Window::resizeEvent(QResizeEvent *e) { |
||||
label->resize(e->size()); |
||||
} |
||||
|
Loading…
Reference in new issue