twn_rendering -> twn_draw

This commit is contained in:
2024-10-07 17:53:09 +03:00
parent 9353999a30
commit ade1af12ca
22 changed files with 238 additions and 186 deletions

View File

@ -252,7 +252,7 @@ static void drawdef(Player *player) {
.h = player->sprite_h,
});
push_circle((Vec2) { 256, 128 },
draw_circle((Vec2) { 256, 128 },
24,
(Color) { 255, 0, 0, 255 });
}
@ -268,10 +268,10 @@ static void drawdef_debug(Player *player) {
/* .r = 0, .g = 0, .b = 0, .a = 255, */
/* }; */
push_rectangle(player->collider_x,
draw_rectangle(player->collider_x,
(Color){ 0, 0, 255, 128 });
push_rectangle(player->collider_y,
draw_rectangle(player->collider_y,
(Color){ 0, 0, 255, 128 });
}

View File

@ -30,9 +30,9 @@ static void title_tick(State *state) {
const char *font = "fonts/kenney-pixel.ttf";
int text_h = 32;
int text_w = text_get_width(text_str, text_h, font);
int text_w = draw_text_width(text_str, text_h, font);
push_rectangle(
draw_rectangle(
(Rect) {
.x = 0,
.y = 0,
@ -41,7 +41,7 @@ static void title_tick(State *state) {
},
(Color) { 0, 0, 0, 255 }
);
push_text(
draw_text(
text_str,
(Vec2){ 0, 0 },
text_h,

View File

@ -39,7 +39,7 @@ static void drawdef_debug(struct World *world) {
for (size_t i = 0; i < world->tilemap_height * world->tilemap_width; ++i) {
if (world->tiles[i].type == TILE_TYPE_VOID) continue;
push_rectangle(to_frect(world->tiles[i].rect),
draw_rectangle(to_frect(world->tiles[i].rect),
(Color) { 255, 0, 255, 128 });
}
}

View File

@ -55,7 +55,7 @@ static void ingame_tick(State *state) {
input_set_mouse_captured(&ctx.input, !input_is_mouse_captured(&ctx.input));
}
set_camera(&scn->cam);
draw_camera(&scn->cam);
#define TERRAIN_FREQUENCY 0.1f
@ -69,7 +69,7 @@ static void ingame_tick(State *state) {
float d2 = stb_perlin_noise3((float)(x + 1) * TERRAIN_FREQUENCY, (float)(y - 1) * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6;
float d3 = stb_perlin_noise3((float)x * TERRAIN_FREQUENCY, (float)(y - 1) * TERRAIN_FREQUENCY, 0, 0, 0, 0) * 3 - 6;
unfurl_triangle("/assets/grass.png",
draw_triangle("/assets/grass.png",
(Vec3){ (float)x, d0, (float)y },
(Vec3){ (float)x + 1, d1, (float)y },
(Vec3){ (float)x, d3, (float)y - 1 },
@ -77,7 +77,7 @@ static void ingame_tick(State *state) {
(Vec2){ 128, 0 },
(Vec2){ 0, 128 });
unfurl_triangle("/assets/grass.png",
draw_triangle("/assets/grass.png",
(Vec3){ (float)x + 1, d1, (float)y },
(Vec3){ (float)x + 1, d2, (float)y - 1 },
(Vec3){ (float)x, d3, (float)y - 1 },
@ -87,8 +87,8 @@ static void ingame_tick(State *state) {
}
}
push_skybox("/assets/miramar/miramar_*.tga");
push_fog(0.9, 1.0, 0.05, (Color){ 140, 147, 160, 255 });
draw_skybox("/assets/miramar/miramar_*.tga");
draw_fog(0.9, 1.0, 0.05, (Color){ 140, 147, 160, 255 });
}

View File

@ -27,9 +27,9 @@ static void title_tick(State *state) {
const char *font = "/fonts/kenney-pixel.ttf";
int text_h = 32;
int text_w = text_get_width(text_str, text_h, font);
int text_w = draw_text_width(text_str, text_h, font);
push_rectangle(
draw_rectangle(
(Rect) {
.x = 0,
.y = 0,
@ -38,7 +38,7 @@ static void title_tick(State *state) {
},
(Color) { 0, 0, 0, 255 }
);
push_text(text_str, (Vec2){ 0, 0 }, text_h, (Color) { 255, 255, 255, 255 }, font);
draw_text(text_str, (Vec2){ 0, 0 }, text_h, (Color) { 255, 255, 255, 255 }, font);
free(text_str);
}

View File

@ -108,7 +108,7 @@ static Color table_to_color(lua_State *L, int idx) {
static int b_sprite(lua_State *L) {
luaL_checktype(L, 1, LUA_TTABLE);
PushSpriteArgs args = { 0 };
DrawSpriteArgs args = { 0 };
lua_getfield(L, 1, "path");
const char *field_path = lua_tostring(L, -1);
@ -157,7 +157,7 @@ static int b_sprite(lua_State *L) {
args.stretch_opt_set = true;
}
push_sprite(args);
draw_sprite_args(args);
return 0;
}
@ -181,7 +181,7 @@ static int b_rectangle(lua_State *L) {
if (lua_istable(L, -1))
color = table_to_color(L, -1);
push_rectangle(rect, color);
draw_rectangle(rect, color);
return 0;
}
@ -227,7 +227,7 @@ static int b_text(lua_State *L) {
if (font == NULL)
luaL_error(L, "bad field 'font' in 'data' (string expected, got %s)", luaL_typename(L, -1));
push_text(string, (Vec2) { x, y }, height_px, color, font);
draw_text(string, (Vec2) { x, y }, height_px, color, font);
return 0;
}