F9 = recarrega mapa sem respawn; adicionada Yoshi's Island 3 :P
[Projeto-PCG.git] / controle.cpp
blobda53caec0e83a479626ef2183d0a097ace088afd
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 jogador.setPosition(game->getSpawn().x, game->getSpawn().y);
38 break;
39 case SDLK_F6:
40 game->previousMap();
41 break;
42 case SDLK_F7:
43 game->reloadMap(true);
44 break;
45 case SDLK_F8:
46 game->nextMap();
47 break;
48 case SDLK_F9:
49 game->reloadMap(false);
50 break;
51 default: handleEvent(e); break;
53 break;
54 case SDL_VIDEORESIZE:
55 game->resize(e.resize.w, e.resize.h);
56 break;
57 default:
58 handleEvent(e);
59 break;
62 handleOther();