Building a flexible stock allocation system in pure ECS

In this post, I’ll walk through the design of a flexible stock allocation system built using pure ECS principles in C++ (with ENTT). We’ll go from problem definition to implementation details, discussing elasticity, priorities, and resource management in a simulation-like environment.

From time to time, I start a new project only to abandon it a few weeks later. That’s been my life for the last 20 years, I’ve grown to accept that I rarely finish them.

I started a new one this weekend. It’s going to be different this time (no, it won’t), and I’ve decided that even if I’m not going to finish it (yes, I won’t), my effort will still be worth it if I can at least extract a few posts for my fancy blog. So here we are.

I’ve been obsessed with Shadow Empire and Aurora 4x for years, and I’ve finally decided to build my own (as an MMORTS, just as God intended, because I’ll probably abandon ship eventually anyway, so… why not?).

Here I am, documenting my journey and sharing my work. Enjoy my failure. ❤

Continue reading “Building a flexible stock allocation system in pure ECS”

Deep-diving into Entity Component System (ECS) Architecture and Data Oriented Programming

1–2 minutes

Some years ago I wrote the first article about ECS, at that time, in a comment, someone suggested that my solution was closer to a standard CS than to a real ECS.
Unfortunately for me, that anonymous internet person was right.

Entity component system (ECS) is an architectural design pattern used primarily in video game development. This pattern differs significantly from object-oriented programming (OOP), which has been the dominant paradigm in software programming for decades.

ECS offers significant advantages in video game development, especially in terms of flexibility, performance and ease of maintenance. This architecture is well suited to the dynamic and often complex needs of modern games, greatly facilitating phases as essential as complex as the prototyping of new features.

Continue reading “Deep-diving into Entity Component System (ECS) Architecture and Data Oriented Programming”

How to write a game engine in pure C: Part 3 – The Engine Entity

If you haven’t read the other posts, go now:

This is the third post of the series and it might be the less appealing, but it’ll set the foundations for all the system that we are to build.

Every software piece should have an architecture to keep the code clean and tidy with it’s modules where they belong, and a game engine is no more than a piece of software, so here we are.

Continue reading “How to write a game engine in pure C: Part 3 – The Engine Entity”

How to write a game engine in pure C: Part 2 – The Graphic initialization

If you haven’t read the other posts, go now:

 

We have a state manager now but a game without graphic representation and user interaction has nothing to do in 2019.
In this new chapter we will initialize the ‘human’ layer: graphics and input.

We could write everything from scratch but it’s a pain in the ass (trust me) so we will use SDL to do so. SDL is an abstraction library written in C that gives a common API to system calls for different architectures and OSs.
We don’t want to couple our engine to a library too much, and we will cover that in future posts, but for now we will use SDL tightly coupled, don’t worry, it wont stay like this forever.

Continue reading “How to write a game engine in pure C: Part 2 – The Graphic initialization”

Hiding malware in Windows – The basics of code injection

There are hundreds of teams working professionally trying to break into any single digital device to compromise sensitive data leaving no fingerprint.Malware industry is bigger than you might think, more than 4,000 ransom-ware attacks have occurred every day since the beginning of 2016 and much more general system vulnerations.

I remember viruses in Win95 where you got a freeze screen, a broken OS or a BSOD; that’s not the case anymore, today access violations leave no trace and usually patches the vulnerabilities behind them so no other malware can take control of the system.
A guy i met once told me that “the best AV you could ever have is a harmless virus”, I don’t fully agree, but that sentence hides a bit of truth.

But, how can this malicious code run freely in a host machine without the user noticing?
Continue reading “Hiding malware in Windows – The basics of code injection”

How to parse key-value strings into associative arrays in ANSI C89

We all know that C is one of the best languages for many reasons and especially the ANSI C89 standard (old and solid as fuck) but it also has it’s own drawbacks. There are many situtations in software development where inbuilt data structures can’t suit the programer’s needs and in a language like C, where there are not as many options to choose from (without relying on glibc or similar) as you can have in python or javascript, sometimes the solution can get really hard to figure out.
Continue reading “How to parse key-value strings into associative arrays in ANSI C89”

Microservices: the wrong approach to the right idea

If you have been in the business for the last 5-6 years you have been indefinitely forced to hear some buzzwords like microservices, modularization, loosely coupled, split or independence popping up in every single company, but are those concepts even in context?

Continue reading “Microservices: the wrong approach to the right idea”

Event-driven programming with C 89

As you may know, C is not a dynamic language by default, the behaviour of this marvelous technology tends to be imperative and sequential, we tend to manage the software’s flow by using callbacks or conditional statements and other techniques like  event-driven are not usually used, but, does it means that it’s not possible?

Continue reading “Event-driven programming with C 89”

How does a CPU work?

The CPU (Central processing unit) is the brain of all systems, it takes instructions as simple as electric variations and performs complex tasks by running electricity through circuits, but, how do they do it?

Not even engineers knows exactly how a CPU works, indeed, I’ve meet very few people (Developer, analyst, Architect or IT) who knows exactly how electricity is evaluated in a logical way to perform concrete calculations in order to run a digitally written program.

Can you even imagine how your computer performs a Node javascript file execution? I bet not…

Continue reading “How does a CPU work?”

Design a site like this with WordPress.com
Get started