suicmez/game/inc/suic_gameplay.c
2025-12-20 17:11:21 +05:30

39 lines
No EOL
1 KiB
C

#include "suic_app.h"
// #include "runtime.h" // Not available
#include <math.h>
const char* suic_item_name(uint8_t t) {
if (t == 1) return "Medkit";
if (t == 2) return "Pistol ammo";
if (t == 3) return "Rifle ammo";
return "-";
}
struct Color* suic_apply_directional_lighting(
struct Color* baseColor,
struct Vector3* normal,
struct DirectionalLight* light
) {
struct Vector3* lightDir = light->direction;
float diff = fmaxf(
0.0f,
-(lightDir->x * normal->x +
lightDir->y * normal->y +
lightDir->z * normal->z)
);
float brightness =
light->ambientIntensity +
diff * light->intensity * (1.0f - light->ambientIntensity);
uint8_t r = (uint8_t)(baseColor->r * brightness);
uint8_t g = (uint8_t)(baseColor->g * brightness);
uint8_t b = (uint8_t)(baseColor->b * brightness);
return suic_alloc_struct(
&sui_typeinfo_Color,
sizeof(struct Color),
&(struct Color){ r, g, b, baseColor->a }
);
}