This repository was archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.cpp
More file actions
45 lines (39 loc) · 1.68 KB
/
input.cpp
File metadata and controls
45 lines (39 loc) · 1.68 KB
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
41
42
43
44
45
//
// Created by alane on 02.01.2018.
//
#include <cstring>
#include <cstdio>
#include "input.h"
MenuInput convertInputToUpAndDown(const char *input) {
if (strcmp(input, "$ 38 Oben") == 0 || strcmp(input, "$ 87 W") == 0) return ARROW_UP;
if (strcmp(input, "$ 40 Unten") == 0 || strcmp(input, "$ 83 S") == 0) return ARROW_DOWN;
if (strcmp(input, "$ 39 Rechts") == 0 || strcmp(input, "$ 68 D") == 0) return ARROW_RIGHT;
if (strcmp(input, "$ 37 Links") == 0 || strcmp(input, "$ 65 A") == 0) return ARROW_LEFT;
if (strcmp(input, "$ 10 Eingabe") == 0) return ENTER;
return FALSE_INPUT;
}
Direction convertInputToNewDirection(const char *input) {
printf("%s\n", input);
if (strcmp(input, "$ 38 Oben") == 0 || strcmp(input, "$ 87 W") == 0) return UP;
if (strcmp(input, "$ 40 Unten") == 0 || strcmp(input, "$ 83 S") == 0) return DOWN;
if (strcmp(input, "$ 39 Rechts") == 0 || strcmp(input, "$ 68 D") == 0) return RIGHT;
if (strcmp(input, "$ 37 Links") == 0 || strcmp(input, "$ 65 A") == 0) return LEFT;
return NONE;
}
int getPlayerIndexByInput(const char *input) {
if(strcmp(input, "$ 38 Oben") == 0 ||
strcmp(input, "$ 40 Unten") == 0 ||
strcmp(input, "$ 39 Rechts") == 0 ||
strcmp(input, "$ 37 Links") == 0) {
return 0;
} else {
return 1;
}
}
int isCollidingDirections(Direction oldDirection, Direction newDirection) {
if (newDirection == UP && oldDirection != DOWN) return false;
if (newDirection == DOWN && oldDirection != UP) return false;
if (newDirection == RIGHT && oldDirection != LEFT) return false;
if (newDirection == LEFT && oldDirection != RIGHT) return false;
return true;
}