rewrote example.cpp to use composition
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "datatypes.cpp"
|
||||
#include "helpers.cpp"
|
||||
#include "buffer.cpp"
|
||||
|
||||
namespace UwU {
|
||||
// point
|
||||
class Point {
|
||||
public:
|
||||
Point(uint16_t x, uint16_t y) {
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
}
|
||||
Point() {}
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
|
||||
// Draw a rectangle
|
||||
void draw (Buffer buffer, Color color) {
|
||||
if (x > buffer.width || y > buffer.height) {return;};
|
||||
buffer.drawPixel(Coord2(x, y), color);
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user