parent
c7986e6bc0
commit
ef4e89e63c
13 changed files with 115 additions and 23 deletions
@ -1 +0,0 @@ |
||||
#include "Entity.h" |
@ -1,5 +0,0 @@ |
||||
#pragma once |
||||
|
||||
class Entity { |
||||
|
||||
}; |
@ -1,11 +1,11 @@ |
||||
#pragma once |
||||
|
||||
#include "Entity.h" |
||||
#include "Listener.h" |
||||
|
||||
class Spectator : public Entity, public GameListener { |
||||
class Spectator : public GameListener { |
||||
protected: |
||||
void OnWallJumped(WallJumpEvent * event) override; |
||||
void OnWallCrashed(WallCrashEvent * event) override; |
||||
public: |
||||
void draw(QPainter &painter) const; |
||||
}; |
||||
|
@ -0,0 +1,26 @@ |
||||
#include "Wall.h" |
||||
#include "Game.h" |
||||
|
||||
void Wall::draw(QPainter &painter) const { |
||||
painter.save(); |
||||
|
||||
int w = size.width(); |
||||
int h = size.height(); |
||||
painter.translate(pos.toPoint()); |
||||
painter.fillRect(w / 2, -h, w, h, Qt::black); |
||||
|
||||
painter.restore(); |
||||
} |
||||
|
||||
void Wall::update(float dTime) { |
||||
pos.setX(pos.x() - dTime * velocity); |
||||
} |
||||
|
||||
Wall::Wall() { |
||||
pos = {WIDTH, GROUND_Y}; |
||||
size = {50, 50}; |
||||
} |
||||
|
||||
bool Wall::isLost() const { |
||||
return pos.x() < -100; |
||||
} |
@ -0,0 +1,17 @@ |
||||
#pragma once |
||||
|
||||
#include <QPainter> |
||||
#include <QVector2D> |
||||
|
||||
class Wall { |
||||
float velocity = 300; |
||||
public: |
||||
bool jumped = false; |
||||
bool failed = false; |
||||
QVector2D pos; |
||||
QSize size; |
||||
bool isLost() const; |
||||
explicit Wall(); |
||||
void draw(QPainter &painter) const; |
||||
void update(float dTime); |
||||
}; |
Loading…
Reference in new issue