Snake/back-end/snake.h

53 lines
1.0 KiB
C
Raw Normal View History

2018-09-11 20:10:37 +03:00
#ifndef SNAKE_H
#define SNAKE_H
#define SPEEDSNAKE 10
#include <QVector>
#include "head.h"
2018-09-11 22:15:30 +03:00
#include "baseclass.h"
2018-10-11 00:04:52 +03:00
class GuiObject;
2018-11-28 22:17:30 +03:00
2018-09-11 22:15:30 +03:00
class Snake : public BaseClass
2018-09-11 20:10:37 +03:00
{
private:
2018-11-25 03:24:41 +03:00
double rataticonDistance = 1;
2018-09-14 22:06:34 +03:00
QVector<Head*> items;
2018-11-25 03:24:41 +03:00
double *speed = nullptr;
2018-11-16 02:08:35 +03:00
bool isClick = false;
int countClick = 0;
2018-11-28 22:17:30 +03:00
bool dead = false;
2018-12-01 21:06:40 +03:00
double sizeByLvl(double lvl, int count) const;
void changeCountObjects(int count);
2018-11-16 02:08:35 +03:00
2018-11-25 03:24:41 +03:00
double checDistance(int i);
void clearItems();
2018-11-25 18:10:08 +03:00
2018-09-11 20:10:37 +03:00
public:
Snake();
2018-09-11 22:15:30 +03:00
~Snake() override;
2018-11-25 03:24:41 +03:00
void clear();
2018-11-25 18:10:08 +03:00
void resetPosotion();
2018-10-11 00:04:52 +03:00
2018-11-28 22:17:30 +03:00
void kill();
bool isDead() const;
2018-11-16 02:08:35 +03:00
void reverse();
2018-09-11 22:15:30 +03:00
void render() override;
2018-11-25 03:24:41 +03:00
QMap<int, GuiObject *> init(int size, double *speed);
bool isInited() const;
2018-09-11 22:08:08 +03:00
const QVector<Head*>& getItems() const;
2018-10-11 18:09:35 +03:00
double getMovedLong() const;
2018-11-25 03:24:41 +03:00
double getRataticonDistance() const;
void setRataticonDistance(double value);
2018-11-28 22:17:30 +03:00
int getDeadTimer() const;
void setDeadTimer(int value);
2018-12-01 22:39:03 +03:00
void unPause();
2018-09-11 20:10:37 +03:00
};
#endif // SNAKE_H