jakubg1 / OpenSMCE

Game engine which allows creating a broad range of marble popper games.
MIT License
14 stars 11 forks source link

Replace missing sprites with solid color rects as an optional flag #74

Open ShamblesSM opened 1 year ago

ShamblesSM commented 1 year ago

If it's possible to add flags to the executable, something like no-crash-on-missing-texture would work. I'm not too sure what use this would be but it would probably be too annoying when experimenting with the framework.

The flag should only be exclusive to OpenSMCE and not when releasing a game. Missing textures should be still logged in the console (and maybe show the nonexistent path when hovered).

jakubg1 commented 1 year ago

Yes, it's possible to add flags to the executable. The problem with missing sprites is that we don't know their size - most objects in the engine which are rendered by sprites have an undefined size and are rendered with their natural size, defined in their sprite or inferred from the image size. Thus, we don't really know how big the rectangle should be in order to be drawn on the screen. It can be as small as a single sphere, or as big as an UI dialog background. I like the idea of logging missing assets instead of crashing - this way, we can pinpoint multiple problems in a single launch, rather than dealing with problems one by one. In far future, there are plans to make a tool which would check the integrity of game files and log all paths to missing stuff, errors in files, unused assets, etc. These are far plans, though. For now, due to the aforementioned problem, I have no immediate solution to this problem. Will however consider adding it in the future.

ShamblesSM commented 1 year ago

...most objects in the engine which are rendered by sprites have an undefined size and are rendered with their natural size, defined in their sprite or inferred from the image size. Thus, we don't really know how big the rectangle should be in order to be drawn on the screen. It can be as small as a single sphere, or as big as an UI dialog background.

They could be a 32x32 px rect. It could also be a placeholder checkerboard texture even.

jakubg1 commented 1 year ago

Alright, works for me if it's going to be just a marker which is like "if you see me, you have a serious problem to deal with, check log". I think ResourceManager could handle stuff like that, but the exact implementation is up to discussion.