|
|
|
@ -1,14 +1,20 @@ |
|
|
|
|
#include "Player.h" |
|
|
|
|
#include "Audio.h" |
|
|
|
|
#include <iostream> |
|
|
|
|
#include "Game.h" |
|
|
|
|
|
|
|
|
|
void Player::mousePressed(MouseEvent *event) { |
|
|
|
|
if (pos.y() == ground && event->button == Qt::MouseButton::LeftButton){ |
|
|
|
|
if (pos.y() == GROUND_Y && event->button == Qt::MouseButton::LeftButton){ |
|
|
|
|
jump(); |
|
|
|
|
auto e = new WallJumpEvent; |
|
|
|
|
e->time = Game::instance->eTime; |
|
|
|
|
e->player = this; |
|
|
|
|
e->wallHeight = 100; |
|
|
|
|
Game::eventQueue->submitEvent(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Player::draw(QPainter &painter) { |
|
|
|
|
void Player::draw(QPainter &painter) const { |
|
|
|
|
painter.save(); |
|
|
|
|
|
|
|
|
|
painter.translate(pos.toPoint()); |
|
|
|
@ -21,8 +27,8 @@ void Player::update(float dTime) { |
|
|
|
|
pos += vel * dTime; |
|
|
|
|
vel += acc * dTime; |
|
|
|
|
|
|
|
|
|
if (pos.y() > ground){ |
|
|
|
|
pos.setY(ground); |
|
|
|
|
if (pos.y() > GROUND_Y){ |
|
|
|
|
pos.setY(GROUND_Y); |
|
|
|
|
vel = {}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|