-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (42 loc) · 1.51 KB
/
main.cpp
File metadata and controls
57 lines (42 loc) · 1.51 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
//Pre-compiled header are used in this project
#include "stdafx.h"
//Include Annwvyn Engine.
#include <Annwvyn.h>
//Every Annwvyn classes are in the Annwvyn namespace
//Include our level/stages here
#include "myLevel.hpp"
#include "PST4Net.hpp"
//constexpr const char* const server{ "annwvyn.org" };
constexpr const char* const server{ "localhost" };
#include <iostream>
#include <fstream>
using namespace Annwvyn;
AnnMain() //The application entry point is "AnnMain()". return type int.
{
std::ifstream ipFile;
ipFile.open("ip.cfg");
std::string serverAddress;
if (ipFile.is_open())
ipFile >> serverAddress;
ipFile.close();
//Initialize the engine
AnnEngine::openConsole();//optional : open console
AnnInit("NameOfApp");
AnnGetResourceManager()->addFileLocation("./media/teleroom/");
AnnGetResourceManager()->initResources();
//Call physics initialization for the player body:
AnnGetEngine()->initPlayerStandingPhysics();
//Instantiate and register our basic level and "jump" to it:
AnnGetLevelManager()->addLevel(std::make_shared<MyLevel>());
AnnGetLevelManager()->jumpToFirstLevel();
//The game is rendering here now:
AnnGetEventManager()->useDefaultEventListener();
if (serverAddress.empty())
serverAddress = server;
AnnGetEngine()->registerUserSubSystem(std::make_shared<PST4::NetSubSystem>(serverAddress));
//The game runs here
AnnGetEngine()->startGameplayLoop();
//Destroy the engine now. Engine is RAII managed, but you can manually release it with this command
AnnQuit();
return EXIT_SUCCESS;
}