|
|
@@ -36,14 +36,51 @@ void get_cur_state(GameState *cur_state)
|
|
|
|
|
|
cur_state->text = strdup("Hello, World!");
|
|
|
cur_state->text_color = RAYWHITE;
|
|
|
- cur_state->text_size = 30;
|
|
|
+ cur_state->text_size = 32;
|
|
|
+
|
|
|
|
|
|
- /*
|
|
|
cur_state->layers[0].img = LoadTexture("assets/spiral_atlas/bedroom.jpg");
|
|
|
cur_state->layers[0].pos = (Vector2){0.5, 0.5};
|
|
|
cur_state->layers[1].img = LoadTexture("assets/sumi/smile.png");
|
|
|
- cur_state->layers[1].pos = (Vector2){0.5, 0.5}; */
|
|
|
- cur_state->layers_count = 0;
|
|
|
+ cur_state->layers[1].pos = (Vector2){0.5, 0.5};
|
|
|
+ cur_state->layers_count = 2;
|
|
|
+}
|
|
|
+
|
|
|
+int DrawTextBoxed(const char *text, int font_size, int x, int y,
|
|
|
+ bool is_centered, int width, int height)
|
|
|
+{
|
|
|
+ if (text == NULL || text[0] == '\0') return 1;
|
|
|
+ int text_width = MeasureText(text, font_size);
|
|
|
+ int new_fs = font_size;
|
|
|
+ while (text_width > width && new_fs > 8) {
|
|
|
+ new_fs--;
|
|
|
+ text_width = MeasureText(text, new_fs);
|
|
|
+ }
|
|
|
+ int new_x = x;
|
|
|
+ if (is_centered)
|
|
|
+ new_x = x + (width - text_width) / 2;
|
|
|
+ DrawText(text, new_x, y, new_fs, RAYWHITE);
|
|
|
+
|
|
|
+ printf("H: %d W: %d TW:%d\n", height, width, text_width);
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+int DrawTextbox(GameState *cur_state, int pad, int screenWidth,
|
|
|
+ int screenHeight)
|
|
|
+{
|
|
|
+ DrawRectangle(screenWidth/10, screenHeight/5 * 4 - 10,
|
|
|
+ screenWidth * 4 / 5, screenHeight / 5,
|
|
|
+ (Color){0, 0, 0, 150});
|
|
|
+ DrawTextBoxed(cur_state->name, cur_state->name_size,
|
|
|
+ screenWidth/10 + pad, screenHeight/5 * 4 - 10 + pad, true,
|
|
|
+ screenWidth * 4 / 5 - pad * 2, screenHeight / 5 - pad *2);
|
|
|
+ DrawTextBoxed(cur_state->text, cur_state->text_size,
|
|
|
+ screenWidth/10 + pad, screenHeight/5*4 + pad +
|
|
|
+ cur_state->name_size*2, false,
|
|
|
+ screenWidth * 4 / 5 - pad * 2, screenHeight / 5 - pad *2);
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
int main(void)
|
|
|
@@ -53,7 +90,7 @@ int main(void)
|
|
|
const int screenHeight = 1080;
|
|
|
|
|
|
SetConfigFlags(FLAG_FULLSCREEN_MODE);
|
|
|
- SetTraceLogLevel(LOG_ERROR);
|
|
|
+ //SetTraceLogLevel(LOG_ERROR);
|
|
|
InitWindow(screenWidth, screenHeight,
|
|
|
"Vinora Engine");
|
|
|
|
|
|
@@ -66,7 +103,7 @@ int main(void)
|
|
|
perror("assets/test.vnrs");
|
|
|
return 2;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
while (!WindowShouldClose())
|
|
|
{
|
|
|
if (IsKeyPressed(KEY_SPACE))
|
|
|
@@ -83,17 +120,7 @@ int main(void)
|
|
|
cur_state.layers[i].img.height / 2,
|
|
|
RAYWHITE);
|
|
|
}
|
|
|
- DrawRectangle(screenWidth/10, screenHeight/5 * 4 - 10,
|
|
|
- screenWidth * 4 / 5, screenHeight / 5,
|
|
|
- (Color){0, 0, 0, 150});
|
|
|
- DrawText(cur_state.name, screenWidth/2 -
|
|
|
- (strlen(cur_state.name)*cur_state.name_size/2)/2,
|
|
|
- screenHeight/5*4,
|
|
|
- cur_state.name_size, cur_state.name_color);
|
|
|
- DrawText(cur_state.text, screenWidth/2 -
|
|
|
- (strlen(cur_state.text)*cur_state.text_size/2)/2,
|
|
|
- screenHeight/5*4.5,
|
|
|
- cur_state.text_size, cur_state.text_color);
|
|
|
+ DrawTextbox(&cur_state, 20, screenWidth, screenHeight);
|
|
|
DrawFPS(5, 5);
|
|
|
|
|
|
EndDrawing();
|
|
|
@@ -107,7 +134,7 @@ int main(void)
|
|
|
f = fopen("assets/test.vnrs", "r");
|
|
|
if (!f) {
|
|
|
perror("assets/test.vnrs");
|
|
|
- return 2;
|
|
|
+ return 2;
|
|
|
}
|
|
|
|
|
|
parse_vnrs(f, stdout);
|