-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayer.cpp
More file actions
49 lines (40 loc) · 965 Bytes
/
Copy pathplayer.cpp
File metadata and controls
49 lines (40 loc) · 965 Bytes
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
#include "splashkit.h"
#include "player.h"
#define PLAYER_HEIGHT 100
#define PLAYER_WIDTH 100
player_data new_player(double x, double y)
{
player_data result;
result.x = x;
result.y = y;
result.width = x + PLAYER_WIDTH;
result.height = y + PLAYER_HEIGHT;
result.vel = 0;
result.acc = 0.125;
result.highest_y = 0;
result.state = IDLE;
result.face = RIGHT;
return result;
}
bitmap player_bitmap(const player_data &player)
{
string bitmap_name;
bitmap_name = "player";
if (player.face == LEFT && player.state == IDLE)
{
bitmap_name += "-idle-l";
}
if (player.face == LEFT && player.state == JUMP)
{
bitmap_name += "-jump-l";
}
if (player.face == RIGHT && player.state == IDLE)
{
bitmap_name += "-idle-r";
}
if (player.face == RIGHT && player.state == JUMP)
{
bitmap_name += "-jump-r";
}
return bitmap_named(bitmap_name);
}