0
\$\begingroup\$

I've been coding a small 2D platformer applying ECS pattern. However, I'm struggling with a issue. When building each platform from tilemap and such platforms need to be collided by other entities, are they considered as entity itself so that the respective system can handle such entities? For example: a platform must have a different behavior from other platforms even if it's in a fixed position like collisions, wet floor, etc.

My main concern is about performance and memory since the game is for very low-end devices (64MB in RAM, 333 MHz CPUs maximum), so due to the map being made with platforms (entity for each) using a collision system (verify if the player collides with map objs, etc) it could slow down the performance, couldn't it?

\$\endgroup\$
4
  • \$\begingroup\$ Why not? What alternatives do you have? \$\endgroup\$
    – Vaillancourt
    Commented Jan 12, 2022 at 19:20
  • \$\begingroup\$ Well, you are right, @Vaillancourt , maybe there are not much ways to do so but what I'm struggling with it's about performance and memory since I forgot to mention that the game is for device with 64MB in RAM and a CPU up to 333 MHz, so due to the map is made with platforms (entity for each) and there is a collision system, then verify if the player collides with map objs it could slow down the performance, couldn't it? \$\endgroup\$ Commented Jan 12, 2022 at 19:38
  • \$\begingroup\$ Sure, it could. Don't check collision with every platform in your level! If the player does not see the platform, it does not need to be checked against. A platform needs 4 values to decide where it is, so it's not a "big deal" as for space consumption, just that if you add more data to it, it could grow fast. You'll need to carefully design your levels. (Also, although a platform is graphically represented by multiple tiles, it does not need to be done so physically: a 4-tile wide platform only needs one "physical" representation which covers the whole thing.) \$\endgroup\$
    – Vaillancourt
    Commented Jan 12, 2022 at 19:59
  • 1
    \$\begingroup\$ @Vaillancourt thanks! I think that'd be it. Those last words gave me an idea I wouldn't have though with your support. I owe you a beer. \$\endgroup\$ Commented Jan 12, 2022 at 21:02

1 Answer 1

1
\$\begingroup\$

Is a platform an entity in 2D Platform in ECS pattern?

Yes, it is. *

Keep in mind that although you design your objects with tiles, only the graphical part needs to have "one sprite per tile". For example, although a platform is composed of four tiles, you do not have to have four physics "blocs" for this platform, you can extend a single physics box to four graphics boxes, this will 1) make your physics handling much easier, 2) reduce the amount of checks done, and 3) reduce the size taken by the physics objects.

Additionally, being a platformer, remember that the player will only see your character and what's around it; they don't care about what's not being shown on their screen, and so should you: when you check your character against other physics entities, you can completely and safely ignore what's not displayed, so this will speed up your physics loop.


* There is no ECS police so you can eventually decide whatever you want.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .