Skip to content

Commit cda845f

Browse files
committed
[template] use Camera2D
1 parent f74ac34 commit cda845f

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/template.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ void plug_update(Env env)
7070

7171
ClearBackground(background_color);
7272

73-
const char *text = "Panim Template";
74-
Vector2 text_size = MeasureTextEx(p->font, text, FONT_SIZE, 0);
75-
76-
Vector2 position = {env.screen_width/2, env.screen_height/2};
77-
position = Vector2Subtract(position, Vector2Scale(text_size, 0.5));
78-
DrawTextEx(p->font, text, position, FONT_SIZE, 0, foreground_color);
73+
Camera2D camera = {
74+
.zoom = 1.0,
75+
.offset = {env.screen_width/2, env.screen_height/2},
76+
};
77+
BeginMode2D(camera);
78+
const char *text = "Panim Template";
79+
Vector2 text_size = MeasureTextEx(p->font, text, FONT_SIZE, 0);
80+
Vector2 position = Vector2Scale(text_size, -0.5);
81+
DrawTextEx(p->font, text, position, FONT_SIZE, 0, foreground_color);
82+
EndMode2D();
7983
}
8084

8185
bool plug_finished(void)

0 commit comments

Comments
 (0)