-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGhost.cpp
More file actions
80 lines (79 loc) · 1.47 KB
/
Ghost.cpp
File metadata and controls
80 lines (79 loc) · 1.47 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
80
#include "raylib.h"
#include "Ghost.hpp"
Ghost::Ghost(int z, int t) {
x = z;
y = t;
speed = 2;
Texture2D ghostmovetexture;
Rectangle ghostmoveframe;
}
Ghost::~Ghost() {
}
void Ghost::up(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
y -= speed;
if (y < 0)
y = 0;
}
void Ghost::down(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
y += speed;
if (y > 950)
y = 950;
}
void Ghost::right(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
x += speed;
if (x > 950)
x = 950;
}
void Ghost::left(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
x -= speed;
if (x < 0)
x = 0;
}
void Ghost::upright(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
x += speed;
y -= speed;
if (x > 950)
x = 950;
if (y < 0)
y = 0;
}
void Ghost::upleft(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
x -= speed;
y -= speed;
if (x < 0)
x = 0;
if (y < 0)
y = 0;
}
void Ghost::downright(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
x += speed;
y += speed;
if (x > 950)
x = 950;
if (y > 950)
y = 950;
}
void Ghost::downleft(Texture2D texture, Rectangle frame) {
ghostmovetexture = texture;
ghostmoveframe = frame;
x -= speed;
y += speed;
if (x < 0)
x = 0;
if (y > 950)
y = 950;
}