This repository has been archived by the owner on Oct 3, 2022. It is now read-only.
generated from camila314/cross-platform-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
73 lines (56 loc) · 1.67 KB
/
main.cpp
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
#define CAC_PROJ_NAME "Gradual Speed"
#include "GameObjectController.h"
class AccelAction : public CCActionInterval {
public:
static AccelAction* create(PlayerObject* p, float yAccel, float duration=1.0) {
auto pRet = new AccelAction();
pRet->m_fDuration = duration > 0 ? duration : 0.0001;
pRet->m_elapsed = 0;
pRet->m_bFirstTick = true;
pRet->m_destSpeed = yAccel;
pRet->m_srcSpeed = p->_yAccel();
pRet->m_player = p;
return pRet;
}
void update(float dur) override {
m_player->_yAccel() = dur*(m_destSpeed-m_srcSpeed)+m_srcSpeed;
}
virtual void step(float dt) override {
if (m_bFirstTick) {
m_bFirstTick = false;
m_elapsed = 0;
} else {
m_elapsed += dt;
}
this->update(m_elapsed / m_fDuration);
}
virtual bool isDone() override {
return m_elapsed > m_fDuration;
}
protected:
float m_destSpeed;
float m_srcSpeed;
PlayerObject* m_player;
};
class TestObject : public GameObjectController {
public:
static TestObject* create(int object_id) {
auto pRet = new TestObject();
pRet->init(object_id, "ring_01_001.png", kGameObjectTypeSolid);
return pRet;
}
void onSetup() override {
#include "/Users/jakrillis/spwn.c"
setTextureFromImage(&spwn_png, spwn_png_len);
}
void onCollision(PlayerObject* p, GJBaseGameLayer* l) override {
p->runAction(AccelAction::create(p, 16, 0.3));
}
};
void inject() {
ObjectManager::enable();
ObjectManager::addObject(83, &TestObject::create);
}
#if _WIN32
WIN32CAC_ENTRY(inject)
#endif