-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer.h
101 lines (83 loc) · 2.42 KB
/
player.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#ifndef PLAYER_H
#define PLAYER_H
#include <QObject>
#include <QGraphicsPixmapItem>
#include <QGraphicsItem>
#include <QMediaPlayer>
#include "iobserver.h"
#include "isubject.h"
#include "mushroom_object.h"
class Player: public QObject, public QGraphicsPixmapItem, public IObserver
{
Q_OBJECT
public:
Player(ISubject &gameLoop, QGraphicsItem * parent = 0);
void keyPressEvent(QKeyEvent * event) override;
void keyReleaseEvent(QKeyEvent * event) override;
void movePlayer();
void dying();
void colliding_block();
void update() override;
private:
ISubject &gameLoop;
float accl = 0.01;
float maxSpeed = 1.5;
float jumpCounterMax = 40;
float jumpCounter = 0;
float gravityMaxSpeed = 3;
float velX = 0;
float velY = 0;
bool isBig = false;
bool win = false;
bool isTakingDamage = false;
bool stopControls = false;
bool stopGravity = false;
bool isDead = false;
bool isMovingRight = false;
bool isMovingLeft = false;
bool isCollidingRight = false;
bool isCollidingLeft = false;
bool isCollidingBottom = false;
bool isCollidingTop = false;
bool isJumping = false;
bool mario_direction = false; //false = direita | true = esquerda
bool isAnimateToRight = false;
bool isAnimateToLeft = false;
bool isMidJump = false;
void damage();
void get_powerup(Mushroom_Object *mushr);
void change_hitboxes();
QGraphicsRectItem * mario_box_bottom;
QGraphicsRectItem * mario_box_top;
QGraphicsRectItem * mario_box_right;
QGraphicsRectItem * mario_box_left;
QGraphicsRectItem * mario_box_precise_top;
QGraphicsRectItem * mario_box_precise_bottom;
QTimer *timer;
QMediaPlayer * jump;
QMediaPlayer * win_music;
QMediaPlayer * music;
QMediaPlayer * dead;
QMediaPlayer * kick;
QMediaPlayer * powerup;
QMediaPlayer * damage_music;
private slots:
void walk_animation_1();
void walk_animation_2();
void walk_animation_3();
void jump_animation();
void stop_animation();
void winning_animation();
void walk_winning_animation();
void walk_winning_animation_2();
void walk_winning_animation_3();
void damage_animation();
void damage_animation_2();
void stop_damage_animation();
void powerup_animation();
void powerup_animation_2();
void die_animation_up();
void die_animation_down();
void restart_game();
};
#endif // PLAYER_H