aboutsummaryrefslogtreecommitdiff
path: root/src/example/gameloop.cpp
blob: d45b3ce989d2e613c0ddd4d9d4b020d5674168e7 (plain)
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
#include <iostream>
#include "crepe/api/LoopManager.h"
#include <crepe/api/EventManager.h>
#include <crepe/api/GameObject.h>
#include <crepe/api/IKeyListener.h>
#include <crepe/api/IMouseListener.h>
using namespace crepe;
class TestKeyListener : public IKeyListener {
public:
	bool on_key_pressed(const KeyPressEvent & event) override {
		std::cout << "TestKeyListener: Key Pressed - Code: " << static_cast<int>(event.key)
				  << std::endl;
		if(event.key == Keycode::ESCAPE){
			
		}
		return false;
	}
	bool on_key_released(const KeyReleaseEvent & event) override {
		std::cout << "TestKeyListener: Key Released - Code: " << static_cast<int>(event.key)
				  << std::endl;
		return false;
	}
};
bool on_key_pressed(const KeyPressEvent & event){
		std::cout << "TestKeyListener: Key Pressed - Code: " << static_cast<int>(event.key)
				  << std::endl;
		if(event.key == Keycode::ESCAPE){
			return true;
		}
		return false;
	}
int main() {
	LoopManager gameloop;
	TestKeyListener key_listener;
	EventManager::get_instance().subscribe<KeyPressEvent>(on_key_pressed);
	gameloop.start();
	
	
	return 1;
}