From 3bdda0c03d6c5ed5ff85771d468b60fab675655b Mon Sep 17 00:00:00 2001
From: AnonymusRaccoon
Date: Sat, 4 Jan 2020 16:56:28 +0100
Subject: [PATCH] Adding layer
---
include/components/walk_action.h | 1 +
include/my.h | 2 ++
lib/gamacon | 2 +-
lib/my/include/my.h | 2 ++
lib/my/my/my_getnbr_base.c | 4 ++--
lib/my/my/my_str_islower.c | 11 +++++++++++
lib/quadtree | 2 +-
lib/xmlparser | 2 +-
prefabs/game.gcprefab | 6 +++---
prefabs/player.gcprefab | 4 ++--
src/components/jump_component.c | 2 ++
src/components/walk_component.c | 5 ++++-
src/systems/walk_system.c | 10 +++++-----
13 files changed, 37 insertions(+), 16 deletions(-)
diff --git a/include/components/walk_action.h b/include/components/walk_action.h
index 0165b4d..e934c30 100644
--- a/include/components/walk_action.h
+++ b/include/components/walk_action.h
@@ -15,6 +15,7 @@ struct walk_action
gc_component base;
int acceleration;
int max_acceleration;
+ int decceleration;
};
extern const struct walk_action walk_action;
\ No newline at end of file
diff --git a/include/my.h b/include/my.h
index 35212f7..dc4a2d5 100644
--- a/include/my.h
+++ b/include/my.h
@@ -6,6 +6,8 @@
*/
#pragma once
+int my_str_islower_or_num(const char *str);
+
int my_printf(const char *str, ...);
int count_valid_queens_placements(int n);
diff --git a/lib/gamacon b/lib/gamacon
index 94dbd5e..a15371f 160000
--- a/lib/gamacon
+++ b/lib/gamacon
@@ -1 +1 @@
-Subproject commit 94dbd5eb0eeec2738fdea35e56dbd05e14001d96
+Subproject commit a15371fed17be4f8a655e954b997f1fa7d85d443
diff --git a/lib/my/include/my.h b/lib/my/include/my.h
index f5ddc01..3102a6f 100644
--- a/lib/my/include/my.h
+++ b/lib/my/include/my.h
@@ -6,6 +6,8 @@
*/
#pragma once
+int my_str_islower_or_num(const char *str);
+
int my_printf(const char *str, ...);
void print_ptr(void *ptr);
diff --git a/lib/my/my/my_getnbr_base.c b/lib/my/my/my_getnbr_base.c
index 206030c..e309364 100644
--- a/lib/my/my/my_getnbr_base.c
+++ b/lib/my/my/my_getnbr_base.c
@@ -7,7 +7,7 @@
int my_strlen(const char *str);
-int my_compute_power_it(int i, int p);
+int my_pow(int i, int p);
static int indexof(char c, const char *str)
{
@@ -29,7 +29,7 @@ static int parse(char *str, const char *base, long n, int i)
neg = -1;
i *= -1;
}
- power = my_compute_power_it(base_length, i - 1);
+ power = my_pow(base_length, i - 1);
n += indexof(str[str_length - i], base) * power * neg;
if ((n > 0 && neg < 0) || (n < 0 && neg > 0))
return (0);
diff --git a/lib/my/my/my_str_islower.c b/lib/my/my/my_str_islower.c
index 7ec625d..56d38c5 100644
--- a/lib/my/my/my_str_islower.c
+++ b/lib/my/my/my_str_islower.c
@@ -5,6 +5,8 @@
** Duplicate of the string.h (I think)
*/
+int is_digit(char c);
+
int is_lowercase(char c)
{
if (c >= 'a' && c <= 'z')
@@ -20,3 +22,12 @@ int my_str_islower(const char *str)
}
return (1);
}
+
+int my_str_islower_or_num(const char *str)
+{
+ for (int i = 0; str[i] != '\0'; i++) {
+ if (!is_lowercase(str[i]) && !is_digit(str[i]))
+ return (0);
+ }
+ return (1);
+}
diff --git a/lib/quadtree b/lib/quadtree
index b23039a..a7a504f 160000
--- a/lib/quadtree
+++ b/lib/quadtree
@@ -1 +1 @@
-Subproject commit b23039ac966af5e83a66e1dcecf43583493febce
+Subproject commit a7a504fd265048061449854a6b031c7e4a4f7f0b
diff --git a/lib/xmlparser b/lib/xmlparser
index b9cd425..9262589 160000
--- a/lib/xmlparser
+++ b/lib/xmlparser
@@ -1 +1 @@
-Subproject commit b9cd42541689de76a8c7eab020cfe3055c87b4cf
+Subproject commit 92625890549fca2529bd124916e05c35f8e69117
diff --git a/prefabs/game.gcprefab b/prefabs/game.gcprefab
index 9279e7f..02223b9 100644
--- a/prefabs/game.gcprefab
+++ b/prefabs/game.gcprefab
@@ -56,7 +56,7 @@
-
+
@@ -66,7 +66,7 @@
-
+
@@ -76,7 +76,7 @@
-
+
\ No newline at end of file
diff --git a/prefabs/player.gcprefab b/prefabs/player.gcprefab
index 3ebce1d..5b13296 100644
--- a/prefabs/player.gcprefab
+++ b/prefabs/player.gcprefab
@@ -11,9 +11,9 @@
-
+
-
+
\ No newline at end of file
diff --git a/src/components/jump_component.c b/src/components/jump_component.c
index 9fb0aa9..635cade 100644
--- a/src/components/jump_component.c
+++ b/src/components/jump_component.c
@@ -17,6 +17,7 @@ static void ctr(void *component, va_list args)
struct jump_action *cmp = (struct jump_action *)component;
cmp->acceleration = va_arg(args, int);
+ cmp->contered = false;
}
static void fdctr(gc_scene *scene, void *component, node *n)
@@ -25,6 +26,7 @@ static void fdctr(gc_scene *scene, void *component, node *n)
cmp->acceleration = xml_getintprop(n, "acceleration");
cmp->counterforce = xml_getintprop(n, "counterforce");
+ cmp->contered = false;
(void)scene;
}
diff --git a/src/components/walk_component.c b/src/components/walk_component.c
index 2bc342b..c729855 100644
--- a/src/components/walk_component.c
+++ b/src/components/walk_component.c
@@ -18,6 +18,7 @@ static void walk_ctr(void *component, va_list args)
cmp->acceleration = va_arg(args, int);
cmp->max_acceleration = va_arg(args, int);
+ cmp->decceleration = va_arg(args, int);
}
static void walk_fdctr(gc_scene *scene, void *component, node *n)
@@ -26,6 +27,7 @@ static void walk_fdctr(gc_scene *scene, void *component, node *n)
cmp->acceleration = xml_getintprop(n, "acceleration");
cmp->max_acceleration = xml_getintprop(n, "max_acceleration");
+ cmp->decceleration = xml_getintprop(n, "decceleration");
(void)scene;
}
@@ -57,5 +59,6 @@ const struct walk_action walk_action = {
destroy: &component_destroy
},
acceleration: 0,
- max_acceleration: 0
+ max_acceleration: 0,
+ decceleration: 0
};
\ No newline at end of file
diff --git a/src/systems/walk_system.c b/src/systems/walk_system.c
index aa2dd12..88014e7 100644
--- a/src/systems/walk_system.c
+++ b/src/systems/walk_system.c
@@ -22,12 +22,12 @@ gc_entity *entity, float dtime)
struct controllable_component *con = GETCMP(controllable_component);
struct movable_component *mov = GETCMP(movable_component);
struct walk_action *walk = GETCMP(walk_action);
- bool clamp = mov->acceleration.x < walk->max_acceleration || mov->acceleration.x > -walk->max_acceleration;
+ gc_vector2 *acc = &mov->acceleration;
- mov->acceleration.x -= con->moving_left * walk->acceleration;
- mov->acceleration.x += con->moving_right * walk->acceleration;
- if (clamp)
- ABSCLAMP(mov->acceleration.x, walk->max_acceleration);
+ if (con->moving_left)
+ acc->x -= walk->acceleration;
+ if (con->moving_right)
+ acc->x += walk->acceleration;
(void)system;
(void)dtime;
(void)engine;