Skip to content

Commit

Permalink
Merge pull request #1159 from tsoding/1139
Browse files Browse the repository at this point in the history
(#1139) Implement Move snap for Label Layer
  • Loading branch information
rexim authored Nov 30, 2019
2 parents aa5d7e6 + c7497e3 commit b926d93
Show file tree
Hide file tree
Showing 19 changed files with 204 additions and 193 deletions.
43 changes: 20 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,6 @@ include_directories(src/)

include_directories(${SDL2_INCLUDE_DIRS})

add_library(system STATIC
src/system/line_stream.h
src/system/line_stream.c
src/system/log.h
src/system/log.c
src/system/lt.h
src/system/lt_adapters.h
src/system/lt_adapters.c
src/system/nth_alloc.h
src/system/nth_alloc.c
src/system/stacktrace.h
src/system/stacktrace.c
src/system/str.h
src/system/str.c
src/dynarray.h
src/dynarray.c
src/hashset.h
src/hashset.c
src/system/file.h
src/system/file.c
)

add_executable(nothing
src/color.h
src/color.c
Expand Down Expand Up @@ -173,8 +151,27 @@ add_executable(nothing
src/game/level/level_editor/undo_history.c
src/game/level/level_editor/action_picker.h
src/game/level/level_editor/action_picker.c
src/system/line_stream.h
src/system/line_stream.c
src/system/log.h
src/system/log.c
src/system/lt.h
src/system/lt_adapters.h
src/system/lt_adapters.c
src/system/nth_alloc.h
src/system/nth_alloc.c
src/system/stacktrace.h
src/system/stacktrace.c
src/system/str.h
src/system/str.c
src/dynarray.h
src/dynarray.c
src/hashset.h
src/hashset.c
src/system/file.h
src/system/file.c
)
target_link_libraries(nothing ${SDL2_LIBRARIES} system)
target_link_libraries(nothing ${SDL2_LIBRARIES})

ADD_CUSTOM_TARGET(link_assets ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/assets ${CMAKE_BINARY_DIR}/assets)
Expand Down
61 changes: 32 additions & 29 deletions assets/levels/platforms.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,40 @@
Platforms
073642
117.10616 417.59192 b58900
117.106163 417.591919 b58900
22
rect6 0 658.81897 1617.7523 1014.819 657b83
rect4-3-3 -1609.375 0 1659.375 1673.6379 657b83
rect4-3-3-7 895.57068 0 50 680.31897 657b83
rect4-3-3-7-5-3 829.6087 585.28345 65.961945 20 657b83
rect4-3-3-7-5-3-6 669.13647 508.79398 65.961945 20 657b83
rect4-3-3-7-5-3-5 829.6087 443.09402 65.961945 20 657b83
rect4-3-3-7-5-3-6-3 669.13654 366.60455 65.961945 20 657b83
rect4-3-3-7-5-3-56 829.6087 288.23764 65.961945 20 657b83
rect4-3-3-7-5-3-6-2 669.13654 211.74818 65.961945 20 657b83
rect4-3-3-7-5-3-9 829.6087 129.84573 65.961945 20 657b83
rect4-3-3-7-5-3-6-1 669.13654 53.356262 65.961945 20 657b83
rect4-3-3-7-5-3-2 945.57068 585.78259 65.961945 20 657b83
rect4-3-3-7-5-3-6-37 1088.0984 509.29309 65.961945 20 657b83
rect4-3-3-7-5-3-5-5 945.57068 443.59314 65.961945 20 657b83
rect4-3-3-7-5-3-6-3-9 1088.0985 367.1037 65.961945 20 657b83
rect4-3-3-7-5-3-56-2 945.57068 288.73676 65.961945 20 657b83
rect4-3-3-7-5-3-6-2-2 1088.0985 212.24731 65.961945 20 657b83
rect4-3-3-7-5-3-9-8 945.57068 130.34485 65.961945 20 657b83
rect4-3-3-7-5-3-6-1-9 1088.0985 53.855385 65.961945 20 657b83
rect4-3-3-7-7 1768.5708 -1131.3708 1356 2805.0088 657b83
rect4-3-3-7-5-3-6-36 358.7562 617.80682 65.961945 82.024391 657b83
rect4-3-3-7-5-3-6-7 508.66281 617.80682 65.961945 82.024391 657b83
rect6 0.000000 658.818970 1617.752319 1014.818970 657b83
rect4-3-3 -1609.375000 0.000000 1659.375000 1673.637939 657b83
rect4-3-3-7 895.570679 0.000000 50.000000 680.318970 657b83
rect4-3-3-7-5-3 829.608704 585.283447 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6 669.136475 508.793976 65.961945 20.000000 657b83
rect4-3-3-7-5-3-5 829.608704 443.094025 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6-3 669.136536 366.604553 65.961945 20.000000 657b83
rect4-3-3-7-5-3-56 829.608704 288.237640 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6-2 669.136536 211.748184 65.961945 20.000000 657b83
rect4-3-3-7-5-3-9 829.608704 129.845734 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6-1 669.136536 53.356262 65.961945 20.000000 657b83
rect4-3-3-7-5-3-2 945.570679 585.782593 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6-37 1088.098389 509.293091 65.961945 20.000000 657b83
rect4-3-3-7-5-3-5-5 945.570679 443.593140 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6-3-9 1088.098511 367.103699 65.961945 20.000000 657b83
rect4-3-3-7-5-3-56-2 945.570679 288.736755 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6-2-2 1088.098511 212.247314 65.961945 20.000000 657b83
rect4-3-3-7-5-3-9-8 945.570679 130.344849 65.961945 20.000000 657b83
rect4-3-3-7-5-3-6-1-9 1088.098511 53.855385 65.961945 20.000000 657b83
rect4-3-3-7-7 1768.570801 -1131.370850 1356.000000 2805.008789 657b83
rect4-3-3-7-5-3-6-36 358.756195 617.806824 65.961945 82.024391 657b83
rect4-3-3-7-5-3-6-7 508.662811 617.806824 65.961945 82.024391 657b83
2
goal2 973.78259 631.06897 d33682
goal3 -103.3381 -136.98125 d33682
goal2 973.782593 631.068970 d33682
goal3 -103.338097 -136.981247 d33682
2
lava1 413.91043 628.4342 105.55992 38.384777 000000
lava1-3 225.22003 152.62662 357.55994 245.38478 ff9955
0
0
lava1 413.910431 628.434204 105.559921 38.384777 000000
lava1-3 225.220032 152.626617 357.559937 245.384781 ff9955
0
0
2
label_0 150.416733 691.458435 bfe34f
Label Test
label_1 290.416748 691.458435 bfe34f
Label Test
0
2 changes: 2 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@

#define ENTITY_MAX_ID_SIZE 36

#define SNAPPING_THRESHOLD 10.0f

#endif // CONFIG_H_
4 changes: 2 additions & 2 deletions src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static int game_event_level_picker(Game *game, const SDL_Event *event)
} break;
}

return level_picker_event(game->level_picker, event, &game->camera);
return level_picker_event(game->level_picker, event);
}

static int game_event_level_editor(Game *game, const SDL_Event *event)
Expand Down Expand Up @@ -511,7 +511,7 @@ int game_event(Game *game, const SDL_Event *event)

// TODO(#1145): get rid of keyboard_state and introduce *_joystick methods
//
// keyboard_state is a global var and can be check anywhere anyway
// keyboard_state is a global var and can be check anywhere anyway
int game_input(Game *game,
const Uint8 *const keyboard_state,
SDL_Joystick *the_stick_of_joy)
Expand Down
24 changes: 5 additions & 19 deletions src/game/camera.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#include <SDL.h>
#include "system/stacktrace.h"
#include <math.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>

#include <SDL.h>

#include "camera.h"
#include "sdl/renderer.h"
#include "system/nth_alloc.h"
#include "system/log.h"
#include "system/stacktrace.h"

#define RATIO_X 16.0f
#define RATIO_Y 9.0f
Expand Down Expand Up @@ -304,11 +306,7 @@ int camera_is_text_visible(const Camera *camera,
return rects_overlap(
camera_rect(
camera,
sprite_font_boundary_box(
camera->font,
position,
size,
text)),
sprite_font_boundary_box(position, size, strlen(text))),
rect_from_sdl(&view_port));
}

Expand Down Expand Up @@ -519,18 +517,6 @@ const Sprite_font *camera_font(const Camera *camera)
return camera->font;
}

Rect camera_text_boundary_box(const Camera *camera,
Vec2f position,
Vec2f scale,
const char *text)
{
trace_assert(camera);
trace_assert(text);

return sprite_font_boundary_box(
camera->font, position, scale, text);
}

int camera_draw_line(const Camera *camera,
Vec2f begin, Vec2f end,
Color color)
Expand Down
5 changes: 0 additions & 5 deletions src/game/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ int camera_render_text_screen(const Camera *camera,
Color color,
Vec2f position);

Rect camera_text_boundary_box(const Camera *camera,
Vec2f position,
Vec2f scale,
const char *text);

int camera_render_debug_text(const Camera *camera,
const char *text,
Vec2f position);
Expand Down
2 changes: 1 addition & 1 deletion src/game/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int credits_render(const Credits *credits, const Camera *camera)
return -1;
}

const Vec2f title_size = wiggly_text_size(&credits->wiggly_text, camera);
const Vec2f title_size = wiggly_text_size(&credits->wiggly_text);

if (wiggly_text_render(
&credits->wiggly_text,
Expand Down
4 changes: 1 addition & 3 deletions src/game/level/level_editor.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,7 @@ int level_editor_render(const LevelEditor *level_editor,
}

const Rect screen_viewport = camera_view_port_screen(camera);
const Vec2f text_size = fading_wiggly_text_size(
&level_editor->notice,
camera);
const Vec2f text_size = fading_wiggly_text_size(&level_editor->notice);

fading_wiggly_text_render(
&level_editor->notice, camera,
Expand Down
Loading

0 comments on commit b926d93

Please sign in to comment.