|
|
@ -1,14 +1,20 @@ |
|
|
|
#include "Player.h" |
|
|
|
#include "Player.h" |
|
|
|
#include "Audio.h" |
|
|
|
#include "Audio.h" |
|
|
|
#include <iostream> |
|
|
|
#include <iostream> |
|
|
|
|
|
|
|
#include "Game.h" |
|
|
|
|
|
|
|
|
|
|
|
void Player::mousePressed(MouseEvent *event) { |
|
|
|
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(); |
|
|
|
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.save(); |
|
|
|
|
|
|
|
|
|
|
|
painter.translate(pos.toPoint()); |
|
|
|
painter.translate(pos.toPoint()); |
|
|
@ -21,8 +27,8 @@ void Player::update(float dTime) { |
|
|
|
pos += vel * dTime; |
|
|
|
pos += vel * dTime; |
|
|
|
vel += acc * dTime; |
|
|
|
vel += acc * dTime; |
|
|
|
|
|
|
|
|
|
|
|
if (pos.y() > ground){ |
|
|
|
if (pos.y() > GROUND_Y){ |
|
|
|
pos.setY(ground); |
|
|
|
pos.setY(GROUND_Y); |
|
|
|
vel = {}; |
|
|
|
vel = {}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|