stuff
This commit is contained in:
parent
1006b231f0
commit
0c0cfef186
28 changed files with 220 additions and 331 deletions
39
game/inc/suic_gameplay.c
Normal file
39
game/inc/suic_gameplay.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#include "suic_app.h"
|
||||
#include "runtime.h"
|
||||
#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 }
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue