-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfruit.cpp
More file actions
32 lines (26 loc) · 773 Bytes
/
fruit.cpp
File metadata and controls
32 lines (26 loc) · 773 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
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "fruit.h"
#include <stdlib.h>
using namespace std;
void Fruit::paint(XInfo &xinfo) {
XFillRectangle(xinfo.display, xinfo.pixmap, xinfo.gc[0], x, y, 15, 15);
}
Fruit::Fruit(int maxX, int maxY) {
//regenerateFruit();
this->maxX = maxX - 200;
this->maxY = maxY - 200;
x = 250;
y = 250;
}
void Fruit::regenerate(XInfo &xInfo) {
unPaint(xInfo);
this->x = (rand() % (maxX - 200)) + 200;
this->y = (rand() % (maxY - 200)) + 200; // FIX THIS, GOING OUT OF BOUNDS RN
cout << "X: " << x << " Y:" << y << endl;
cout << "maxX: " << maxX << " maxY:" << maxY << endl;
paint(xInfo);
}
void Fruit::unPaint(XInfo &xinfo) {
XFillRectangle(xinfo.display, xinfo.pixmap, xinfo.gc[1], x, y, 15, 15);
}