mirror of
https://github.com/zoriya/Gamacon.git
synced 2026-06-02 03:35:43 +00:00
Coding style
This commit is contained in:
@@ -16,11 +16,9 @@ static void ctr(void *component, va_list args)
|
||||
gc_entity *entity = va_arg(args, gc_entity *);
|
||||
struct renderer *rend;
|
||||
struct fixed_to_cam *cmp = (struct fixed_to_cam *)component;
|
||||
bool centered;
|
||||
|
||||
if (!entity)
|
||||
return;
|
||||
rend = GETCMP(entity, renderer);
|
||||
cmp->pos = va_arg(args, gc_vector2);
|
||||
cmp->per_x = va_arg(args, int);
|
||||
cmp->per_y = va_arg(args, int);
|
||||
@@ -28,10 +26,9 @@ static void ctr(void *component, va_list args)
|
||||
cmp->size_y = va_arg(args, int);
|
||||
cmp->per_w = va_arg(args, int);
|
||||
cmp->per_h = va_arg(args, int);
|
||||
centered = va_arg(args, int);
|
||||
if (!rend)
|
||||
if (!(rend = GETCMP(entity, renderer)))
|
||||
my_printf("Missing a renderer on an entity fixed to the cam.\n");
|
||||
else if (centered) {
|
||||
else if (va_arg(args, int)) {
|
||||
rend->render_mode_x = RENDER_MODE_CENTERED;
|
||||
if (rend->type != GC_TXTREND)
|
||||
rend->render_mode_y = RENDER_MODE_CENTERED;
|
||||
@@ -42,20 +39,15 @@ static void fdctr(gc_entity *entity, gc_scene *scene, void *component, node *n)
|
||||
{
|
||||
struct fixed_to_cam *cmp = (struct fixed_to_cam *)component;
|
||||
struct renderer *rend = GETCMP(entity, renderer);
|
||||
char *tmp;
|
||||
|
||||
cmp->pos.x = xml_getintprop(n, "x");
|
||||
cmp->pos.y = xml_getintprop(n, "y");
|
||||
tmp = xml_gettempprop(n, "x");
|
||||
cmp->per_x = tmp && my_strchr(tmp, '%');
|
||||
tmp = xml_gettempprop(n, "y");
|
||||
cmp->per_y = tmp && my_strchr(tmp, '%');
|
||||
cmp->per_x = xml_propcontains(n, "x", "%");
|
||||
cmp->per_y = xml_propcontains(n, "y", "%");
|
||||
cmp->size_x = xml_getintprop(n, "width");
|
||||
tmp = xml_gettempprop(n, "width");
|
||||
cmp->per_w = tmp && my_strchr(tmp, '%');
|
||||
cmp->per_w = xml_propcontains(n, "width", "%");
|
||||
cmp->size_y = xml_getintprop(n, "height");
|
||||
tmp = xml_gettempprop(n, "height");
|
||||
cmp->per_h = tmp && my_strchr(tmp, '%');
|
||||
cmp->per_h = xml_propcontains(n, "height", "%");
|
||||
if (!rend)
|
||||
my_printf("Missing a renderer on an entity fixed to the cam.\n");
|
||||
else {
|
||||
|
||||
@@ -74,9 +74,9 @@ const char *file)
|
||||
dprintf(fd, "\t</vertex_data>\n\t<tiles_data>\n");
|
||||
for (int i = 0; ve->map[i].corners[0]; i++) {
|
||||
texture = scene->get_data_ptr(scene, ve->map[i].texture);
|
||||
dprintf(fd, "\t\t<tile x=\"%d\" y=\"%d\" texture=\"%s\" rotation=\"%d\" %s/>\n", \
|
||||
ve->map[i].corners[0]->x, ve->map[i].corners[0]->y, \
|
||||
texture ? texture->name : "", ve->map[i].data, ve->map[i].solid ? "solid=\"true\"" : "");
|
||||
dprintf(fd, "\t\t<tile x=\"%d\" y=\"%d\" texture=\"%s\" \rotation=\
|
||||
\"%d\" %s/>\n", ve->map[i].corners[0]->x, ve->map[i].corners[0]->y, texture ? \
|
||||
texture->name : "", ve->map[i].data, ve->map[i].solid ? "solid=\"true\"" : "");
|
||||
}
|
||||
dprintf(fd, "\t</tiles_data>\n</gc_map>\n");
|
||||
return (!close(fd));
|
||||
|
||||
@@ -76,7 +76,7 @@ gc_animholder *holder, float dtime)
|
||||
sfmlrenderer_draw_texture(engine, entity, holder->sprite, dtime);
|
||||
}
|
||||
|
||||
void sfmlrenderer_settextpos(sfText *text, gc_entity *entity, sfFloatRect bounds)
|
||||
void sfmlrenderer_settxtpos(sfText *txt, gc_entity *entity, sfFloatRect bounds)
|
||||
{
|
||||
struct renderer *rend = GETCMP(entity, renderer);
|
||||
struct transform_component *tra = GETCMP(entity, transform_component);
|
||||
@@ -87,11 +87,11 @@ void sfmlrenderer_settextpos(sfText *text, gc_entity *entity, sfFloatRect bounds
|
||||
ori_x = bounds.width / 2;
|
||||
if (rend->render_mode_y == RENDER_MODE_CENTERED)
|
||||
ori_y = bounds.height / 2;
|
||||
sfText_setPosition(text, (sfVector2f) {
|
||||
sfText_setPosition(txt, (sfVector2f) {
|
||||
tra->position.x,
|
||||
-tra->position.y
|
||||
});
|
||||
sfText_setOrigin(text, (sfVector2f){ori_x, ori_y});
|
||||
sfText_setOrigin(txt, (sfVector2f){ori_x, ori_y});
|
||||
}
|
||||
|
||||
void sfmlrenderer_draw_txt(gc_engine *engine, gc_entity *entity, \
|
||||
@@ -114,6 +114,6 @@ gc_text *txt, float dt)
|
||||
tra->size.x = bounds.width;
|
||||
tra->size.y = bounds.height;
|
||||
sfText_setColor(this->text, *(sfColor*)&txt->color);
|
||||
sfmlrenderer_settextpos(this->text, entity, bounds);
|
||||
sfmlrenderer_settxtpos(this->text, entity, bounds);
|
||||
sfRenderWindow_drawText(this->window, this->text, NULL);
|
||||
}
|
||||
@@ -29,7 +29,8 @@ sfVertexArray *sfml_init_verticies(void)
|
||||
sfVertex v[4] = {
|
||||
{.position = {0, 0}, .texCoords = {0, 0}, .color = sfWhite},
|
||||
{.position = {0, 0}, .texCoords = {TEXTURE_WIDTH, 0}, .color = sfWhite},
|
||||
{.position = {0, 0}, .texCoords = {0, TEXTURE_HEIGHT}, .color = sfWhite},
|
||||
{.position = {0, 0}, .texCoords = {0, \
|
||||
TEXTURE_HEIGHT}, .color = sfWhite},
|
||||
{.position = {0, 0}, .texCoords = {TEXTURE_WIDTH, \
|
||||
TEXTURE_HEIGHT}, .color = sfWhite}
|
||||
};
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#include "components/transform_component.h"
|
||||
|
||||
void map_linker_update_entity(gc_engine *engine, gc_entity *entity, \
|
||||
struct tile *tile, gc_vector2 map_offset) {
|
||||
struct tile *tile, gc_vector2 map_offset)
|
||||
{
|
||||
struct map_linker *link = GETCMP(entity, map_linker);
|
||||
struct transform_component *tra = GETCMP(entity, transform_component);
|
||||
struct vertex *c = tile->corners[0];
|
||||
|
||||
+3
-4
@@ -41,10 +41,9 @@ gc_text *text)
|
||||
entity->add_component(entity, new_component(&renderer_component,
|
||||
GC_TEXTUREREND, texture, (gc_int_rect){-1, -1, 0, 0}));
|
||||
entity->add_component(entity, new_component(&fixed_to_cam,
|
||||
entity, (gc_vector2){xml_getintprop(n, "x"),xml_getintprop(n, "y")},
|
||||
true, true, s.x, s.y,
|
||||
xml_propcontains(n, "width", "%"), xml_propcontains(n, "height", "%"),
|
||||
true));
|
||||
entity, (gc_vector2){xml_getintprop(n, "x"), xml_getintprop(n, "y")},
|
||||
true, true, s.x, s.y, xml_propcontains(n, "width", "%"),
|
||||
xml_propcontains(n, "height", "%"), true));
|
||||
return (entity);
|
||||
}
|
||||
|
||||
|
||||
+3
-5
@@ -19,12 +19,10 @@
|
||||
|
||||
gc_entity *new_text(gc_engine *engine, gc_scene *scene, node *n)
|
||||
{
|
||||
gc_entity *entity;
|
||||
gc_entity *entity = xml_hasproperty(n, "text_id")
|
||||
? entity_create_with_id(xml_getintprop(n, "text_id"))
|
||||
: entity_create();
|
||||
|
||||
if (xml_hasproperty(n, "text_id"))
|
||||
entity = entity_create_with_id(xml_getintprop(n, "text_id"));
|
||||
else
|
||||
entity = entity_create();
|
||||
entity->add_component(entity, new_component(&transform_component,
|
||||
(gc_vector2){0, 0}, (gc_vector2){0, 0}));
|
||||
entity->add_component(entity, new_component(&renderer_component,
|
||||
|
||||
Reference in New Issue
Block a user