malena
Why malena
Quick start
Tutorials
API docs
GitHub
GitHub
Tutorials
Loading...
Searching...
No Matches
ECS
System
MovementSystem.h
Go to the documentation of this file.
1
//
2
// Created by Dave Smith on 3/11/25.
3
//
4
5
#ifndef MOVEMENTSYSTEM_H
6
#define MOVEMENTSYSTEM_H
7
8
#pragma once
9
10
#include <unordered_map>
11
#include <vector>
12
13
#include "
Core/ECSManager.h
"
14
#include "
Core/EntitiesAndComponents.h
"
15
namespace
ml
16
{
21
class
MovementSystem
22
{
23
public
:
24
static
void
update
(
ECSManager
&ecs,
const
float
deltaTime)
25
{
26
for
(
auto
&[entity, velocity] : ecs.
velocities
)
27
{
28
if
(ecs.
positions
.find(entity) != ecs.
positions
.end())
29
{
30
ecs.
positions
[entity].x += velocity.vx * deltaTime;
31
ecs.
positions
[entity].y += velocity.vy * deltaTime;
32
}
33
}
34
}
35
};
36
}
37
#endif
// MOVEMENTSYSTEM_H
ECSManager.h
EntitiesAndComponents.h
ml::ECSManager
ECSManager.
Definition
ECSManager.h:23
ml::ECSManager::positions
std::unordered_map< Entity, PositionComponent > positions
Definition
ECSManager.h:25
ml::ECSManager::velocities
std::unordered_map< Entity, VelocityComponent > velocities
Definition
ECSManager.h:26
ml::MovementSystem
MovementSystem.
Definition
MovementSystem.h:22
ml::MovementSystem::update
static void update(ECSManager &ecs, const float deltaTime)
Definition
MovementSystem.h:24
ml
Definition
Component.h:18
Generated by
1.16.1