-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathengine.cpp
More file actions
49 lines (31 loc) · 1.01 KB
/
Copy pathengine.cpp
File metadata and controls
49 lines (31 loc) · 1.01 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
#include "engine.h"
Engine::Engine(QQmlApplicationEngine * appEngine)
{
m_appEngine = appEngine;
m_root = m_appEngine->rootObjects()[0]->findChild<QQuickItem*>("root");
sun = newPlanet(QPointF(640/2,480/2),10,m_root);
planet = newPlanet(QPointF(150,0),10,sun);
moon = newPlanet(QPointF(0,-50), 5,planet);
planet->setPosition(QPointF(-150,50));
frameRate = 60;
timer = new QTimer;
timer->setInterval(1000/frameRate);
connect(timer,SIGNAL(timeout()),this,SLOT(timeout()));
timer->start();
}
Planet *Engine::newPlanet(QPointF position, float radius, QQuickItem * relative_obj)
{
Planet * p = new Planet(radius);
p->setParentItem(relative_obj);
p->setPosition(position);
QQmlComponent component(m_appEngine,QUrl("qrc:/planet.qml"));
QQuickItem * obj = qobject_cast<QQuickItem*>(component.create());
//Parenting graphics item to player
obj->setParent(m_appEngine);
p->assignObj(obj);
p->update();
return p;
}
void Engine::timeout()
{
}