zephr/game: various fixes and improvements

- zephr: handle newlines in text
- fix(zephr): don't overflow color channels bytes when multiplying
  colors
- fix(zephr): don't fallback to UI_CONSTRAINT_FIXED when setting the x
  or y constraint to UI_CONSTRAINT_RELATIVE_PIXELS
- game: added how to play dialog
- game: ability to start a new game
This commit is contained in:
2023-12-29 15:12:43 +02:00
parent 31f22a4ba7
commit e543b5f882
8 changed files with 322 additions and 223 deletions
+6 -2
View File
@@ -43,7 +43,6 @@ void set_parent_constraint(UIConstraints *constraints, UIConstraints *parent_con
void set_x_constraint(UIConstraints *constraints, float value, UIConstraint type) {
switch (type) {
case UI_CONSTRAINT_RELATIVE_PIXELS:
case UI_CONSTRAINT_ASPECT_RATIO:
// no-op. fallback to FIXED
case UI_CONSTRAINT_FIXED:
@@ -52,6 +51,9 @@ void set_x_constraint(UIConstraints *constraints, float value, UIConstraint type
case UI_CONSTRAINT_RELATIVE:
constraints->x = (value * zephr_ctx->window.size.width);
break;
case UI_CONSTRAINT_RELATIVE_PIXELS:
constraints->x = zephr_ctx->window.size.width / (float)zephr_ctx->screen_size.width * value;
break;
}
if (constraints->parent) {
@@ -61,7 +63,6 @@ void set_x_constraint(UIConstraints *constraints, float value, UIConstraint type
void set_y_constraint(UIConstraints *constraints, float value, UIConstraint type) {
switch (type) {
case UI_CONSTRAINT_RELATIVE_PIXELS:
case UI_CONSTRAINT_ASPECT_RATIO:
// no-op. fallback to FIXED
case UI_CONSTRAINT_FIXED:
@@ -70,6 +71,9 @@ void set_y_constraint(UIConstraints *constraints, float value, UIConstraint type
case UI_CONSTRAINT_RELATIVE:
constraints->y = (value * zephr_ctx->window.size.height);
break;
case UI_CONSTRAINT_RELATIVE_PIXELS:
constraints->y = zephr_ctx->window.size.height / (float)zephr_ctx->screen_size.height * value;
break;
}
if (constraints->parent) {