rework to context: now there's engine and user code copies, renaming of fields, most things that shouldn't be there are hidden
This commit is contained in:
@ -17,8 +17,8 @@ static void ingame_tick(State *state) {
|
||||
|
||||
if (input_is_mouse_captured()) {
|
||||
const float sensitivity = 0.6f; /* TODO: put this in a better place */
|
||||
scn->yaw += (float)ctx.mouse_relative_position.x * sensitivity;
|
||||
scn->pitch -= (float)ctx.mouse_relative_position.y * sensitivity;
|
||||
scn->yaw += (float)ctx.mouse_movement.x * sensitivity;
|
||||
scn->pitch -= (float)ctx.mouse_movement.y * sensitivity;
|
||||
scn->pitch = clampf(scn->pitch, -89.0f, 89.0f);
|
||||
|
||||
const float yaw_rad = scn->yaw * (float)DEG2RAD;
|
||||
@ -62,8 +62,8 @@ static void ingame_tick(State *state) {
|
||||
|
||||
for (int ly = 64; ly--;) {
|
||||
for (int lx = 64; lx--;) {
|
||||
float x = SDL_truncf(scn->cam.pos.x + 32 - lx);
|
||||
float y = SDL_truncf(scn->cam.pos.z + 32 - ly);
|
||||
float x = SDL_truncf(scn->cam.pos.x + 32 - (float)lx);
|
||||
float y = SDL_truncf(scn->cam.pos.z + 32 - (float)ly);
|
||||
|
||||
float d0 = stb_perlin_noise3((float)x * TERRAIN_FREQUENCY, (float)y * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6;
|
||||
float d1 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)y * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6;
|
||||
@ -89,7 +89,7 @@ static void ingame_tick(State *state) {
|
||||
}
|
||||
|
||||
draw_skybox("/assets/miramar/miramar_*.tga");
|
||||
draw_fog(0.9, 1.0, 0.05, (Color){ 140, 147, 160, 255 });
|
||||
draw_fog(0.9f, 1.0f, 0.05f, (Color){ 140, 147, 160, 255 });
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,15 +16,13 @@ static void title_tick(State *state) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
m_sprite("/assets/title.png", ((Rect) {
|
||||
((float)ctx.base_draw_w / 2) - ((float)320 / 2), 64, 320, 128 }));
|
||||
|
||||
|
||||
((float)ctx.resolution.x / 2) - ((float)320 / 2), 64, 320, 128 }));
|
||||
|
||||
/* draw the tick count as an example of dynamic text */
|
||||
size_t text_str_len = snprintf(NULL, 0, "%lu", state->ctx->tick_count) + 1;
|
||||
size_t text_str_len = snprintf(NULL, 0, "%lu", state->ctx->frame_number) + 1;
|
||||
char *text_str = cmalloc(text_str_len);
|
||||
snprintf(text_str, text_str_len, "%lu", state->ctx->tick_count);
|
||||
snprintf(text_str, text_str_len, "%lu", state->ctx->frame_number);
|
||||
|
||||
const char *font = "/fonts/kenney-pixel.ttf";
|
||||
int text_h = 32;
|
||||
@ -39,6 +37,7 @@ static void title_tick(State *state) {
|
||||
},
|
||||
(Color) { 0, 0, 0, 255 }
|
||||
);
|
||||
|
||||
draw_text(text_str, (Vec2){ 0, 0 }, text_h, (Color) { 255, 255, 255, 255 }, font);
|
||||
|
||||
free(text_str);
|
||||
|
Reference in New Issue
Block a user