Phyzix
Loading...
Searching...
No Matches
DynamicObject.h
1//
2// Created by shams on 8/7/24.
3//
4
5#ifndef PHYZIX_DYNAMICOBJECT_H
6#define PHYZIX_DYNAMICOBJECT_H
7
8
9#include <cstdint>
10#include "Drawable.h"
11#include "Boundary.h"
12#include "Vector.h"
13#include "app/lib/rtti.h"
14#include "app/lib/malloc.h"
15
16class DynamicObject : public Drawable {
17public:
18 float prev_x = 0;
19 float prev_y = 0;
20
21 Vector s;
22 Vector v = Vector(0, 0);
23 Vector a = Vector(0, 0);
24 float m = 1;
25
26 Vector (*forceFunction)(float, float, float, float, float){};
27
28 float zIndex = 0;
29
30 [[nodiscard]] RuntimeBaseType getBaseType() const override {
31 return RuntimeBaseType::DYNAMIC_OBJECT;
32 }
33
34 // Constructor takes a callable to implement the draw method
36 void (*drawFunction)(float , float),
37 void (*blackOutFunction)(float , float),
38 void (*boundaryUpdateFunction)(Boundaries&, Vector&),
39 float x,
40 float y
41 )
42 : drawFunction(drawFunction), blackOutFunction(blackOutFunction), updateBoundaryFunction(boundaryUpdateFunction), s(Vector(x, y)) {
43 }
44
45 // Override the draw method from the base class
46 void draw() const override {
47 drawFunction(s.x, s.y);
48 }
49
50 void blackOut() const {
51 blackOutFunction(prev_x, prev_y);
52 }
53
54public:
55 void (*drawFunction)(float , float );
56 void (*blackOutFunction)(float , float );
57 void (*updateBoundaryFunction)(Boundaries&, Vector&);
58 Boundaries boundaries;
59};
60
61
62#endif //PHYZIX_DYNAMICOBJECT_H
Definition Drawable.h:11
Definition DynamicObject.h:16
Enum class to identify the base type of a class for runtime type identification.
Definition Vector.h:12
A struct to hold a list of boundaries.
Definition Boundary.h:21