mirror of
https://github.com/zoriya/ForecastingVillage.git
synced 2026-06-09 21:08:50 +00:00
Merging the combat
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 215 B |
@@ -10,7 +10,9 @@
|
|||||||
typedef enum display_type
|
typedef enum display_type
|
||||||
{
|
{
|
||||||
SELECT_TILE_DISPLAY,
|
SELECT_TILE_DISPLAY,
|
||||||
XP_DISPLAY
|
XP_DISPLAY,
|
||||||
|
HEALTH_DISPLAY,
|
||||||
|
HEALTH_DISPLAY_ENNEMY
|
||||||
} display_type_enum;
|
} display_type_enum;
|
||||||
|
|
||||||
struct game_display
|
struct game_display
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
struct health_component
|
struct health_component
|
||||||
{
|
{
|
||||||
gc_component base;
|
gc_component base;
|
||||||
|
int health_max;
|
||||||
int health;
|
int health;
|
||||||
bool dead;
|
bool dead;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,4 +25,4 @@ unsigned int amount);
|
|||||||
|
|
||||||
extern const struct xp_component xp_component;
|
extern const struct xp_component xp_component;
|
||||||
|
|
||||||
#endif //MY_RPG_HEALTH_COMPONENT_H
|
#endif //MY_RPG_XP_COMPONENT_H
|
||||||
|
|||||||
+1
-1
Submodule lib/gamacon updated: 845620bd43...5d78e62f4a
+16
-5
@@ -80,12 +80,12 @@
|
|||||||
<sprite name="water_top" src="assets/tiles/generic-rpg-tile-waterfall06.png" />
|
<sprite name="water_top" src="assets/tiles/generic-rpg-tile-waterfall06.png" />
|
||||||
<sprite name="water_top_right_left" src="assets/tiles/generic-rpg-tile-waterfall07.png" />
|
<sprite name="water_top_right_left" src="assets/tiles/generic-rpg-tile-waterfall07.png" />
|
||||||
<sprite name="water" src="assets/tiles/generic-rpg-plain-water.png" />
|
<sprite name="water" src="assets/tiles/generic-rpg-plain-water.png" />
|
||||||
|
<sprite name="stone" src="assets/tiles/stone.png" />
|
||||||
<sprite name="panel" src="assets/ui/panel.png" />
|
<sprite name="panel" src="assets/ui/panel.png" />
|
||||||
|
|
||||||
<tiles>
|
<tiles>
|
||||||
<tile name="dirt_top_right_1" />
|
<tile name="dirt_inner_top_left" />
|
||||||
<tile name="grass_top" />
|
<tile name="dirt_top_right_0" />
|
||||||
<tile name="dirt" />
|
<tile name="dirt" />
|
||||||
</tiles>
|
</tiles>
|
||||||
|
|
||||||
@@ -111,6 +111,15 @@
|
|||||||
<sprite name="coop" src="assets/sprites/houses/Coop.png" />
|
<sprite name="coop" src="assets/sprites/houses/Coop.png" />
|
||||||
<sprite name="town_hall" src="assets/sprites/houses/Community_Center.png" />
|
<sprite name="town_hall" src="assets/sprites/houses/Community_Center.png" />
|
||||||
|
|
||||||
|
<sprite name="item_grass_0" src="assets/sprites/items/generic-rpg-grass01.png" />
|
||||||
|
<sprite name="item_grass_1" src="assets/sprites/items/generic-rpg-grass02.png" />
|
||||||
|
<sprite name="item_flower_0" src="assets/sprites/items/generic-rpg-flower01.png" />
|
||||||
|
<sprite name="item_flower_1" src="assets/sprites/items/generic-rpg-flower02.png" />
|
||||||
|
<sprite name="item_flower_2" src="assets/sprites/items/generic-rpg-flower03.png" />
|
||||||
|
<sprite name="item_rock_0" src="assets/sprites/items/generic-rpg-rock03.png" />
|
||||||
|
<sprite name="item_rock_1" src="assets/sprites/items/generic-rpg-rock04.png" />
|
||||||
|
<sprite name="item_rock_2" src="assets/sprites/items/generic-rpg-rock05.png" />
|
||||||
|
|
||||||
<sprite name="main_ui_game" src="assets/ui/health_and_xp.png" />
|
<sprite name="main_ui_game" src="assets/ui/health_and_xp.png" />
|
||||||
<music src="assets/musics/windless_slopes.ogg"/>
|
<music src="assets/musics/windless_slopes.ogg"/>
|
||||||
<font src="assets/fonts/roboto.ttf" />
|
<font src="assets/fonts/roboto.ttf" />
|
||||||
@@ -168,8 +177,10 @@
|
|||||||
|
|
||||||
|
|
||||||
<panel src="main_ui_game" x="3%" y="2%" width="30%" height="15%" centered="false"/>
|
<panel src="main_ui_game" x="3%" y="2%" width="30%" height="15%" centered="false"/>
|
||||||
<text text="/20" x="13%" y="6%" centered="false"/>
|
<text text="Loading" x="13%" y="6%" centered="false">
|
||||||
<text text="10/100" x="14%" y="14%" centered="false">
|
<game_display stats="health"/>
|
||||||
|
</text>
|
||||||
|
<text text="Loading" x="14%" y="14%" centered="false">
|
||||||
<game_display stats="xp"/>
|
<game_display stats="xp"/>
|
||||||
</text>
|
</text>
|
||||||
</gc_entities>
|
</gc_entities>
|
||||||
|
|||||||
+2680
-1080
File diff suppressed because it is too large
Load Diff
+35
-34
@@ -5,38 +5,39 @@
|
|||||||
<Size x="100" y="100" />
|
<Size x="100" y="100" />
|
||||||
</transform_component>
|
</transform_component>
|
||||||
<renderer src="player">
|
<renderer src="player">
|
||||||
<Rect height="147" width="138" top="0" left="0" />
|
<Rect height="147" width="138" top="0" left="0" />
|
||||||
<animation name="walk_down_left" frame_count="6" frame_rate="10">
|
<animation name="walk_down_left" frame_count="6" frame_rate="10">
|
||||||
<Rect top="192" left="138" />
|
<Rect top="192" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
<animation name="walk_up_left" frame_count="6" frame_rate="10">
|
<animation name="walk_up_left" frame_count="6" frame_rate="10">
|
||||||
<Rect top="576" left="138" />
|
<Rect top="576" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
<animation name="walk_up_right" frame_count="6" frame_rate="10">
|
<animation name="walk_up_right" frame_count="6" frame_rate="10">
|
||||||
<Rect top="960" left="138" />
|
<Rect top="960" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
<animation name="walk_down_right" frame_count="6" frame_rate="10">
|
<animation name="walk_down_right" frame_count="6" frame_rate="10">
|
||||||
<Rect top="1344" left="138" />
|
<Rect top="1344" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
<animation name="walk_down" frame_count="6" frame_rate="10">
|
<animation name="walk_down" frame_count="6" frame_rate="10">
|
||||||
<Rect top="0" left="138" />
|
<Rect top="0" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
<animation name="walk_up" frame_count="6" frame_rate="10">
|
<animation name="walk_up" frame_count="6" frame_rate="10">
|
||||||
<Rect top="768" left="138" />
|
<Rect top="768" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
<animation name="walk_right" frame_count="6" frame_rate="10">
|
<animation name="walk_right" frame_count="6" frame_rate="10">
|
||||||
<Rect top="1152" left="138" />
|
<Rect top="1152" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
<animation name="walk_left" frame_count="6" frame_rate="10">
|
<animation name="walk_left" frame_count="6" frame_rate="10">
|
||||||
<Rect top="384" left="138" />
|
<Rect top="384" left="138" />
|
||||||
</animation>
|
</animation>
|
||||||
</renderer>
|
</renderer>
|
||||||
<camerafollow_component/>
|
<camerafollow_component/>
|
||||||
<controllable_component />
|
<controllable_component />
|
||||||
<keyboard_controller left="16" right="3" up="25" down="18" />
|
<keyboard_controller left="16" right="3" up="25" down="18" />
|
||||||
<map_movement />
|
<map_movement />
|
||||||
<map_linker x="1" y="1" solid="false" />
|
<map_linker x="1" y="1" solid="false"/>
|
||||||
<xp_component xp="20"/>
|
<xp_component xp="20"/>
|
||||||
<player_component fight_rate="100%" />
|
<health_component max_health="420"/>
|
||||||
</gc_entity>
|
<player_component fight_rate="100%" />
|
||||||
|
</gc_entity>
|
||||||
</gc_entities>
|
</gc_entities>
|
||||||
|
|||||||
+892
-892
File diff suppressed because it is too large
Load Diff
@@ -32,12 +32,15 @@ static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
|
|||||||
}
|
}
|
||||||
if (!my_strcmp(display_type, "selected_tile")) {
|
if (!my_strcmp(display_type, "selected_tile")) {
|
||||||
cmp->type = SELECT_TILE_DISPLAY;
|
cmp->type = SELECT_TILE_DISPLAY;
|
||||||
return;
|
} if (!my_strcmp(display_type, "xp")) {
|
||||||
}
|
|
||||||
if (!my_strcmp(display_type, "xp")) {
|
|
||||||
cmp->type = XP_DISPLAY;
|
cmp->type = XP_DISPLAY;
|
||||||
rend->destroy = &text_safe_destroy;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,8 @@ static void ctr(void *component, va_list args)
|
|||||||
{
|
{
|
||||||
struct health_component *cmp = (struct health_component *)\
|
struct health_component *cmp = (struct health_component *)\
|
||||||
component;
|
component;
|
||||||
cmp->health = va_arg(args, int);
|
cmp->health_max = va_arg(args, int);
|
||||||
|
cmp->health = cmp->health_max;
|
||||||
cmp->dead = false;
|
cmp->dead = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -23,7 +24,10 @@ void *component, node *n)
|
|||||||
struct health_component *cmp = (struct health_component *)\
|
struct health_component *cmp = (struct health_component *)\
|
||||||
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;
|
cmp->dead = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,5 +25,7 @@ unsigned int amount)
|
|||||||
if (this->dead)
|
if (this->dead)
|
||||||
return;
|
return;
|
||||||
this->health += amount;
|
this->health += amount;
|
||||||
|
if (this->health > this->health_max)
|
||||||
|
this->health = this->health_max;
|
||||||
engine->trigger_event(engine, "add_health", this->health, amount);
|
engine->trigger_event(engine, "add_health", this->health, amount);
|
||||||
}
|
}
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "my.h"
|
#include "my.h"
|
||||||
#include "map_editor.h"
|
#include "map_editor.h"
|
||||||
#include "components/xp_component.h"
|
#include "components/xp_component.h"
|
||||||
|
#include "components/health_component.h"
|
||||||
|
|
||||||
const struct callback callbacks[] = {
|
const struct callback callbacks[] = {
|
||||||
{"start_button", &start_button},
|
{"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, &attack_component);
|
||||||
engine->add_component(engine, &combat_holder);
|
engine->add_component(engine, &combat_holder);
|
||||||
engine->add_system(engine, new_system(&combat_manager, engine));
|
engine->add_system(engine, new_system(&combat_manager, engine));
|
||||||
|
engine->add_component(engine, &health_component);
|
||||||
engine->finish_physics(engine);
|
engine->finish_physics(engine);
|
||||||
engine->add_dataloader(engine, "enemies", &enemies_dataloader);
|
engine->add_dataloader(engine, "enemies", &enemies_dataloader);
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "components/renderer.h"
|
#include "components/renderer.h"
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
|
#include "components/health_component.h"
|
||||||
#include "sprite.h"
|
#include "sprite.h"
|
||||||
|
|
||||||
void display_current_texture(gc_scene *scene, struct renderer *rend)
|
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;
|
((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)
|
void display_current_xp(gc_scene *scene, struct renderer *rend)
|
||||||
{
|
{
|
||||||
gc_entity *player = scene->get_entity(scene, 50);
|
gc_entity *player = scene->get_entity(scene, 50);
|
||||||
@@ -50,7 +70,7 @@ float dtime)
|
|||||||
struct renderer *rend = GETCMP(entity, renderer);
|
struct renderer *rend = GETCMP(entity, renderer);
|
||||||
gc_scene *scene = engine->scene;
|
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);
|
display_current_texture(scene, rend);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,6 +78,14 @@ float dtime)
|
|||||||
display_current_xp(scene, rend);
|
display_current_xp(scene, rend);
|
||||||
return;
|
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)
|
static void destroy(void *system, gc_engine *engine)
|
||||||
|
|||||||
Executable
+21
@@ -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)
|
||||||
Executable
+31
@@ -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)
|
||||||
Executable
+20
@@ -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)
|
||||||
@@ -22,7 +22,7 @@ for i in range(max_height - min_height + 1):
|
|||||||
print(f"""<gc_entity>
|
print(f"""<gc_entity>
|
||||||
<transform_component>
|
<transform_component>
|
||||||
<Position x="0" y="0" />
|
<Position x="0" y="0" />
|
||||||
<Size x="150" y="200" />
|
<Size x="30" y="30" />
|
||||||
</transform_component>
|
</transform_component>
|
||||||
<renderer src="{entity}">
|
<renderer src="{entity}">
|
||||||
<Rect height="auto" width="auto" top="0" left="0" />
|
<Rect height="auto" width="auto" top="0" left="0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user