Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
85 lines (67 loc) · 2.03 KB
/
Copy pathmain.cpp
File metadata and controls
85 lines (67 loc) · 2.03 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
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
76
77
78
79
80
81
82
83
84
85
/**
* Example Application: 2D Scene Graph Demo #3
*
* @file main.cpp
* @version 1.0.0
* @author Roman Divotkey
* @copyright MIT License
*/
// Local includes
#include "MainService.h"
#include "HandleBlock.h"
#include "HandlePaddle.h"
#include "HandleBall.h"
#include "EntityPrototypeService.h"
#include "cBall.h"
// AST Utilities includes
#include <AstuSuiteSDL.h>
#include <AstuInput.h>
#include <AstuECS.h>
#include <AstuSuite2D.h>
// ASTU/Box2D includes
#include <AstuBox2D.h>
// C++ Standard Library includes
#include <iostream>
#include <stdexcept>
using namespace astu2d;
using namespace astu;
using namespace std;
// Main entry point of the application.
int main()
{
SdlApplication app;
ASTU_CREATE_AND_ADD_SERVICE(CameraService);
ASTU_CREATE_AND_ADD_SERVICE(CameraControlService);
ASTU_CREATE_AND_ADD_SERVICE(EntityService);
ASTU_CREATE_AND_ADD_SERVICE(GameEventService);
ASTU_CREATE_AND_ADD_SERVICE(SceneSystem);
ASTU_CREATE_AND_ADD_SERVICE(Box2DPhysicsSystem);
ASTU_CREATE_AND_ADD_SERVICE(CollisionSignalService);
ASTU_CREATE_AND_ADD_SERVICE(EntityFactoryService);
// Let's add our main service that runs the application.
ASTU_CREATE_AND_ADD_SERVICE(EntityPrototypeService);
ASTU_CREATE_AND_ADD_SERVICE(MainService);
ASTU_CREATE_AND_ADD_SERVICE(HandleBall);
ASTU_CREATE_AND_ADD_SERVICE(HandleBlock);
ASTU_CREATE_AND_ADD_SERVICE(HandlePaddle);
ASTU_SERVICE(PhysicsSystem).SetGravityVector(0.0f,0.0f);
auto& ims = ASTU_SERVICE(InputMappingService);
ims.AddAxisMapping("Move", Keys::Left, -1.0f);
ims.AddAxisMapping("Move", Keys::Right, 1.0f);
ims.AddActionMapping("Respawn", Keys::SpaceBar);
app.SetApplicationName("Breakout-Clone");
app.SetVersionString("1.0.0");
// Run the application.
try {
app.Run();
}
catch (const runtime_error & e) {
cerr << e.what() << endl;
return -1;
}
catch (const logic_error & e) {
cerr << "programmer error: " << e.what() << endl;
return -1;
}
return 0;
}