feat: add wake, rose, terrain, pathfinding, gameover, clouds, enemy shooting, variable bird speed refactor: some things

This commit is contained in:
2026-09-19 13:17:46 +02:00
parent c80b4887e9
commit a2ffb45fc5
49 changed files with 3002 additions and 1178 deletions
+42 -25
View File
@@ -1,36 +1,53 @@
#include "engine.h"
#include "enginePostfx.h"
PostProcessing CreatePostFX(const char* shaderPath){
PostProcessing postFX = {0};
postFX.shader = LoadShader(NULL, shaderPath);
#include <stddef.h>
if (postFX.shader.id == 0) {
TraceLog(LOG_ERROR, "Failed to load shader: %s", shaderPath);
return postFX;
}
PostProcessing CreatePostFX(const char *shaderPath) {
PostProcessing postFX = {0};
postFX.shader = LoadShader(NULL, shaderPath);
postFX.strength = 0.0f;
postFX.resolutionLoc = GetShaderLocation(postFX.shader, "resolution");
postFX.strengthLoc = GetShaderLocation(postFX.shader, "strength");
Vector2 resolution = { (float)GetScreenWidth(), (float)GetScreenHeight() };
SetShaderValue(postFX.shader, postFX.resolutionLoc, &resolution, SHADER_UNIFORM_VEC2);
if (postFX.shader.id == 0) {
TraceLog(LOG_ERROR, "Failed to load shader: %s", shaderPath);
return postFX;
}
postFX.strength = 0.0f;
postFX.time = 0.0f;
postFX.resolutionLoc = GetShaderLocation(postFX.shader, "resolution");
postFX.strengthLoc = GetShaderLocation(postFX.shader, "strength");
postFX.timeLoc = GetShaderLocation(postFX.shader, "time");
Vector2 resolution = {(float)GetScreenWidth(), (float)GetScreenHeight()};
SetShaderValue(postFX.shader, postFX.resolutionLoc, &resolution, SHADER_UNIFORM_VEC2);
return postFX;
}
void UpdatePostFX(PostProcessing *postFX){
if (postFX->shader.id == 0) return;
SetShaderValue(postFX->shader, postFX->strengthLoc, &postFX->strength, SHADER_UNIFORM_FLOAT);
Vector2 resolution = { (float)GetScreenWidth(), (float)GetScreenHeight() };
SetShaderValue(postFX->shader, postFX->resolutionLoc, &resolution, SHADER_UNIFORM_VEC2);
void UpdatePostFX(PostProcessing *postFX) {
if (postFX->shader.id == 0)
return;
SetShaderValue(postFX->shader, postFX->strengthLoc, &postFX->strength, SHADER_UNIFORM_FLOAT);
Vector2 resolution = {(float)GetScreenWidth(), (float)GetScreenHeight()};
SetShaderValue(postFX->shader, postFX->resolutionLoc, &resolution, SHADER_UNIFORM_VEC2);
if (postFX->timeLoc != -1) {
postFX->time += GetFrameTime();
SetShaderValue(postFX->shader, postFX->timeLoc, &postFX->time, SHADER_UNIFORM_FLOAT);
}
}
void RenderPostFX(PostProcessing *postFX, RenderTexture2D *target){
BeginShaderMode(postFX->shader);
DrawTextureRec(target->texture, (Rectangle){ 0, 0, target->texture.width, -target->texture.height }, (Vector2){ 0, 0 }, WHITE);
EndShaderMode();
void UpdateShaders(PostProcessing *postFX, int count) {
for (int i = 0; i < count; i++) {
UpdatePostFX(&postFX[i]);
}
}
void UnloadPostFX(PostProcessing *postFX){
if (postFX->shader.id == 0) return;
UnloadShader(postFX->shader);
void RenderPostFX(PostProcessing *postFX, RenderTexture2D *target) {
BeginShaderMode(postFX->shader);
DrawTextureRec(target->texture, (Rectangle){0, 0, target->texture.width, -target->texture.height},
(Vector2){0, 0}, WHITE);
EndShaderMode();
}
void UnloadPostFX(PostProcessing *postFX) {
if (postFX->shader.id == 0)
return;
UnloadShader(postFX->shader);
}