-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGame.cpp
72 lines (62 loc) · 2.29 KB
/
Game.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
#include "Game.h"
Game::Game(){
this->init();
// this->states.push(new ActiveState(this->window));
tm.addTexture("pixel", "/home/terrance/Desktop/games/RPG/Assets/pixel.png");
tm.addTexture("new-walk", "Assets/new-walk.png");
tm.addTexture("npc1", "Assets/base-walk.png");
tm.addTexture("interaction-screen", "Assets/small-square-text.png");
tm.addTexture("interaction-screen-select-1", "Assets/small-sqaure-text-select.png");
tm.addTexture("tree", "Assets/obst-tree.png");
tm.addTexture("stream", "Assets/water.png");
tm.addTexture("bridge", "Assets/bridge.png");
tm.addTexture("blood-levels", "Assets/blood-levels.png");
tm.addTexture("dialog1", "Assets/dialog1.png");
tm.addTexture("dialogBox", "Assets/dialogbox1.png");
tm.addTexture("dialogBox1", "Assets/tb-dialog1.png");
ttm.addText("dialog1", "This is sample text that will be used for sampling\nNew lines will be added occasionally and i hope it looks okay sad");
// tm.getSize();
this->states.push(new ActiveState(&tm, &ttm));
this->states.push(new Menu(&tm));
};
Game::~Game(){}
void Game::init(){
printf("Creating Window and initializing Game object now\n");
this->window = new sf::RenderWindow(sf::VideoMode(1024, 1024), "RPG", sf::Style::Close | sf::Style::Resize);
this->window->setVerticalSyncEnabled(true);
};
void Game::update(){
};
void Game::render(){
this->window->clear();
this->states.top()->render(this->window);
this->window->display();
};
void Game::run(){
printf("Game running \n");
sf::Clock frameClock;
sf::Time frameTime;
// lua_State* L = luaL_newstate();
// luaL_loadfile(L, "Zones/constraints/zone1.lua");
// lua_pcall(L, 0, 1, 0);
// auto waterRef = luabridge::
// lua_getglobal(L, "")
while(this->window->isOpen()){
sf::Event event;
while(window->pollEvent(event)){
// switch(event.type){
// case sf::Event::Resized:
//
// }
}
frameTime = frameClock.restart();
// this->update();
// this->render();
if(this->states.top()->stateFinished){
this->states.pop();
this->states.top()->init();
}
this->states.top()->update(frameTime);
this->render();
}
}