fix test lvl

This commit is contained in:
Andrei Yankovich 2021-06-22 18:12:34 +03:00
parent 6bda0f06fb
commit cccea19ee3
8 changed files with 33 additions and 10 deletions

View File

@ -31,7 +31,6 @@ QByteArray ClientApp::initTheme() {
case 1: return "Dark"; case 1: return "Dark";
default: return "Light"; default: return "Light";
} }
} }
ClientApp::ClientApp() { ClientApp::ClientApp() {

View File

@ -30,7 +30,7 @@ void GuiObject::setColor(QString color) {
void GuiObject::generateId() { void GuiObject::generateId() {
static int id = 0; static int id = 0;
_guiId = id++; setGuiId(id++);
} }
const QString &GuiObject::className() const { const QString &GuiObject::className() const {

View File

@ -5,12 +5,13 @@
//# of this license document, but changing it is not allowed. //# of this license document, but changing it is not allowed.
//# //#
#include "defaultcontrol.h"
#include "iplayer.h" #include "iplayer.h"
IPlayer::IPlayer(const QString &name, IPlayer::IPlayer(const QString &name,
const QString &viewTempalte, const QString &viewTempalte,
QObject *ptr): QObject *ptr):
IWorldItem(name, viewTempalte, ptr) { MovableObject(name, viewTempalte, ptr) {
} }
@ -52,6 +53,21 @@ void IPlayer::setSpeed(float newSpead) {
} }
} }
void IPlayer::setControl(const IControl *control) {
if (auto oldControl = dynamic_cast<const DefaultControl*>(_currentControl)) {
disconnect(oldControl, &DefaultControl::userTap, this, &IPlayer::onTap);
}
auto defaultControl = dynamic_cast<const DefaultControl*>(control);
_currentControl = defaultControl;
if (_currentControl) {
connect(defaultControl, &DefaultControl::userTap, this, &IPlayer::onTap);
}
}
void IPlayer::kill() { void IPlayer::kill() {
_fDead = true; _fDead = true;
} }

View File

@ -9,15 +9,15 @@
#define IPLAYER_H #define IPLAYER_H
#include "gameresult.h" #include "gameresult.h"
#include "iworlditem.h"
#include "global.h" #include "global.h"
#include "movableobject.h"
class IControl; class IControl;
/** /**
* @brief The IPlayer class This is base class of the player functions. * @brief The IPlayer class This is base class of the player functions.
*/ */
class CRAWL_EXPORT IPlayer: public IWorldItem { class CRAWL_EXPORT IPlayer: public MovableObject {
Q_OBJECT Q_OBJECT
public: public:
IPlayer(const QString& name, IPlayer(const QString& name,
@ -53,7 +53,7 @@ public:
* @param control This is control object. * @param control This is control object.
* @note This method can invoked two or more times, for example connect with AI control object and player control object. So your implementation should be contains disconnect methods. * @note This method can invoked two or more times, for example connect with AI control object and player control object. So your implementation should be contains disconnect methods.
*/ */
virtual void setControl(const IControl* control) = 0; virtual void setControl(const IControl* control);
protected: protected:
@ -92,6 +92,7 @@ protected:
*/ */
void fine(int value); void fine(int value);
protected slots:
/** /**
* @brief onTap This method invoked when user tap on screen. * @brief onTap This method invoked when user tap on screen.
* @note method connected in the IPlayer::setControl function. So if you overrid the IPlayer::setControl method then please invoke method of a parent class. * @note method connected in the IPlayer::setControl function. So if you overrid the IPlayer::setControl method then please invoke method of a parent class.
@ -102,6 +103,7 @@ private:
bool _fDead = false; bool _fDead = false;
int _currentPoints = 0; int _currentPoints = 0;
float _speed = 0; float _speed = 0;
const IControl * _currentControl = nullptr;
}; };
#endif // IPLAYER_H #endif // IPLAYER_H

View File

@ -28,6 +28,9 @@ void MovableObject::render(unsigned int tbfMsec) {
// recalc new currentMovable vector (applay changes) // recalc new currentMovable vector (applay changes)
_currentMovableVector += tempVector; _currentMovableVector += tempVector;
// update movable vector
_movableVector *= _breakingForce;
} }
const QVector3D &MovableObject::movableVector() const { const QVector3D &MovableObject::movableVector() const {

View File

@ -12,7 +12,7 @@
* * **Angular velocity** This property sets spead of the angle moving. * * **Angular velocity** This property sets spead of the angle moving.
* * **Braking force** This property are delta decriment the Power of the movable vector on time. * * **Braking force** This property are delta decriment the Power of the movable vector on time.
*/ */
class MovableObject: public IWorldItem class CRAWL_EXPORT MovableObject: public IWorldItem
{ {
Q_OBJECT Q_OBJECT
public: public:
@ -72,7 +72,7 @@ private:
QVector3D _currentMovableVector; QVector3D _currentMovableVector;
float _angularVelocity = 0; float _angularVelocity = 0;
float _breakingForce = 0; float _breakingForce = 1;
}; };

View File

@ -33,7 +33,9 @@ View3D {
PointLight { PointLight {
position: camera.position position: camera.position
brightness: 1500 rotation: camera.rotation
brightness: 250
} }
environment: SceneEnvironment { environment: SceneEnvironment {
@ -64,6 +66,7 @@ View3D {
console.log("create object fail") console.log("create object fail")
return; return;
} }
const objModel = model.getGameObject(cppObjId); const objModel = model.getGameObject(cppObjId);
if (!objModel) { if (!objModel) {

@ -1 +1 @@
Subproject commit 3f8198a0767f860fa17fed86f6772f09462077fa Subproject commit d23bfac78fa12f38aafaffc99955bcaea35e59a9