-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathworld.h
executable file
·64 lines (53 loc) · 1.28 KB
/
world.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
#ifndef WORLD_H
#define WORLD_H
#include <QVector>
#include "Box2D.h"
#include "car.h"
#include "contactlistener.h"
#include "geneticalgorithm.h"
#include "track.h"
class ContactListener;
class World: public QObject {
Q_OBJECT
public:
World();
~World();
void addSparksList(const int impulses, const b2Vec2 pos,
const QColor *color);
GeneticAlgorithm *getAlgorithm();
Car *getCar();
b2Vec2 getCenter();
Track *getTrack();
b2Body *getSpark(const int index);
int getSparkCount();
float getUptime();
void step();
signals:
void creteNewCar();
void freeCallListNumber(unsigned int);
public slots:
void carStoped();
private:
struct sparkStuct {
int count;
b2Vec2 pos;
const QColor *color;
};
static const float GRAVITY = -15.0;
static const int ITERATIONS = 30;
static const float TIME_STEP = 1.0/60.0;
static const int MAX_SPARK_COUNT = 512;
void destroy();
void destroySpark(const int index);
void init();
void updateSparks();
GeneticAlgorithm *algorithm;
b2World *b2world;
Car *car;
ContactListener *contactListener;
QVector<b2Fixture *> sparks;
QVector<sparkStuct> sparkList;
Track *track;
float uptime;
};
#endif // WORLD_H