Remove Lt from Credits

master
rexim 2020-01-06 08:37:49 +07:00
parent 85503090d9
commit 8baadcceb5
8 changed files with 28 additions and 46 deletions

View File

@ -27,7 +27,7 @@ typedef struct Game {
Memory tmpmem;
LevelPicker level_picker;
LevelEditor level_editor;
Credits *credits;
Credits credits;
Level *level;
Settings settings;
Sound_samples *sound_samples;
@ -73,13 +73,7 @@ Game *create_game(const char *level_folder,
level_picker_populate(&game->level_picker, level_folder);
game->credits = PUSH_LT(
lt,
create_credits(),
destroy_credits);
if (game->credits == NULL) {
RETURN_LT(lt, NULL);
}
game->credits = create_credits();
game->sound_samples = PUSH_LT(
lt,
@ -163,7 +157,7 @@ int game_render(const Game *game)
} break;
case GAME_STATE_CREDITS: {
if (credits_render(game->credits, &game->camera) < 0) {
if (credits_render(&game->credits, &game->camera) < 0) {
return -1;
}
} break;
@ -263,7 +257,7 @@ int game_update(Game *game, float delta_time)
} break;
case GAME_STATE_CREDITS: {
if (credits_update(game->credits, &game->camera, delta_time) < 0) {
if (credits_update(&game->credits, &game->camera, delta_time) < 0) {
return -1;
}
} break;

View File

@ -11,43 +11,17 @@
#define TITLE_MARGIN_TOP 100.0f
struct Credits
Credits create_credits(void)
{
Lt *lt;
Background background;
Vec2f camera_position;
WigglyText wiggly_text;
};
Credits *create_credits(void)
{
Lt *lt = create_lt();
Credits *credits = PUSH_LT(
lt,
nth_calloc(1, sizeof(Credits)),
free);
if (credits == NULL) {
RETURN_LT(lt, NULL);
}
credits->lt = lt;
credits->background = create_background(hexstr("250741"));
credits->camera_position = vec(0.0f, 0.0f);
credits->wiggly_text = (WigglyText) {
Credits result;
result.background = create_background(hexstr("250741"));
result.camera_position = vec(0.0f, 0.0f);
result.wiggly_text = (WigglyText) {
.text = "Twitch Subs/Contributors",
.scale = {8.0f, 8.0f},
.color = COLOR_WHITE,
};
return credits;
}
void destroy_credits(Credits *credits)
{
trace_assert(credits);
RETURN_LT0(credits->lt);
return result;
}
int credits_render(const Credits *credits, const Camera *camera)

View File

@ -4,15 +4,22 @@
#include <SDL.h>
#include "game/camera.h"
#include "game/level/background.h"
#include "ui/wiggly_text.h"
typedef struct Credits Credits;
typedef struct {
Background background;
Vec2f camera_position;
WigglyText wiggly_text;
} Credits;
Credits *create_credits(void);
Credits create_credits(void);
void destroy_credits(Credits *credits);
int credits_render(const Credits *credits,
const Camera *camera);
int credits_update(Credits *credits,
Camera *camera, float dt);
Camera *camera, float dt);
#endif // CREDITS_H_

View File

@ -6,6 +6,7 @@
#include "game/camera.h"
#include "game/level/player.h"
#include "game/sound_samples.h"
#include "game/level/level_editor/point_layer.h"
#include "config.h"
typedef struct Goals Goals;

View File

@ -4,6 +4,7 @@
#include "math/vec.h"
#include "color.h"
#include "config.h"
#include "game/level/level_editor/label_layer.h"
typedef struct Labels Labels;

View File

@ -27,7 +27,6 @@
#define LEVEL_EDITOR_NOTICE_SCALE vec(10.0f, 10.0f)
#define LEVEL_EDITOR_NOTICE_DURATION 1.0f
#define LEVEL_EDITOR_NOTICE_PADDING_TOP 100.0f
#define LEVEL_EDITOR_TMPMEM_CAPACITY (640 * KILO)
static int level_editor_dump(LevelEditor *level_editor);

View File

@ -4,6 +4,9 @@
#include "layer.h"
#include "color.h"
#include "math/vec.h"
#include "dynarray.h"
#include "game/level/level_editor/color_picker.h"
#include "ui/edit_field.h"
#define LABELS_SIZE vec(2.0f, 2.0f)
#define LABEL_LAYER_ID_MAX_SIZE 36

View File

@ -4,6 +4,9 @@
#include "math/vec.h"
#include "color.h"
#include "layer.h"
#include "dynarray.h"
#include "game/level/level_editor/color_picker.h"
#include "ui/edit_field.h"
#define ID_MAX_SIZE 36