#include "background.h" #include "constants.h" #include #include #include void AddBackground(const char* backgroundTextureName) { Entity e = {0}; e.type = Background_Entity; e.flags |= ENTITY_VISIBLE; e.position = (Vector2) {0.0f, 0.0f}; Asset* backgroundTextureAsset = GetMatchingAssetWithType(backgroundTextureName, Texture_Asset); if (backgroundTextureAsset == NULL) { TraceLog(LOG_ERROR, "Failed to create background from texture asset: %s, asset not found", backgroundTextureName ); exit(EXIT_FAILURE); } Texture2D backgroundTexture = backgroundTextureAsset->texture; const float backgroundSizeScale = (float)WINDOW_HEIGHT / backgroundTexture.height; Vector2 backgroundBounds = Vector2Scale((Vector2) {backgroundTexture.width, backgroundTexture.height}, backgroundSizeScale); AddSpriteToEntity(&e, (Sprite){ .texture = backgroundTexture, .layer = Background_Layer, .destRect = {NO_OFFSET, NO_OFFSET, backgroundBounds.x, backgroundBounds.y} }); AddEntity(&e); }