-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntity.cpp
More file actions
48 lines (37 loc) · 1.15 KB
/
Copy pathEntity.cpp
File metadata and controls
48 lines (37 loc) · 1.15 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
//
// Created by Louis-Philippe on 2/9/2026.
//
#include "Entity.h"
#include <random>
//Entity Conetient les components
void Entity::AddComponent(const Uint64 comps) {
flag |= comps;
}
bool Entity::HasComponent(const Uint64 comps) const {
return (flag & comps) == comps;
}
void Entity::RemoveComponent(const Uint64 comps) {
flag &= ~comps;
}
void Entity::MovementUpdate(float deltaTime) {
// Si l'entité a une position ET un mouvement, on bouge
if (HasComponent(TRANSFORM | MOVEMENT)) {
transform.position.x += movement.velocity.x * deltaTime;
transform.position.y += movement.velocity.y * deltaTime;
}
}
void Entity::HeightMovement(float deltaTime) {
}
void Entity::RenderUpdate(SDL_Renderer* renderer) {
// Si l'entité a une position ET doit être rendue
if (HasComponent(TRANSFORM | RENDER)) {
SDL_FRect dst = {
transform.position.x,
transform.position.y,
transform.size.x,
transform.size.y
};
SDL_SetRenderDrawColor(renderer, render.color.r, render.color.g, render.color.b, render.color.a);
SDL_RenderFillRect(renderer, &dst);
}
}