diff options
| author | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-01-16 19:38:33 +0100 |
|---|---|---|
| committer | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-01-16 19:38:33 +0100 |
| commit | a90db3b7b6e87e24c789b5db222f1cef92809bde (patch) | |
| tree | 2096abcb1ac1ea970a51e598257186bc4e030b22 /original/procesar.c | |
Initial commit
Diffstat (limited to 'original/procesar.c')
| -rw-r--r-- | original/procesar.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/original/procesar.c b/original/procesar.c new file mode 100644 index 0000000..2bb58b6 --- /dev/null +++ b/original/procesar.c @@ -0,0 +1,71 @@ +#include "main.h" + +int processEvents(SDL_Window *window,GameState *gameState) +{ + gameState->scrollx = -gameState->man.x; + SDL_Event event; + int done = 0; + + while(SDL_PollEvent(&event)) + { + switch(event.type) + { + case SDL_WINDOWEVENT_CLOSE: + { + if(window) + { + SDL_DestroyWindow(window); + window = NULL; + done = 1; + } + } + break; + case SDL_KEYDOWN: + { + switch(event.key.keysym.sym) + { + case SDLK_ESCAPE: + done = 1; + break; + } + } + break; + case SDL_QUIT: + //quit out of the game + done = 1; + break; + case SDL_MOUSEBUTTONDOWN: + gameState->man.x = event.button.x; + gameState->man.y = event.button.y; + break; + } + } + + const Uint8 *state = SDL_GetKeyboardState(NULL); + if(state[SDL_SCANCODE_LEFT]) + { + gameState->man.x -= 5; + gameState->man.facing_left = 1; + gameState->man.walking = 1; + } + if(state[SDL_SCANCODE_RIGHT]) + { + gameState->man.x += 5; + gameState->man.facing_left = 0; + gameState->man.walking = 1; + gameState->i++; + } + if(state[SDL_SCANCODE_SPACE]) + { + if(gameState->salto == 1 && gameState->man.dy != 0) + { + + } + else if(gameState->salto == 0 && gameState->man.dy == 0) + { + gameState->man.dy = -15; + gameState->salto = 1; + } + } + return done; +} |
