mirror of
https://github.com/zoriya/My3D.git
synced 2026-06-01 18:16:40 +00:00
Cleaning up and merging
This commit is contained in:
@@ -22,7 +22,7 @@ enum modes_on_tile {
|
||||
INVERT_ADD_VALUE = 1
|
||||
};
|
||||
|
||||
bool tile_interact(gc_engine *engine, gc_entity *entity, gc_vector2 pos, \
|
||||
bool map_onclick(gc_engine *engine, gc_entity *entity, gc_vector2 pos, \
|
||||
enum gc_mousekeys key);
|
||||
|
||||
#endif //MY3D_MAP_INTERACTIONS_H
|
||||
|
||||
+1
-1
Submodule lib/gamacon updated: 0062aa990e...7f8048fe73
@@ -33,12 +33,12 @@
|
||||
</tiles>
|
||||
</data>
|
||||
<gc_entities>
|
||||
<camera x="0" y="300" />
|
||||
<camera x="0" y="0" />
|
||||
<gc_entity>
|
||||
<clickable_component click="map_manage_click"/>
|
||||
<map_manager_component />
|
||||
<transform_component>
|
||||
<Position x="0" y="0" />
|
||||
<Position x="0" y="300" />
|
||||
<Size x="100000000" y="100000000" />
|
||||
</transform_component>
|
||||
<vertex_component tilemap="prefabs/tilemap.gcmap" />
|
||||
|
||||
@@ -29,36 +29,38 @@ struct tile *ret, bool is_left)
|
||||
break;
|
||||
case MOVE:
|
||||
case RESET:
|
||||
move_tile(engine, ret, ALL_VERTICES | is_left, r);
|
||||
move_verticies(engine, ret, ALL_VERTICES | is_left, r);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool tile_interact(gc_engine *engine, gc_entity *entity, gc_vector2 pos, \
|
||||
bool map_onclick(gc_engine *engine, gc_entity *entity, gc_vector2 pos, \
|
||||
enum gc_mousekeys key)
|
||||
{
|
||||
struct vertex_component *map = GETCMP(entity, vertex_component);
|
||||
struct map_manager_component *manager = GETCMP(entity, map_manager_component);
|
||||
struct tile *ret = get_tile_from_pos(map, pos);
|
||||
bool r = manager->brush == RESET;
|
||||
struct map_manager_component *m = GETCMP(entity, map_manager_component);
|
||||
struct transform_component *tc = GETCMP(entity, transform_component);
|
||||
struct tile *t = get_tile_from_pos(map, gc_vector2_add(pos, tc->position));
|
||||
bool r;
|
||||
int ind;
|
||||
|
||||
if (!map || !manager) {
|
||||
if (!map || !m) {
|
||||
my_printf("map not found\n");
|
||||
return (false);
|
||||
}
|
||||
if (!ret)
|
||||
r = m->brush == RESET;
|
||||
if (!t)
|
||||
return (false);
|
||||
if (manager->tile_mode)
|
||||
click_tile(engine, manager, ret, key == GC_LEFT);
|
||||
if (m->tile_mode)
|
||||
click_tile(engine, m, t, key == GC_LEFT);
|
||||
else {
|
||||
ind = get_index_nearest_vertex(ret, pos);
|
||||
move_tile(engine, ret, ((int) pow(2, ind + 1)) | (key == GC_LEFT), r);
|
||||
ind = get_index_nearest_vertex(t, gc_vector2_add(pos, tc->position));
|
||||
move_verticies(engine, t, (int)pow(2, ind + 1) | (key == GC_LEFT), r);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
void move_tile(gc_engine *engine, struct tile *ret, char mode, bool r)
|
||||
void move_verticies(gc_engine *engine, struct tile *ret, char mode, bool r)
|
||||
{
|
||||
int val = (mode & INVERT_ADD_VALUE) ? ADD_VALUE : -ADD_VALUE;
|
||||
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ const struct callback callbacks[] = {
|
||||
{"goto_main_menu", &goto_main_menu},
|
||||
{"quit", &quit},
|
||||
{"fullscreen", &fullscreen},
|
||||
{"map_manage_click", &tile_interact},
|
||||
{"map_manage_click", &map_onclick},
|
||||
{"resolution_down", &resolution_down},
|
||||
{"resolution_up", &resolution_up},
|
||||
{"framerate_up", &framerate_up},
|
||||
|
||||
Reference in New Issue
Block a user