-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameStart.cpp
76 lines (60 loc) · 1.38 KB
/
GameStart.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
74
#include "GameStart.h"
#include "WorldManager.h"
#include "ResourceManager.h"
#include "LogManager.h"
#include "GameManager.h"
#include "EventKeyboard.h"
#include "Color.h"
#include "Music.h"
#include "Points.h"
#include "Spawner.h"
#include "Lives.h"
#include "Ground.h"
#include "HighScore.h"
#include "Player.h"
#include "Scroller.h"
GameStart::GameStart() {
setType("GameStart");
setSprite("gamestart");
setLocation(df::CENTER_CENTER);
// Register for step event.
registerInterest(df::KEYBOARD_EVENT);
}
int GameStart::eventHandler(const df::Event *p_e) {
if (p_e->getType() == df::KEYBOARD_EVENT) {
df::EventKeyboard *p_keyboard_event = (df::EventKeyboard *) p_e;
switch (p_keyboard_event->getKey()) {
case df::Keyboard::P: // play
start();
break;
case df::Keyboard::Q: // quit
GM.setGameOver();
break;
default: // Key is not handled.
break;
}
return 1;
}
return 0;
}
// Override default draw so as not to display "value".
int GameStart::draw() {
return df::Object::draw();
}
void GameStart::start() {
//new Spawner;
new Spawner;
new Lives;
// Setup heads-up display.
new Points; // points display
new HighScore;
new Ground;
new Player;
new Scroller;
// When game starts, become inactive.
setActive(false);
}
// plays start music
void GameStart::playMusic() {
//p_music->play();
}