-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.c
53 lines (48 loc) · 862 Bytes
/
input.c
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
46
47
48
49
50
51
52
53
#include"core.h"
#include"player.h"
//SDL Event variable
SDL_Event e;
//Player variable
extern Player player;
int getInput()
{
if(SDL_PollEvent(&e))
{
switch(e.type)
{
case SDL_QUIT:
return -1;
case SDL_KEYDOWN:
switch(e.key.keysym.sym)
{
case SDLK_ESCAPE:
return -1;
case SDLK_LEFT:
player.x -= 10;
break;
case SDLK_RIGHT:
player.x += 10;
break;
case SDLK_UP:
player.y -= 10;
break;
case SDLK_DOWN:
player.y += 10;
break;
}
break;
case SDL_MOUSEBUTTONDOWN:
if(e.button.button == SDL_BUTTON_LEFT)
{
movePlayerXY(e.button.x, e.button.y);
//player.x = e.button.x - (player.w >> 1);
//player.y = e.button.y - (player.h >> 1);
}
if(e.button.button == SDL_BUTTON_RIGHT)
{
}
break;
}
}
return 0;
}