From 0a3fefb19491383d4f9f1352f35a84f16814169b Mon Sep 17 00:00:00 2001 From: En Yi Date: Sat, 23 Nov 2019 18:05:00 +0800 Subject: [PATCH] Incorporate squish offset --- .gitignore | 8 ++++---- main.c | 5 ++--- obj/squishy.c | 10 +++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 4793958..4bc9bc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -Make* -.vscode -main -main.code-workspace \ No newline at end of file +* +!*.c +!*.h +!.gitignore \ No newline at end of file diff --git a/main.c b/main.c index 2369c34..34762e7 100644 --- a/main.c +++ b/main.c @@ -38,7 +38,7 @@ int main() camera.rotation = 0.0f; camera.zoom = 1.0f; - struct kinematic_obj player = init_kinematic_obj(30, 30); + struct kinematic_obj player = init_kinematic_obj(40, 40); player.color = BLUE; struct kinematic_obj tile = init_kinematic_obj(900, 100); set_position(&player, 400, 300); @@ -92,8 +92,7 @@ int main() DrawRectangleRec(current->obj->rect, current->obj->color); current = current->next; } - DrawTriangle((Vector2){0,0}, - (Vector2){screenWidth, screenHeight}, (Vector2){50,0}, BLACK); + DrawFPS(100,100); draw_squishy(&sqr); EndMode2D(); diff --git a/obj/squishy.c b/obj/squishy.c index d8e6bf9..dc6aba6 100644 --- a/obj/squishy.c +++ b/obj/squishy.c @@ -33,13 +33,13 @@ void update_squishy(struct squishy_square *square){ square->bottomright.y = square->rect->y + square->rect->height; square->top_handle.x = square->rect->x + square->rect->width / 2; - square->top_handle.y = square->rect->y; + square->top_handle.y = square->rect->y + square->top_offset; square->bottom_handle.x = square->rect->x + square->rect->width / 2; - square->bottom_handle.y = square->rect->y + square->rect->height; - square->left_handle.x = square->rect->x; + square->bottom_handle.y = square->rect->y + square->rect->height - square->bottom_offset; + square->left_handle.x = square->rect->x + square->left_offset; square->left_handle.y = square->rect->y + square->rect->height / 2; - square->right_handle.x = square->rect->x + square->rect->width; - square->right_handle.y = square->rect->y+ square->rect->height / 2; + square->right_handle.x = square->rect->x + square->rect->width - square->right_offset; + square->right_handle.y = square->rect->y+ square->rect->height / 2; } void draw_squishy(struct squishy_square *square){