-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
64 lines (52 loc) · 1.82 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
#include "app/baseapp.h"
#include "ztyp/ztyp.h"
#include <iostream>
class GameApp : public app::GameApp {
public:
GameApp(int w, int h)
: app::GameApp(w, h) {
}
private:
void Initialize() override {
render::LoadResource("resources/images/apple.png", "apple");
render::LoadResource("resources/images/stars.jpg", "stars");
render::LoadResource("resources/images/gradient.png", "gradient");
render::LoadResource("resources/images/mother.png", "mother");
space_ships_.push_back(new zt::SmallShip("abc", {10, 10}, {0,0}));
space_ships_.push_back(new zt::SmallShip("abc", {100, 20}, {0,1}));
space_ships_.push_back(new zt::SpamShip("abc", {200, 10}, {0,0}));
space_ships_.push_back(new zt::SmallShip("abc", {220, 40}, {0,0}));
space_ships_.push_back(new zt::SmallShip("abc", {300, 50}, {0,0}));
}
void ProcessInput(const Uint8* keyboard, const MouseState& mouse) override {
}
void Render() override {
render::DrawImage("stars", 0, 0, 480, 720);
/// ?? entire alpha channel render::DrawImage("gradient",0, 0, 480, 720);
for (const zt::SpaceShip* ss: space_ships_) {
const zt::Vector2d& pos = ss->GetPosition();
render::DrawImage("mother", pos.x, pos.y);
}
}
void Update(Uint32 millis) override {
std::vector<zt::SpaceShip*> new_ss;
for (zt::SpaceShip* ss: space_ships_) {
auto ns = ss->Update(0.1f);
new_ss.insert(new_ss.end(), ns.begin(), ns.end());
//space_ships_.insert(space_ships_.end(), new_ss.begin(), new_ss.end());
}
space_ships_.insert(space_ships_.end(), new_ss.begin(), new_ss.end());
}
zt::Player player_;
std::vector<zt::SpaceShip*> space_ships_;
int level_ = 1;
};
#undef main
int main() {
try {
GameApp(800, 800).Run();
} catch (std::exception& e) {
std::cout << e.what() << std::endl;
}
return 0;
}