-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayentity.cpp
More file actions
127 lines (104 loc) · 2.58 KB
/
Copy pathplayentity.cpp
File metadata and controls
127 lines (104 loc) · 2.58 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#include "playentity.h"
PlayerEntity::PlayerEntity()
{
qDebug() << getCurrentTime() << "initObject:player" << endl;
this->moveEntityPixmap = new PlayerItem(); // 获得图元实例
this->setBaseHealth(BASE_HEALTH_PLAYER); // 设置基础血量
this->setMotionTickIndex(0);
this->setAccelerationX(BASE_ACCEX_PLAYER); // 设置初始水平加速度
this->setGravity(BASE_ACCEY_PLAYER); // 设置初始竖直加速度
this->setAccelerationF( BASE_ACCEX_F_PLAYER ); //设置水平阻力加速度
this->setSpeedX(BASE_SPEEDX_PLAYER); // 设置初始水平速度为
this->setMovingX(false); // 设置是否有水平动量
this->setXOffsets(0); // 设置水平偏移为0
}
PlayerEntity::~PlayerEntity()
{
// 玩家死亡后应该设置对速度或者计时器全部停止计算
this->setBaseHealth(0);
delete this;
}
/* 物理性质函数 */
void PlayerEntity::setSpeed( qreal speedX, qreal speedY ){
this->speed = sqrt(pow(speedX , 2) + pow(speedY , 2));
}
void PlayerEntity::setSpeed(qreal speed)
{
this->speed = speed;
}
qreal PlayerEntity::getSpeed()
{
return this->speed;
}
void PlayerEntity::setSpeedX(qreal speedX)
{
this->speedX = speedX;
}
qreal PlayerEntity::getSpeedX()
{
return this->speedX;
}
void PlayerEntity::setAccelerationX(qreal a)
{
this->accelerationX = a;
}
qreal PlayerEntity::getAccelerationX()
{
return this->accelerationX;
}
void PlayerEntity::setAccelerationF(qreal a)
{
this->accelerationF = a;
}
qreal PlayerEntity::getAccelerationF()
{
return this->accelerationF;
}
void PlayerEntity::setMovingX(bool temp)
{
this->moving = temp;
}
bool PlayerEntity::isMovingX()
{
return this->moving;
}
void PlayerEntity::setXOffsets(int offsets)
{
this->offsetX = offsets;
}
int PlayerEntity::getXOffsets()
{
return this->offsetX;
}
void PlayerEntity::setInertiaMove(int temp)
{
//playerView->translate(0,temp);
}
void PlayerEntity::setMotionTickIndex(long int a)
{
this->motionTickIndex = a;
}
long int PlayerEntity::getTimeGo()
{
return this->motionTickIndex;
}
void PlayerEntity::setGravity(double fixedValue)
{
this->gravity = fixedValue;
}
void PlayerEntity::setGravity(int poX, int posY,double speedX)
{
this->gravity = ((-1) * posY * pow(speedX, 2)) / poX;
}
double PlayerEntity::getGravity()
{
return this->gravity;
}
// 强制上升:
void PlayerEntity::uppingEvent()
{
}
// 按键跳跃
void PlayerEntity::uppingEvent(QKeyEvent *jumpEvent)
{
}