Reversing the click order

This commit is contained in:
AnonymusRaccoon
2020-03-09 17:27:22 +01:00
parent 14f28e8339
commit 7b4781a4cd
6 changed files with 27 additions and 4 deletions
+15
View File
@@ -0,0 +1,15 @@
//
// Created by anonymus-raccoon on 3/9/20.
//
#ifndef _KEYBINDINGS_H_
#define _KEYBINDINGS_H_
#include <SFML/Window/Keyboard.h>
typedef enum gc_keybindings
{
ESCAPE = sfKeyEscape
} gc_keybindings;
#endif //_KEYBINDINGS_H_
+1
View File
@@ -13,6 +13,7 @@ struct gc_list
{
void *data;
gc_list *next;
gc_list *prev;
};
gc_list *list_add(gc_list *list, void *obj);
+2
View File
@@ -30,6 +30,8 @@ struct gc_scene
gc_list *callbacks;
callback_t (*get_callback)(gc_scene *this, char *name);
bool is_paused;
};
callback_t scene_get_callback(gc_scene *scene, char *name);
+2 -3
View File
@@ -41,11 +41,10 @@ gc_scene *scene_create(gc_engine *engine, const char *xmlpath)
gc_scene *scene = malloc(sizeof(gc_scene));
node *n = NULL;
if (!scene)
return (NULL);
if (xmlpath && !(n = xml_parse(xmlpath)))
if (!scene || (xmlpath && !(n = xml_parse(xmlpath))))
return (NULL);
scene_load_data(engine, scene, n);
scene->is_paused = false;
scene->entities = NULL;
scene->entities_by_cmp = NULL;
scene->add_entity = &entity_add;
+3 -1
View File
@@ -21,7 +21,9 @@ void clickable_onclick(gc_engine *engine, gc_vector2 position)
if (!scene)
return;
entities = scene->get_entity_by_cmp(scene, "clickable_component");
for (gc_list *ent = entities; ent; ent = ent->next) {
while (entities->next)
entities = entities->next;
for (gc_list *ent = entities; ent; ent = ent->prev) {
tra = GETCMP(((gc_entity *)ent->data), transform_component);
if ((tra->position.x - tra->size.x / 2) <= position.x
&& (tra->position.y + tra->size.y / 2) >= position.y
+4
View File
@@ -14,11 +14,15 @@ gc_list *list_add(gc_list *list, void *obj)
if (!list) {
list = malloc(sizeof(gc_list));
if (list)
list->prev = NULL;
listconst = list;
} else {
while (list->next)
list = list->next;
list->next = malloc(sizeof(gc_list));
if (list->next)
list->next->prev = list;
list = list->next;
}
if (!list)