-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayer1.cpp
More file actions
79 lines (78 loc) · 1.44 KB
/
Player1.cpp
File metadata and controls
79 lines (78 loc) · 1.44 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "raylib.h"
#include "Player1.hpp"
#include "Movement.hpp"
Player1::Player1() {
x = 625;
y = 500;
speed = 3;
Texture2D p1movetexture;
Rectangle p1moveframe;
}
void Player1::up(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
y -= speed;
if (y < 0)
y = 0;
}
void Player1::down(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
y += speed;
if (y > 950)
y = 950;
}
void Player1::right(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
x += speed;
if (x > 950)
x = 950;
}
void Player1::left(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
x -= speed;
if (x < 0)
x = 0;
}
void Player1::upright(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
x += speed;
y -= speed;
if (x > 950)
x = 950;
if (y < 0)
y = 0;
}
void Player1::upleft(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
x -= speed;
y -= speed;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
}
void Player1::downright(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
x += speed;
y += speed;
if (x > 950)
x = 950;
if (y > 950)
y = 950;
}
void Player1::downleft(Texture2D texture, Rectangle frame) {
p1movetexture = texture;
p1moveframe = frame;
x -= speed;
y += speed;
if (x < 0)
x = 0;
if (y > 950)
y = 950;
}