summary refs log tree commit diff stats
path: root/src/main.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2015-03-07 11:29:57 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2015-03-07 11:29:57 -0500
commitb53826079429939cdfbda073608cb85be8ba0738 (patch)
tree3c40de4658f0cea01cd3938f07fe82788ef3dd01 /src/main.cpp
parent0751446e1d069263d25abcff49a32a380231709a (diff)
downloadtherapy-b53826079429939cdfbda073608cb85be8ba0738.tar.gz
therapy-b53826079429939cdfbda073608cb85be8ba0738.tar.bz2
therapy-b53826079429939cdfbda073608cb85be8ba0738.zip
Created entity-component system
Also tweaked the bloom flicker, tweaked the scanline texture, created a second test map, and created some currently unused sound effects.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp67
1 files changed, 2 insertions, 65 deletions
diff --git a/src/main.cpp b/src/main.cpp index bc7832d..c552d2a 100644 --- a/src/main.cpp +++ b/src/main.cpp
@@ -1,77 +1,14 @@
1#include <ctime> 1#include <ctime>
2#include <list> 2#include <list>
3#include "map.h"
4#include "state.h"
5#include "mapview.h"
6#include "renderer.h" 3#include "renderer.h"
7#include <cstdlib> 4#include <cstdlib>
8 5#include "game.h"
9using namespace::std;
10
11bool quit = false;
12
13State* curGameState;
14
15void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
16{
17 if ((key == GLFW_KEY_ESCAPE) && (action == GLFW_PRESS))
18 {
19 quit = true;
20 }
21
22 if (curGameState != NULL)
23 {
24 curGameState->input(key, action);
25 }
26}
27 6
28int main() 7int main()
29{ 8{
30 srand(time(NULL)); 9 srand(time(NULL));
31 10
32 GLFWwindow* window = initRenderer(); 11 Game::getInstance().execute();
33 glfwSwapInterval(1);
34 glfwSetKeyCallback(window, key_callback);
35
36 Map* m = new Map("../maps/embarass.txt");
37 //Map* m2 = new Map("../maps/cozy.txt");
38
39 //m->setLeftMap(m2);
40 //m2->setRightMap(m);
41
42 curGameState = new MapView(m, 100, 100);
43
44 Texture* buffer = createTexture(GAME_WIDTH, GAME_HEIGHT);
45 //Texture* buffer = loadTextureFromBMP("../res/title.png");
46
47 double lastTime = glfwGetTime();
48 int nbFrames = 0;
49
50 while (!(quit || glfwWindowShouldClose(window)))
51 {
52 double currentTime = glfwGetTime();
53 nbFrames++;
54 if (currentTime - lastTime >= 1.0)
55 {
56 // printf and reset timer
57 printf("%f ms/frame\n", 1000.0/double(nbFrames));
58 nbFrames = 0;
59 lastTime += 1.0;
60 }
61
62 curGameState->tick();
63
64 // Do rendering
65 curGameState->render(buffer);
66 renderScreen(buffer);
67
68 glfwPollEvents();
69 }
70
71 delete curGameState;
72 delete m;
73
74 destroyRenderer();
75 12
76 return 0; 13 return 0;
77} 14}