diff --git a/assets/tiles/stone.png b/assets/tiles/stone.png new file mode 100644 index 0000000..2665bae Binary files /dev/null and b/assets/tiles/stone.png differ diff --git a/include/components/game_display.h b/include/components/game_display.h index 3afe855..f5896f5 100644 --- a/include/components/game_display.h +++ b/include/components/game_display.h @@ -10,7 +10,9 @@ typedef enum display_type { SELECT_TILE_DISPLAY, - XP_DISPLAY + XP_DISPLAY, + HEALTH_DISPLAY, + HEALTH_DISPLAY_ENNEMY } display_type_enum; struct game_display diff --git a/include/components/health_component.h b/include/components/health_component.h index e8b5dbd..632c1e7 100644 --- a/include/components/health_component.h +++ b/include/components/health_component.h @@ -14,6 +14,7 @@ struct health_component { gc_component base; + int health_max; int health; bool dead; }; diff --git a/include/components/xp_component.h b/include/components/xp_component.h index 3857bc8..80b46a8 100644 --- a/include/components/xp_component.h +++ b/include/components/xp_component.h @@ -25,4 +25,4 @@ unsigned int amount); extern const struct xp_component xp_component; -#endif //MY_RPG_HEALTH_COMPONENT_H +#endif //MY_RPG_XP_COMPONENT_H diff --git a/lib/gamacon b/lib/gamacon index 845620b..5d78e62 160000 --- a/lib/gamacon +++ b/lib/gamacon @@ -1 +1 @@ -Subproject commit 845620bd43a8ef25d7bb9fd19df7e162d83853f2 +Subproject commit 5d78e62f4a97af93e32613a5d40614a9473b01a7 diff --git a/prefabs/game.gcprefab b/prefabs/game.gcprefab index 9b80bf9..eade679 100644 --- a/prefabs/game.gcprefab +++ b/prefabs/game.gcprefab @@ -80,12 +80,12 @@ - + - - + + @@ -111,6 +111,15 @@ + + + + + + + + + @@ -168,8 +177,10 @@ - - + + + + diff --git a/prefabs/map_entities.gcprefab b/prefabs/map_entities.gcprefab index 1e4650a..4af5b99 100644 --- a/prefabs/map_entities.gcprefab +++ b/prefabs/map_entities.gcprefab @@ -5,3440 +5,3440 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -3446,158 +3446,1758 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + - + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/prefabs/player.gcprefab b/prefabs/player.gcprefab index 1732750..594a5db 100644 --- a/prefabs/player.gcprefab +++ b/prefabs/player.gcprefab @@ -5,38 +5,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prefabs/tilemap.gcmap b/prefabs/tilemap.gcmap index 8a8b375..5812b07 100644 --- a/prefabs/tilemap.gcmap +++ b/prefabs/tilemap.gcmap @@ -5186,7 +5186,7 @@ - + @@ -5311,24 +5311,24 @@ - + - + - + - + @@ -5387,12 +5387,12 @@ - + - + - + @@ -5400,7 +5400,7 @@ - + @@ -5456,9 +5456,9 @@ - + - + @@ -5466,10 +5466,10 @@ - - + + - + @@ -5527,17 +5527,17 @@ - + - + - + @@ -5599,13 +5599,13 @@ - - - - + + + + - - + + @@ -5670,11 +5670,11 @@ - + - + - + @@ -5733,18 +5733,18 @@ - - - + + + - - + + - + - + @@ -5801,16 +5801,16 @@ - + - - - - - + + + + + @@ -5873,17 +5873,17 @@ - - + + - + - - + + @@ -5939,19 +5939,19 @@ - + - + - + - - + + - + @@ -6010,17 +6010,17 @@ - + - + - + - - - + + + @@ -6078,17 +6078,17 @@ - + - + - + - + @@ -6149,17 +6149,17 @@ - + - + - + - + @@ -6215,11 +6215,11 @@ - - + + - + @@ -6228,7 +6228,7 @@ - + @@ -6291,14 +6291,14 @@ - + - - - - - + + + + + @@ -6347,29 +6347,29 @@ - + - - + + - - + + - - - - - - - - - - + + + + + + + + + + @@ -6416,7 +6416,7 @@ - + @@ -6425,21 +6425,21 @@ - + - - + + - - - - - - - - - - + + + + + + + + + + @@ -6485,7 +6485,7 @@ - + @@ -6494,22 +6494,22 @@ - - - + + + - - - - - - - - - - - + + + + + + + + + + + @@ -6560,25 +6560,25 @@ - - + + - - + + - - - - - - - - - - - + + + + + + + + + + + @@ -6634,20 +6634,20 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + @@ -6698,25 +6698,25 @@ - - - - + + + + - + - - - - - - - - - - - + + + + + + + + + + + @@ -6767,24 +6767,24 @@ - + - - - + + + - + - - - - - - - - - + + + + + + + + + @@ -6796,14 +6796,14 @@ - + - + @@ -6837,22 +6837,22 @@ - - - + + + - + - - - - - - - - - + + + + + + + + + @@ -6874,11 +6874,11 @@ - + - + @@ -6908,20 +6908,20 @@ - + - + - - - - - - - + + + + + + + @@ -6935,7 +6935,7 @@ - + @@ -6974,22 +6974,22 @@ - + - + - + - - - - - + + + + + @@ -7001,7 +7001,7 @@ - + @@ -7010,13 +7010,13 @@ - + - + @@ -7043,22 +7043,22 @@ - + - + - + - + - - - - - + + + + + @@ -7073,10 +7073,10 @@ - + - + @@ -7118,16 +7118,16 @@ - + - + - - - - + + + + @@ -7135,7 +7135,7 @@ - + @@ -7150,7 +7150,7 @@ - + @@ -7181,22 +7181,22 @@ - - + + - + - + - - - - + + + + @@ -7210,7 +7210,7 @@ - + @@ -7244,27 +7244,27 @@ - - - - - - - - + + + + + + + + - - - - - - - - + + + + + + + + @@ -7314,25 +7314,25 @@ - - - - - - + + + + + + - - + + - + - + - + @@ -7346,7 +7346,7 @@ - + @@ -7383,25 +7383,25 @@ - - - - - - - + + + + + + + - + - + - + - + @@ -7411,22 +7411,22 @@ - + - + - + - + @@ -7451,26 +7451,26 @@ - - - - - - + + + + + + - - + + - - + + - - + + @@ -7520,25 +7520,25 @@ - - - - - - + + + + + + - - - - + + + + - + - - - + + + @@ -7590,25 +7590,25 @@ - - - - - - + + + + + + - - + + - - + + - + - - + + @@ -7628,7 +7628,7 @@ - + @@ -7659,24 +7659,24 @@ - - - - - + + + + + - + - + - + @@ -7709,7 +7709,7 @@ - + @@ -7728,25 +7728,25 @@ - - - - - + + + + + - + - + - - + + - - + + @@ -7796,26 +7796,26 @@ - - - - - - + + + + + + - + - - + + - + - + - + - + @@ -7834,13 +7834,13 @@ - - + + - + @@ -7866,25 +7866,25 @@ - - - - - - + + + + + + - + - - + + - - - + + + @@ -7935,25 +7935,25 @@ - - - - - + + + + + - - + + - - + + - + - + @@ -7970,22 +7970,22 @@ - + - + - + - - + + @@ -8003,24 +8003,24 @@ - - - - - - + + + + + + - + - + - + @@ -8033,7 +8033,7 @@ - + @@ -8053,8 +8053,8 @@ - - + + @@ -8073,25 +8073,25 @@ - - - - - + + + + + - + - - - - + + + + - + @@ -8117,7 +8117,7 @@ - + @@ -8142,22 +8142,22 @@ - - - - - + + + + + - - + + - + @@ -8211,25 +8211,25 @@ - - - - - + + + + + - + - + - + - + - + @@ -8253,7 +8253,7 @@ - + @@ -8280,14 +8280,14 @@ - - - - - + + + + + - - + + @@ -8298,7 +8298,7 @@ - + @@ -8327,10 +8327,10 @@ - + - + @@ -8349,24 +8349,24 @@ - - - - - + + + + + - + - - + + - + - + @@ -8382,13 +8382,13 @@ - + - + @@ -8398,7 +8398,7 @@ - + @@ -8417,24 +8417,24 @@ - - - - - - - - - + + + + + + + + + - - - - - - + + + + + + @@ -8447,7 +8447,7 @@ - + @@ -8487,22 +8487,22 @@ - - - - - + + + + + - + - + - + - - + + @@ -8531,7 +8531,7 @@ - + @@ -8561,13 +8561,13 @@ - + - - - + + + - + @@ -8585,7 +8585,7 @@ - + @@ -8631,7 +8631,7 @@ - + @@ -8640,8 +8640,8 @@ - - + + @@ -8700,19 +8700,19 @@ - + - - - + + + - + - - + + @@ -8741,7 +8741,7 @@ - + @@ -8769,18 +8769,18 @@ - + - - + + - - - - + + + + - + @@ -8802,9 +8802,9 @@ - + - + @@ -8832,20 +8832,20 @@ - - - - - + + + + + - - + + - + @@ -8901,25 +8901,25 @@ - - - - - + + + + + - + - + - + @@ -8941,7 +8941,7 @@ - + @@ -8972,22 +8972,22 @@ - - - - + + + + - + - - - + + + @@ -9015,10 +9015,10 @@ - + - + @@ -9042,20 +9042,20 @@ - - + + - - - - + + + + - - + + @@ -9078,7 +9078,7 @@ - + @@ -9107,26 +9107,26 @@ - - + + - + - + - - + + - - + + - + @@ -9151,11 +9151,11 @@ - + - + @@ -9175,26 +9175,26 @@ - - - - + + + + - - + + - - - - + + + + - + @@ -9208,11 +9208,11 @@ - - - - - + + + + + @@ -9231,7 +9231,7 @@ - + @@ -9244,23 +9244,23 @@ - - - - - + + + + + - + - + - + - + @@ -9276,34 +9276,34 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - + + + + @@ -9313,18 +9313,18 @@ - - - - - - - - + + + + + + + + - + @@ -9332,8 +9332,8 @@ - - + + @@ -9345,36 +9345,36 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + @@ -9383,15 +9383,15 @@ - - - - - - + + + + + + - - + + @@ -9400,7 +9400,7 @@ - + @@ -9412,62 +9412,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + - - - + + + - + - + - + @@ -9481,39 +9481,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9522,24 +9522,24 @@ - - - - - + + + + + - - - + + + - + - + - + @@ -9550,39 +9550,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9598,15 +9598,15 @@ - - - - - + + + + + - - + + @@ -9619,39 +9619,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9668,7 +9668,7 @@ - + @@ -9676,9 +9676,9 @@ - - - + + + @@ -9688,39 +9688,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -9736,11 +9736,11 @@ - + - + @@ -9757,39 +9757,39 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/components/game_display.c b/src/components/game_display.c index a06c923..602121a 100644 --- a/src/components/game_display.c +++ b/src/components/game_display.c @@ -32,12 +32,15 @@ static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n) } if (!my_strcmp(display_type, "selected_tile")) { cmp->type = SELECT_TILE_DISPLAY; - return; - } - if (!my_strcmp(display_type, "xp")) { + } if (!my_strcmp(display_type, "xp")) { cmp->type = XP_DISPLAY; rend->destroy = &text_safe_destroy; - return; + } if (!my_strcmp(display_type, "health")) { + cmp->type = HEALTH_DISPLAY; + rend->destroy = &text_safe_destroy; + } if (!my_strcmp(display_type, "health_ennemy")) { + cmp->type = HEALTH_DISPLAY_ENNEMY; + rend->destroy = &text_safe_destroy; } } diff --git a/src/components/health_component.c b/src/components/health_component.c index 2c0c5a2..d2647af 100644 --- a/src/components/health_component.c +++ b/src/components/health_component.c @@ -13,7 +13,8 @@ static void ctr(void *component, va_list args) { struct health_component *cmp = (struct health_component *)\ component; - cmp->health = va_arg(args, int); + cmp->health_max = va_arg(args, int); + cmp->health = cmp->health_max; cmp->dead = false; } @@ -23,7 +24,10 @@ void *component, node *n) struct health_component *cmp = (struct health_component *)\ component; - cmp->health = xml_getintprop(n, "health"); + cmp->health_max = xml_getintprop(n, "max_health"); + if (cmp->health_max <= 0) + cmp->health_max = 42; + cmp->health = cmp->health_max; cmp->dead = false; } diff --git a/src/components/health_methods.c b/src/components/health_methods.c index 911d6a7..de3a9cd 100644 --- a/src/components/health_methods.c +++ b/src/components/health_methods.c @@ -25,5 +25,7 @@ unsigned int amount) if (this->dead) return; this->health += amount; + if (this->health > this->health_max) + this->health = this->health_max; engine->trigger_event(engine, "add_health", this->health, amount); } \ No newline at end of file diff --git a/src/game_loader.c b/src/game_loader.c index 76fa684..6540654 100644 --- a/src/game_loader.c +++ b/src/game_loader.c @@ -26,6 +26,7 @@ #include "my.h" #include "map_editor.h" #include "components/xp_component.h" +#include "components/health_component.h" const struct callback callbacks[] = { {"start_button", &start_button}, @@ -80,6 +81,7 @@ int register_customcmps(gc_engine *engine, bool map_editor) engine->add_component(engine, &attack_component); engine->add_component(engine, &combat_holder); engine->add_system(engine, new_system(&combat_manager, engine)); + engine->add_component(engine, &health_component); engine->finish_physics(engine); engine->add_dataloader(engine, "enemies", &enemies_dataloader); diff --git a/src/systems/game_display_system.c b/src/systems/game_display_system.c index d72c237..4f11b6b 100644 --- a/src/systems/game_display_system.c +++ b/src/systems/game_display_system.c @@ -15,6 +15,7 @@ #include "text.h" #include "components/renderer.h" #include +#include "components/health_component.h" #include "sprite.h" void display_current_texture(gc_scene *scene, struct renderer *rend) @@ -28,6 +29,25 @@ void display_current_texture(gc_scene *scene, struct renderer *rend) ((gc_sprite *)rend->data)->texture = map->selected_texture; } +void display_current_health(gc_scene *scene, struct renderer *rend, bool is_player) +{ + gc_list *entities = scene->get_entity_by_cmp(scene, "health_component"); + gc_entity *entity = NULL; + struct health_component *health_cmp = NULL; + static char str[10]; + + if (!entities) + return; + for (; entities->next || !entity; entities = entities->next ) { + entity = entities->data; + if ((entity->id == 50 && is_player) || (entity->id != 50 && !is_player)) + break; + } + health_cmp = GETCMP(entity, health_component); + snprintf(str, 10, "%d/%d", health_cmp->health, health_cmp->health_max); + ((gc_text *)rend->data)->text = str; +} + void display_current_xp(gc_scene *scene, struct renderer *rend) { gc_entity *player = scene->get_entity(scene, 50); @@ -50,7 +70,7 @@ float dtime) struct renderer *rend = GETCMP(entity, renderer); gc_scene *scene = engine->scene; - if (disp->type == SELECT_TILE_DISPLAY && rend->type == GC_TEXTUREREND){ + if (disp->type == SELECT_TILE_DISPLAY && rend->type == GC_TEXTUREREND) { display_current_texture(scene, rend); return; } @@ -58,6 +78,14 @@ float dtime) display_current_xp(scene, rend); return; } + if (disp->type == HEALTH_DISPLAY && rend->type == GC_TXTREND) { + display_current_health(scene, rend, true); + return; + } + if (disp->type == HEALTH_DISPLAY_ENNEMY && rend->type == GC_TXTREND) { + display_current_health(scene, rend, false); + return; + } } static void destroy(void *system, gc_engine *engine) diff --git a/utility/do_stuff.py b/utility/do_stuff.py new file mode 100755 index 0000000..0b8409f --- /dev/null +++ b/utility/do_stuff.py @@ -0,0 +1,21 @@ +#!/usr/bin/python3 +import sys, xml.etree.ElementTree as ET + +try: + file_entity = sys.argv[1] + elements = sys.argv[2:] +except IndexError: + print(f"Usage: {sys.argv[0]} file entity") + sys.exit(1) +tree = ET.parse(file_entity) +root = tree.getroot() +for entity in root.findall("gc_entity"): + attribs = entity.find('map_linker').attrib + attribs['name'] = entity.find("renderer").get("src") + #print(f"x:{attribs['x']} y:{attribs['y']} name:{attribs['name']}") + if not (attribs['name'] in elements): + continue + attribs['x'] = str(int(attribs['x']) - 1) + attribs['y'] = str(int(attribs['y']) + 1) + +tree.write(file_entity) \ No newline at end of file diff --git a/utility/entity_checker.py b/utility/entity_checker.py new file mode 100755 index 0000000..31419d3 --- /dev/null +++ b/utility/entity_checker.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 +import sys, xml.etree.ElementTree as ET + +try: + file_entity = sys.argv[1] + file_map = sys.argv[2] + elements_to_get_rid_of = sys.argv[3:] +except IndexError: + print(f"Usage: {sys.argv[0]} file entity file map items to get rid of") + sys.exit(1) +treemap = ET.parse(file_map) +rootmap = treemap.getroot() +tree = ET.parse(file_entity) +root = tree.getroot() +for entity in root.findall("gc_entity"): + attribs = entity.find('map_linker').attrib + attribs['name'] = entity.find("renderer").get("src") + #print(f"x:{attribs['x']} y:{attribs['y']} name:{attribs['name']}") + if not (attribs['name'] in elements_to_get_rid_of): + continue + for tile in rootmap.findall("./tiles_data/tile"): + tile_info = tile.attrib + # print(f"x:{tile_info['x']} y:{tile_info['y']} texture:{tile_info['texture']}") + + if not (tile_info['x'] == attribs['x'] and tile_info['y'] == attribs['y']): + continue + if (tile_info['texture'] == "grass_top" or tile_info['texture'] == "stone"): + continue + root.remove(entity) + break +tree.write(file_entity) \ No newline at end of file diff --git a/utility/entity_set_centered.py b/utility/entity_set_centered.py new file mode 100755 index 0000000..7b6ede5 --- /dev/null +++ b/utility/entity_set_centered.py @@ -0,0 +1,20 @@ +#!/usr/bin/python3 +import sys, xml.etree.ElementTree as ET + +try: + file_entity = sys.argv[1] + elements_to_get_rid_of = sys.argv[2:] +except IndexError: + print(f"Usage: {sys.argv[0]} file entity") + sys.exit(1) +tree = ET.parse(file_entity) +root = tree.getroot() +for entity in root.findall("gc_entity"): + attribs = entity.find('map_linker').attrib + attribs['name'] = entity.find("renderer").get("src") + #print(f"x:{attribs['x']} y:{attribs['y']} name:{attribs['name']}") + if (attribs['name'] in elements_to_get_rid_of): + continue + attribs['centered'] = "true" + +tree.write(file_entity) \ No newline at end of file diff --git a/utility/entity_setter.py b/utility/entity_setter.py index 2fd39fa..c6aa2bb 100755 --- a/utility/entity_setter.py +++ b/utility/entity_setter.py @@ -22,7 +22,7 @@ for i in range(max_height - min_height + 1): print(f""" - +