mirror of
https://github.com/zoriya/My3D.git
synced 2025-12-06 06:26:14 +00:00
Cleaning up
This commit is contained in:
@@ -69,7 +69,7 @@ add_executable(My3D
|
||||
lib/gamacon/src/components/parallax_component.c
|
||||
lib/gamacon/src/components/renderer.c
|
||||
lib/gamacon/src/components/transform_component.c
|
||||
lib/gamacon/src/components/isometry/vertex_component.c
|
||||
lib/gamacon/src/components/vertex_component.c
|
||||
lib/gamacon/src/deserializer/deserialize_entity.c
|
||||
lib/gamacon/src/deserializer/prefab.c
|
||||
lib/gamacon/src/engine/discard_player.c
|
||||
@@ -206,13 +206,13 @@ add_executable(My3D
|
||||
src/main_menu.c
|
||||
lib/gamacon/src/components/clickable_component.c
|
||||
lib/gamacon/include/components/clickable_component.h
|
||||
lib/gamacon/src/systems/clickable_manager.c
|
||||
lib/gamacon/src/systems/clickable_system.c
|
||||
lib/gamacon/src/sfml_renderer/sfml_events.c
|
||||
lib/my/my/my_str_replace.c
|
||||
lib/gamacon/src/sfml_renderer/sfml_init.c
|
||||
lib/gamacon/src/sfml_renderer/sfml_events.c
|
||||
lib/gamacon/src/components/isometry/map_managment.c
|
||||
lib/gamacon/include/map_managment.h
|
||||
lib/gamacon/src/isometry/map_utils.c
|
||||
lib/gamacon/include/map_utils.h
|
||||
lib/xmlparser/src/otherget.c
|
||||
src/options.c
|
||||
lib/gamacon/src/components/input_component.c
|
||||
@@ -233,7 +233,7 @@ add_executable(My3D
|
||||
include/components/game_display.h
|
||||
src/components/game_display.c
|
||||
src/systems/game_display_system.c
|
||||
lib/gamacon/src/components/tile_collision_manager.c
|
||||
src/isometry/tile_collision_manager.c
|
||||
lib/gamacon/include/tile_collision_manager.h
|
||||
lib/gamacon/src/engine/event_manager.c
|
||||
lib/gamacon/include/event_manager.h
|
||||
@@ -242,21 +242,22 @@ add_executable(My3D
|
||||
src/systems/game_manager_system.c
|
||||
include/systems/game_manager_system.h
|
||||
lib/gamacon/include/keybindings.h
|
||||
src/components/isometry/map_interactions.c
|
||||
src/isometry/map_interactions.c
|
||||
include/map_interactions.h
|
||||
lib/gamacon/include/keybindings.h
|
||||
lib/gamacon/src/ui/tooltip.c
|
||||
lib/gamacon/src/components/tooltip_component.c
|
||||
lib/gamacon/include/components/tooltip_component.h
|
||||
lib/gamacon/src/systems/tooltip_system.c
|
||||
src/components/isometry/map_manager_component.c
|
||||
src/components/map_manager_component.c
|
||||
include/components/isometry/map_manager_component.h
|
||||
lib/gamacon/src/components/isometry/vertex_data_loader.c
|
||||
lib/gamacon/include/vertex_data_loader.h src/toolbar.c
|
||||
lib/gamacon/src/isometry/vertex_data_loader.c
|
||||
lib/gamacon/include/vertex_data_loader.h
|
||||
src/toolbar.c
|
||||
lib/gamacon/include/callbacks.h src/selectors.c
|
||||
src/framerate.c
|
||||
lib/gamacon/src/components/isometry/create_map_functions.c
|
||||
lib/gamacon/include/create_map_functions.h
|
||||
lib/gamacon/src/isometry/isometry.c
|
||||
lib/gamacon/include/isometry.h
|
||||
)
|
||||
|
||||
add_compile_options(-W -Wall -Wextra -Wshadow)
|
||||
|
||||
18
Makefile
18
Makefile
@@ -6,7 +6,23 @@
|
||||
##
|
||||
|
||||
SRC = src/main.c \
|
||||
src/game_loader.c
|
||||
src/game_loader.c \
|
||||
src/framerate.c \
|
||||
src/main_menu.c \
|
||||
src/options.c \
|
||||
src/selectors.c \
|
||||
src/toolbar.c \
|
||||
src/teams/absent.c \
|
||||
src/teams/forgot.c \
|
||||
src/systems/game_display_system.c \
|
||||
src/systems/game_manager_system.c \
|
||||
src/systems/teams_system.c \
|
||||
src/isometry/map_interactions.c \
|
||||
src/isometry/tile_collision_manager.c \
|
||||
src/components/map_manager_component.c \
|
||||
src/components/game_display.c \
|
||||
src/components/game_manager.c \
|
||||
src/components/teams_component.c
|
||||
|
||||
OBJ = $(SRC:%.c=%.o)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#define MY3D_MAP_INTERACTIONS_H
|
||||
|
||||
#include "engine.h"
|
||||
#include "vertex_component.h"
|
||||
#include "components/vertex_component.h"
|
||||
#include "keybindings.h"
|
||||
|
||||
enum modes_on_tile {
|
||||
|
||||
Submodule lib/gamacon updated: 7f8048fe73...2d9e7acac2
Submodule lib/xmlparser updated: edee81e3ae...e09c121a56
@@ -9,7 +9,7 @@
|
||||
#include "engine.h"
|
||||
#include <malloc.h>
|
||||
#include "utility.h"
|
||||
#include "renderer.h"
|
||||
#include "components/renderer.h"
|
||||
#include "systems/sfml_renderer_system.h"
|
||||
#include "limits.h"
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#include "engine.h"
|
||||
#include "setup.h"
|
||||
#include "map_managment.h"
|
||||
#include "components/teams_component.h"
|
||||
#include "components/isometry/map_manager_component.h"
|
||||
#include "systems/teams_system.h"
|
||||
#include <SFML/System.h>
|
||||
#include "teams.h"
|
||||
@@ -48,6 +48,7 @@ const struct callback callbacks[] = {
|
||||
|
||||
int register_customcmps(gc_engine *engine)
|
||||
{
|
||||
engine->add_component(engine, &map_manager_component);
|
||||
engine->add_component(engine, &game_manager);
|
||||
engine->add_system(engine, new_system(&game_manager_system, engine));
|
||||
engine->add_component(engine, &game_display);
|
||||
|
||||
@@ -6,14 +6,14 @@
|
||||
*/
|
||||
|
||||
#include "map_interactions.h"
|
||||
#include "clickable_component.h"
|
||||
#include "components/clickable_component.h"
|
||||
#include "entity.h"
|
||||
#include "my.h"
|
||||
#include <math.h>
|
||||
#include "components/transform_component.h"
|
||||
#include "map_managment.h"
|
||||
#include "map_utils.h"
|
||||
#include <stdlib.h>
|
||||
#include <components/isometry/map_manager_component.h>
|
||||
#include "components/isometry/map_manager_component.h"
|
||||
|
||||
void click_tile(gc_engine *engine, struct map_manager_component *manager, \
|
||||
struct tile *ret, bool is_left)
|
||||
80
src/isometry/tile_collision_manager.c
Normal file
80
src/isometry/tile_collision_manager.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2020
|
||||
** Gamacon
|
||||
** File description:
|
||||
** tile collision_managment
|
||||
*/
|
||||
|
||||
#include "tile_collision_manager.h"
|
||||
#include "map_utils.h"
|
||||
#include <math.h>
|
||||
|
||||
#define INF 10000
|
||||
|
||||
bool is_on_segment(gc_vector2 p, gc_vector2 q, gc_vector2 r)
|
||||
{
|
||||
if (q.x <= fmaxf(p.x, r.x) && q.x >= fminf(p.x, r.x) && \
|
||||
q.y <= fmaxf(p.y, r.y) && q.y >= fminf(p.y, r.y))
|
||||
return (true);
|
||||
return (false);
|
||||
}
|
||||
|
||||
int orientation(gc_vector2 p, gc_vector2 q, gc_vector2 r)
|
||||
{
|
||||
int tmp = (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
|
||||
|
||||
if (tmp == 0)
|
||||
return (0);
|
||||
return ((tmp > 0) ? 1 : 2);
|
||||
}
|
||||
|
||||
bool gc_vector2_do_intersect(gc_vector2 p1, gc_vector2 q1, gc_vector2 p2, gc_vector2 q2)
|
||||
{
|
||||
int o1 = orientation(p1, q1, p2);
|
||||
int o2 = orientation(p1, q1, q2);
|
||||
int o3 = orientation(p2, q2, p1);
|
||||
int o4 = orientation(p2, q2, q1);
|
||||
|
||||
if (o1 != o2 && o3 != o4)
|
||||
return (true);
|
||||
if (o1 == 0 && is_on_segment(p1, p2, q1))
|
||||
return (true);
|
||||
if (o2 == 0 && is_on_segment(p1, q2, q1))
|
||||
return (true);
|
||||
if (o3 == 0 && is_on_segment(p2, p1, q2))
|
||||
return (true);
|
||||
if (o4 == 0 && is_on_segment(p2, q1, q2))
|
||||
return (true);
|
||||
return (false);
|
||||
}
|
||||
|
||||
bool is_point_in_polygon(gc_vector2 *polygon, int n, gc_vector2 p)
|
||||
{
|
||||
gc_vector2 segment = {-INF, p.y};
|
||||
int count = 0;
|
||||
int next = 0;
|
||||
int i = 0;
|
||||
|
||||
if (n < 3)
|
||||
return (false);
|
||||
do {
|
||||
next = (i + 1) % n;
|
||||
if (gc_vector2_do_intersect(polygon[i], polygon[next], p, segment)) {
|
||||
if (orientation(polygon[i], p, polygon[next]) == 0)
|
||||
return (is_on_segment(polygon[i], p, polygon[next]));
|
||||
count++;
|
||||
}
|
||||
i = next;
|
||||
} while (i != 0);
|
||||
return (count & 1);
|
||||
}
|
||||
|
||||
bool is_pos_in_tile(gc_vector2 pos, struct tile *tile)
|
||||
{
|
||||
struct vertex **c = tile->corners;
|
||||
gc_vector2 corners[4];
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
corners[i] = get_tile_coords_to_pixels(c[i]->x, c[i]->y, c[i]->z);
|
||||
return (is_point_in_polygon(corners, 4, pos));
|
||||
}
|
||||
Reference in New Issue
Block a user