added kubo_state_wall_new
This commit is contained in:
parent
fb8ff21666
commit
c3973ae02b
9 changed files with 96 additions and 26 deletions
|
|
@ -46,17 +46,6 @@ void kubo_context_set_state(struct kubo_context *context,
|
|||
enum kubo_context_state state) {
|
||||
context->state = kubo_context_states[state];
|
||||
|
||||
// switch (context->state.id) {
|
||||
// case KUBO_CONTEXT_COMMAND:
|
||||
// break;
|
||||
//
|
||||
// case KUBO_CONTEXT_WALL_NEW:
|
||||
// break;
|
||||
//
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
|
||||
for (unsigned i = 0; i < kubo_state_data_length; i++) {
|
||||
if (context->state.id == kubo_state_data[i].id &&
|
||||
kubo_state_data[i].data.state_entered != NULL) {
|
||||
|
|
|
|||
14
kubo_input.c
14
kubo_input.c
|
|
@ -50,17 +50,9 @@ static void key_input(struct kubo_context *context, Camera2D *camera) {
|
|||
kubo_context_set_state(context, KUBO_CONTEXT_NORMAL);
|
||||
break;
|
||||
|
||||
case KEY_W:
|
||||
kubo_context_set_state(context, KUBO_CONTEXT_WALL_NEW);
|
||||
break;
|
||||
|
||||
case KEY_S:
|
||||
kubo_context_set_state(context, KUBO_CONTEXT_WALL_SELECT);
|
||||
break;
|
||||
|
||||
case KEY_T:
|
||||
kubo_mouse_snap = !kubo_mouse_snap;
|
||||
break;
|
||||
// case KEY_T:
|
||||
// kubo_mouse_snap = !kubo_mouse_snap;
|
||||
// break;
|
||||
|
||||
case KEY_SPACE:
|
||||
kubo_camera_reset(camera);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
set(STATES_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_normal.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_command.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_wall_new.c
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kubo_state_wall_select.c
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
|
|
|||
|
|
@ -22,5 +22,4 @@
|
|||
void kubo_state_command_entered(void *context_data) {
|
||||
struct kubo_context *context = (struct kubo_context *)context_data;
|
||||
(void)context;
|
||||
printf("hello from state command\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,3 +17,20 @@
|
|||
*/
|
||||
|
||||
#include "kubo_state_normal.h"
|
||||
#include "../kubo_context.h"
|
||||
|
||||
void kubo_state_normal_entered(void *context_data) { (void)context_data; }
|
||||
|
||||
void kubo_state_normal_key(void *context_data, int key_code) {
|
||||
struct kubo_context *context = (struct kubo_context *)context_data;
|
||||
|
||||
switch (key_code) {
|
||||
case KEY_W:
|
||||
kubo_context_set_state(context, KUBO_CONTEXT_WALL_NEW);
|
||||
break;
|
||||
|
||||
case KEY_S:
|
||||
kubo_context_set_state(context, KUBO_CONTEXT_WALL_SELECT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,12 @@
|
|||
|
||||
#include "kubo_state_data.h"
|
||||
|
||||
void kubo_state_normal_entered(void *context_data);
|
||||
void kubo_state_normal_key(void *context_data, int key_code);
|
||||
|
||||
static const struct kubo_state_data kubo_state_normal_data = {
|
||||
.state_entered = NULL,
|
||||
.state_key = NULL
|
||||
.state_entered = kubo_state_normal_entered,
|
||||
.state_key = kubo_state_normal_key
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
36
states/kubo_state_wall_new.c
Normal file
36
states/kubo_state_wall_new.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright Luka Jankovic 2025
|
||||
*
|
||||
* This file is part of Kubo.
|
||||
*
|
||||
* Kubo is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Kubo is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* Kubo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "kubo_state_wall_new.h"
|
||||
#include "../kubo_context.h"
|
||||
|
||||
extern bool kubo_mouse_snap;
|
||||
|
||||
void kubo_state_wall_new_entered(void *context_data) {
|
||||
struct kubo_context *context = (struct kubo_context *)context_data;
|
||||
(void)context;
|
||||
}
|
||||
|
||||
void kubo_state_wall_new_key(void *context_data, int key_code) {
|
||||
struct kubo_context *context = (struct kubo_context *)context_data;
|
||||
(void)context;
|
||||
|
||||
if (key_code == KEY_S) {
|
||||
kubo_mouse_snap = !kubo_mouse_snap;
|
||||
}
|
||||
}
|
||||
32
states/kubo_state_wall_new.h
Normal file
32
states/kubo_state_wall_new.h
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright Luka Jankovic 2025
|
||||
*
|
||||
* This file is part of Kubo.
|
||||
*
|
||||
* Kubo is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later
|
||||
* version.
|
||||
*
|
||||
* Kubo is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
||||
* A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* Kubo. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KUBO_STATE_WALL_NEW_H
|
||||
#define KUBO_STATE_WALL_NEW_H
|
||||
|
||||
#include "kubo_state_data.h"
|
||||
|
||||
void kubo_state_wall_new_entered(void *context_data);
|
||||
void kubo_state_wall_new_key(void *context_data, int key_code);
|
||||
|
||||
static const struct kubo_state_data kubo_state_wall_new_data = {
|
||||
.state_entered = kubo_state_wall_new_entered,
|
||||
.state_key = kubo_state_wall_new_key
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "kubo_state_command.h"
|
||||
#include "kubo_state_normal.h"
|
||||
#include "kubo_state_wall_new.h"
|
||||
#include "kubo_state_wall_select.h"
|
||||
|
||||
enum kubo_context_state {
|
||||
|
|
@ -38,7 +39,7 @@ struct kubo_state_list_entry {
|
|||
static const struct kubo_state_list_entry kubo_state_data[] = {
|
||||
{ KUBO_CONTEXT_NORMAL, kubo_state_normal_data },
|
||||
{ KUBO_CONTEXT_COMMAND, kubo_state_command_data },
|
||||
{ KUBO_CONTEXT_WALL_NEW, kubo_state_wall_select_data },
|
||||
{ KUBO_CONTEXT_WALL_NEW, kubo_state_wall_new_data },
|
||||
{ KUBO_CONTEXT_WALL_SELECT, kubo_state_wall_select_data }
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue