orton_runner/src/core/get_key.c

27 lines
520 B
C

/*
** EPITECH PROJECT, 2018
** task01
** File description:
** I do task
*/
#include "game/core.h"
#include <SFML/Window/Keyboard.h>
#include <SFML/System/Export.h>
static const uint8_t key_code[] = {sfKeyLShift, sfKeyRShift, sfKeyLeft,
sfKeyRight, sfKeyUp, sfKeySpace, sfKeyA, sfKeyEscape,
sfKeyDown, sfKeyReturn};
void get_key(sfml_t *sfml)
{
int i;
i = -1;
while (++i < 10){
if (sfKeyboard_isKeyPressed(key_code[i]))
sfml->key |= (0x10000 << i) | (0x01 << i);
else
sfml->key &= ~(0x10000 << i);
}
}