label_double_jump 950.930298 -279.062897 fffda5
Double Jump
4
-script_goal_1 659.885925 -301.853394 904.875000 333.048859 deaa87
+script_goal_1 659.885925 -301.853394 904.875000 333.048859 deaa87 2 goal1
script_show_goal_2 1249.832397 -862.224976 323.924408 544.635071 deaa87
-script_hide_label_double_jump 1033.862549 -862.224976 215.969864 569.733276 d35f5f 1 label_double_jump
+script_hide_label_double_jump 1033.862549 -862.224976 215.969864 569.733276 d35f5f 1 label_double_jump
hide_wasd_script 260.383636 24.900909 125.925934 209.259262 a1e764 1 label_wasd
21
;; TODO(#1106): level 01 functionality that was provided by script doesn't work anymore
lt,
create_regions_from_rect_layer(
level_editor->regions_layer,
- level->labels),
+ level->labels,
+ level->goals),
destroy_regions);
if (level->regions == NULL) {
RETURN_LT(lt, NULL);
rigid_bodies_collide(level->rigid_bodies, level->platforms);
- player_hide_goals(level->player, level->goals);
player_die_from_lava(level->player, level->lava);
regions_player_enter(level->regions, level->player);
regions_player_leave(level->regions, level->player);
typedef enum {
ACTION_NONE = 0,
- ACTION_HIDE_LABEL
+ ACTION_HIDE_LABEL,
+ ACTION_TOGGLE_GOAL,
} ActionType;
typedef struct {
ActionType type;
- char label_id[ENTITY_MAX_ID_SIZE];
+ char entity_id[ENTITY_MAX_ID_SIZE];
} Action;
#endif // ACTION_H_
#include "system/str.h"
#define GOAL_RADIUS 10.0f
-#define GOAL_MAX_ID_SIZE 36
static int goals_is_goal_hidden(const Goals *goals, size_t i);
Cue_state *cue_states;
bool *visible;
size_t count;
- Rect player_hitbox;
float angle;
};
RETURN_LT(lt, NULL);
}
for (size_t i = 0; i < goals->count; ++i) {
- goals->ids[i] = PUSH_LT(lt, nth_calloc(1, sizeof(char) * GOAL_MAX_ID_SIZE), free);
+ goals->ids[i] = PUSH_LT(lt, nth_calloc(1, sizeof(char) * ENTITY_MAX_ID_SIZE), free);
if (goals->ids[i] == NULL) {
RETURN_LT(lt, NULL);
}
for (size_t i = 0; i < goals->count; ++i) {
if (sscanf(
line_stream_next(line_stream),
- "%" STRINGIFY(GOAL_MAX_ID_SIZE) "s%f%f%6s",
+ "%" STRINGIFY(ENTITY_MAX_ID_SIZE) "s%f%f%6s",
goals->ids[i],
&goals->positions[i].x,
&goals->positions[i].y,
RETURN_LT(lt, NULL);
}
for (size_t i = 0; i < goals->count; ++i) {
- goals->ids[i] = PUSH_LT(lt, nth_calloc(1, sizeof(char) * GOAL_MAX_ID_SIZE), free);
+ goals->ids[i] = PUSH_LT(lt, nth_calloc(1, sizeof(char) * ENTITY_MAX_ID_SIZE), free);
if (goals->ids[i] == NULL) {
RETURN_LT(lt, NULL);
}
goals->angle = fmodf(goals->angle + 2.0f * delta_time, 2.0f * PI);
}
-void goals_hide_from_player(Goals *goals,
- Rect player_hitbox)
-{
- goals->player_hitbox = player_hitbox;
-
-}
-
int goals_sound(Goals *goals,
Sound_samples *sound_samples)
{
{
return !goals->visible[i];
}
+
+void goals_hide(Goals *goals, char goal_id[ENTITY_MAX_ID_SIZE])
+{
+ trace_assert(goals);
+ trace_assert(goal_id);
+
+ for (size_t i = 0; i < goals->count; ++i) {
+ if (strncmp(goal_id, goals->ids[i], ENTITY_MAX_ID_SIZE) == 0) {
+ goals->visible[i] = false;
+ }
+ }
+}
+
+void goals_show(Goals *goals, char goal_id[ENTITY_MAX_ID_SIZE])
+{
+ trace_assert(goals);
+ trace_assert(goal_id);
+ for (size_t i = 0; i < goals->count; ++i) {
+ if (strncmp(goal_id, goals->ids[i], ENTITY_MAX_ID_SIZE) == 0) {
+ goals->visible[i] = true;
+ }
+ }
+}
#include "game/camera.h"
#include "game/level/player.h"
#include "game/sound_samples.h"
+#include "config.h"
typedef struct Goals Goals;
typedef struct LineStream LineStream;
Sound_samples *sound_samples);
void goals_update(Goals *goals,
float delta_time);
-void goals_hide_from_player(Goals *goals,
- Rect player_hitbox);
void goals_checkpoint(const Goals *goals,
Player *player);
void goals_cue(Goals *goals,
const Camera *camera);
+void goals_hide(Goals *goals, char goal_id[ENTITY_MAX_ID_SIZE]);
+void goals_show(Goals *goals, char goal_id[ENTITY_MAX_ID_SIZE]);
+
#endif // GOALS_H_
if (sscanf(line, "%d%n", (int*)&action.type, &n) != EOF) {
line += n;
switch (action.type) {
+ case ACTION_NONE: break;
+
+ case ACTION_TOGGLE_GOAL:
case ACTION_HIDE_LABEL: {
- if (sscanf(line, "%"STRINGIFY(ENTITY_MAX_ID_SIZE)"s", action.label_id) == EOF) {
+ if (sscanf(line, "%"STRINGIFY(ENTITY_MAX_ID_SIZE)"s", action.entity_id) == EOF) {
log_fail("%s\n", strerror(errno));
RETURN_LT(layer->lt, NULL);
}
} break;
- default: {}
}
}
color_hex_to_stream(colors[i], filedump);
switch (actions[i].type) {
+ case ACTION_NONE: {} break;
+
+ case ACTION_TOGGLE_GOAL:
case ACTION_HIDE_LABEL: {
fprintf(filedump, " %d %.*s ",
(int)actions[i].type,
- ENTITY_MAX_ID_SIZE, actions[i].label_id);
+ ENTITY_MAX_ID_SIZE, actions[i].entity_id);
} break;
- default: {}
}
fprintf(filedump, "\n");
vec(0.0f, -player_hitbox.h * 0.5f)));
}
-void player_hide_goals(const Player *player,
- Goals *goals)
-{
- trace_assert(player);
- trace_assert(goals);
- goals_hide_from_player(
- goals,
- rigid_bodies_hitbox(
- player->rigid_bodies,
- player->alive_body_id));
-}
-
void player_die_from_lava(Player *player,
const Lava *lava)
{
void player_focus_camera(Player *player,
Camera *camera);
-void player_hide_goals(const Player *player,
- Goals *goal);
void player_die_from_lava(Player *player,
const Lava *lava);
#include "system/nth_alloc.h"
#include "game/level/level_editor/rect_layer.h"
#include "game/level/labels.h"
+#include "game/level/goals.h"
enum RegionState {
RS_PLAYER_OUTSIDE = 0,
Action *actions;
Labels *labels;
+ Goals *goals;
};
-Regions *create_regions_from_rect_layer(const RectLayer *rect_layer, Labels *labels)
+Regions *create_regions_from_rect_layer(const RectLayer *rect_layer,
+ Labels *labels,
+ Goals *goals)
{
trace_assert(rect_layer);
trace_assert(labels);
regions->labels = labels;
+ regions->goals = goals;
return regions;
}
player_overlaps_rect(player, regions->rects[i])) {
regions->states[i] = RS_PLAYER_INSIDE;
- if (regions->actions[i].type == ACTION_HIDE_LABEL) {
- labels_hide(regions->labels, regions->actions[i].label_id);
+ switch (regions->actions[i].type) {
+ case ACTION_HIDE_LABEL: {
+ labels_hide(regions->labels, regions->actions[i].entity_id);
+ } break;
+
+ case ACTION_TOGGLE_GOAL: {
+ goals_hide(regions->goals, regions->actions[i].entity_id);
+ } break;
+
+ default: {}
}
}
}
if (regions->states[i] == RS_PLAYER_INSIDE &&
!player_overlaps_rect(player, regions->rects[i])) {
regions->states[i] = RS_PLAYER_OUTSIDE;
+
+ switch (regions->actions[i].type) {
+ case ACTION_TOGGLE_GOAL: {
+ goals_show(regions->goals, regions->actions[i].entity_id);
+ } break;
+
+ default: {}
+ }
}
}
}
typedef struct Level Level;
typedef struct RectLayer RectLayer;
typedef struct Labels Labels;
+typedef struct Goals Goals;
-Regions *create_regions_from_rect_layer(const RectLayer *rect_layer, Labels *labels);
+Regions *create_regions_from_rect_layer(const RectLayer *rect_layer, Labels *labels, Goals *goals);
void destroy_regions(Regions *regions);
int regions_render(Regions *regions, const Camera *camera);