deleting walls
This commit is contained in:
parent
b7b8bd8b1e
commit
edbe4eb8ae
5 changed files with 22 additions and 0 deletions
|
|
@ -111,6 +111,16 @@ struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context) {
|
|||
return wall;
|
||||
}
|
||||
|
||||
void kubo_context_delete_wall(struct kubo_context *context) {
|
||||
if (context->state.id != KUBO_CONTEXT_WALL_SELECT ||
|
||||
!context->walls.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
kubo_wall_arr_del(&context->walls, context->wall_select_index);
|
||||
kubo_context_select_next_wall(context);
|
||||
}
|
||||
|
||||
void kubo_context_select_next_wall(struct kubo_context *context) {
|
||||
if (context->state.id != KUBO_CONTEXT_WALL_SELECT ||
|
||||
!context->walls.count) {
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ void kubo_context_set_state(struct kubo_context *context,
|
|||
void kubo_context_accept_cmd(struct kubo_context *context);
|
||||
|
||||
struct kubo_wall *kubo_context_get_pending_wall(struct kubo_context *context);
|
||||
void kubo_context_delete_wall(struct kubo_context *context);
|
||||
|
||||
void kubo_context_select_next_wall(struct kubo_context *context);
|
||||
void kubo_context_select_prev_wall(struct kubo_context *context);
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define KUBO_DRYNARRAY_DEFAULT_CAP 4
|
||||
|
||||
|
|
@ -80,6 +81,12 @@
|
|||
static inline void name##_clear(struct name *arr) { \
|
||||
free(arr->data); \
|
||||
name##_init(arr); \
|
||||
} \
|
||||
\
|
||||
static inline void name##_del(struct name *arr, size_t index) { \
|
||||
assert(index < arr->count); \
|
||||
memmove(arr->data + index, arr->data + index + 1, \
|
||||
(--arr->count - index) * sizeof(struct name)); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ static void key_input(struct kubo_context *context) {
|
|||
kubo_context_select_prev_wall(context);
|
||||
break;
|
||||
|
||||
case KEY_X:
|
||||
kubo_context_delete_wall(context);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ void kubo_window_init() {
|
|||
InitWindow(KUBO_WINDOW_WIDTH, KUBO_WINDOW_HEIGHT, "Kubo");
|
||||
EnableEventWaiting();
|
||||
SetExitKey(0);
|
||||
SetTargetFPS(60);
|
||||
}
|
||||
|
||||
void kubo_window_cleanup() { CloseWindow(); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue