Game Dev Journey #2
After 2 years, I’m not writing about my game dev journey LOL!
Game Dev Journey #2
After 2 years, I’m not writing about my game dev journey LOL!
Photo by Umberto on Unsplash
Hello! It’s been 2 years since my first Game Dev Journey #1. To be honest, I haven’t continued my game project from the previous story. So I might not be able to share much experience from my journey, but I will at least offer a meaningful lesson. In the previous story, we successfully rendered the circle ball. Now we will continue from that point.
Ball Movement
Since we have defined the ball's structure and integrated it using Flecs, we can use Flecs to change the ball's position.
void move_ball(
flecs::entity& ball,
const goblock::component::Position* position_ball,
const goblock::component::Velocity* velocity_ball,
const goblock::component::Direction* direction_ball)
{
ball.set<goblock::component::Position>({position_ball->x + velocity_ball->x, position_ball->y + velocity_ball->y});
ball.set<goblock::component::Direction>({direction_ball->x, direction_ball->y});
}
I create a function that accepts the current ball position, velocity, and the direction in which the ball will slide. ball parameter is a type of Flecs entity, so that we can utilize the .set method from Flecs to set the new value of the position and direction components. The components of the ball itself are just a public struct that we connect to Flecs.
struct Position {
public:
float x{};
float y{};
};
struct Velocity {
public:
float x{};
float y{};
};
struct Direction {
public:
float x{};
float y{};
};
To initialize the ball object with the components, we can use game_world.entity() method from Flecs.
auto object = game_world.entity("ball");
object.set<goblock::component::Position>({pos.x, pos.y});
object.set<goblock::component::SizeRectangle>({size.width, size.height});
object.set<goblock::component::Velocity>({vel.x, vel.y});
// use "object" anywhere
Every time we want to change the ball position, we can use the .set() method, and every time we want to know the current ball position, we can use the .get() method.
auto ball_velocity = ball.get<goblock::component::Velocity>();

메타데이터
- post_id
- 7bb1a2e0f1ca
- slug
- game-dev-journey-2-7bb1a2e0f1ca
- url
- https://medium.com/@mprtmma/game-dev-journey-2-7bb1a2e0f1ca
- canonical_url
- https://medium.com/@mprtmma/game-dev-journey-2-7bb1a2e0f1ca
- author_url
- https://medium.com/@mprtmma
- status
- ok
- fetched_at
- 2026-06-09 15:37:30