+static void on_collect_win(jumpnrun_item *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv) {
+ (void) lv;
+ self->flags |= JUMPNRUN_ITEM_COLLECTED;
+ state->flags |= JUMPNRUN_STATE_WON;
+}
+
+static void on_collect_checkpoint(jumpnrun_item *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv) {
+ (void) state;
+ self->flags |= JUMPNRUN_ITEM_COLLECTED;
+ lv->start_pos = (vec2d) { self->pos.x,
+ fixed_point_sub(fixed_point_add(self->pos.y, FIXED_INT(self->type->sprite.height)), jumpnrun_player_extents().y)
+ };
+}
+
+static void on_collect_key(jumpnrun_item *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv) {
+ (void) lv;
+ self->flags |= JUMPNRUN_ITEM_COLLECTED;
+ ++state->player.keys;
+}
+
+static void on_collect_encrypted(jumpnrun_item *self,
+ jumpnrun_game_state *state,
+ jumpnrun_level *lv) {
+ if(state->player.keys != 0) {
+ on_collect_win(self, state, lv);
+ }