Inimigos e players afetados pelos tiros
[Projeto-PCG.git] / controle.cpp
blobf7e05de30901d7138ef441b6e81e76c9ab662ccd
1 #include "controle.h"
2 #include "usereventtype.h"
4 Controle::Controle(Player &p) : jogador( p ) {
5 quit = false;
6 game = jogador.game;
7 map = game->mapa;
10 void Controle::handleEvents() {
11 SDL_Event e;
12 jogador.bypass = false;
13 while( SDL_PollEvent( &e ) ) {
14 switch( e.type ) {
15 case SDL_USEREVENT:
16 switch (e.user.code) {
17 case FUNCTIONCALL:{
18 void (*p) (void*) = (void (*)(void*))e.user.data1;
19 p(e.user.data2);
21 break;
22 default: handleEvent(e); break;
24 break;
25 case SDL_QUIT:
26 quit = true;
27 break;
28 case SDL_KEYDOWN:
29 switch (e.key.keysym.sym) {
30 case SDLK_F3:
31 jogador.equip(game->weaponManager->getWeapon("Shotgun"));
32 break;
33 case SDLK_F4:
34 jogador.equip(game->weaponManager->getWeapon("Flamethrower"));
35 break;
36 case SDLK_F5:
37 game->reloadLua();
38 break;
39 case SDLK_F6:
40 jogador.setPosition(game->getSpawn().x, game->getSpawn().y);
41 break;
42 default: handleEvent(e);break;
44 break;
45 case SDL_VIDEORESIZE:
46 jogador.game->resize(e.resize.w, e.resize.h);
47 break;
48 default:
49 handleEvent(e);
50 break;
53 handleOther();