-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
pong.h
75 lines (63 loc) · 1.96 KB
/
pong.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
65
66
67
68
69
70
71
72
73
74
75
#ifndef CLASS_MYEVENTHANDLER
#define CLASS_MYEVENTHANDLER
#include <ncine/IAppEventHandler.h>
#include <ncine/IInputEventHandler.h>
#include <ncine/Vector2.h>
#include <nctl/String.h>
#include <nctl/UniquePtr.h>
namespace ncine {
class AppConfiguration;
class SceneNode;
class Texture;
class Font;
class Sprite;
class TextNode;
class ParticleSystem;
class AudioBuffer;
class AudioBufferPlayer;
}
namespace nc = ncine;
/// My nCine event handler
class MyEventHandler :
public nc::IAppEventHandler,
public nc::IInputEventHandler
{
public:
void onPreInit(nc::AppConfiguration &config) override;
void onInit() override;
void onFrameStart() override;
#ifdef __ANDROID__
virtual void onTouchDown(const nc::TouchEvent &event) override;
virtual void onTouchMove(const nc::TouchEvent &event) override;
#endif
void onKeyReleased(const nc::KeyboardEvent &event) override;
void onMouseButtonPressed(const nc::MouseEvent &event) override;
void onMouseMoved(const nc::MouseState &state) override;
void onJoyMappedAxisMoved(const nc::JoyMappedAxisEvent &event) override;
void onJoyMappedButtonReleased(const nc::JoyMappedButtonEvent &event) override;
private:
nctl::UniquePtr<nc::Texture> megaTexture_;
nctl::UniquePtr<nc::Font> font_;
nctl::UniquePtr<nc::SceneNode> dummy_;
nctl::UniquePtr<nc::Sprite> blueStick_;
nctl::UniquePtr<nc::Sprite> redStick_;
nctl::UniquePtr<nc::Sprite> ball_;
nctl::UniquePtr<nc::TextNode> versionText_;
float targetY_;
nc::Vector2f ballVelocity_;
int blueScore_;
int redScore_;
nctl::UniquePtr<nc::TextNode> blueScoreText_;
nctl::UniquePtr<nc::TextNode> redScoreText_;
nctl::String scoreString_;
bool shouldKickOff_;
float joyAxisValue_;
nctl::UniquePtr<nc::ParticleSystem> particleSys_;
nctl::UniquePtr<nc::AudioBuffer> tickAudioBuffer_;
nctl::UniquePtr<nc::AudioBuffer> outAudioBuffer_;
nctl::UniquePtr<nc::AudioBufferPlayer> tickSound_;
nctl::UniquePtr<nc::AudioBufferPlayer> outSound_;
void kickOff();
void reset();
};
#endif