summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVito Caputo <vcaputo@pengaru.com>2018-07-12 16:33:37 -0700
committerVito Caputo <vcaputo@pengaru.com>2018-07-12 16:33:37 -0700
commitb263b3e4b295c42a36970435eb7df5373bce6c89 (patch)
treea5987e06f2f70f46ab1406b810ba911cfec0ee64
parent853b6f1c47caa825aea09d3e8fefee47098f3be7 (diff)
libstage: add {position,aabb}_map concept to stage
I added a way to set these mappings per-node, but not per-stage. This adds setters for the stage, and new nodes are created with the current per-stage setting. The nodes may still have their mapping mode changed independent of the stage and one another, but this gives a means of easily setting a global mapping mode for a given stage.
-rw-r--r--src/stage.c18
-rw-r--r--src/stage.h2
2 files changed, 20 insertions, 0 deletions
diff --git a/src/stage.c b/src/stage.c
index 1cb3995..cc8f618 100644
--- a/src/stage.c
+++ b/src/stage.c
@@ -58,6 +58,8 @@ struct stage_t {
float aspect_ratio; /* width/height ratio of stage, -1.0...1.0 range of node coordinates map to this ratio. */
v2f_t position; /* position of the stage (defaults to 0,0) */
float alpha; /* alpha to apply to all nodes */
+ stage_map_t aabb_map; /* aabb map for the stage, nodes inherit this setting at create time */
+ stage_map_t position_map; /* position map for the stage, nodes inherit this setting at create time */
};
@@ -106,6 +108,8 @@ stage_node_t * stage_node_new(stage_t *stage, int layer, const char *name, void
if (!node)
return NULL;
+ node->aabb_map = stage->aabb_map;
+ node->position_map = stage->position_map;
list_add_tail(&node->nodes, &stage->layers[layer]);
return node;
@@ -378,6 +382,20 @@ void stage_get_position(stage_t *stage, v2f_t *res_position)
}
+/* set the aabb mapping for the stage */
+void stage_set_aabb_map(stage_t *stage, stage_map_t map)
+{
+ stage->aabb_map = map;
+}
+
+
+/* set the position mapping for the stage */
+void stage_set_position_map(stage_t *stage, stage_map_t map)
+{
+ stage->position_map = map;
+}
+
+
static void map_stage_rect(const stage_t *stage, const SDL_Rect *stage_rect, stage_map_t map, float *res_w, float *res_h)
{
switch (map) {
diff --git a/src/stage.h b/src/stage.h
index 6e0a93c..7299f4a 100644
--- a/src/stage.h
+++ b/src/stage.h
@@ -45,6 +45,8 @@ void stage_set_alpha(stage_t *stage, float alpha);
void stage_get_alpha(stage_t *stage, float *res_alpha);
void stage_set_position(stage_t *stage, v2f_t *position);
void stage_get_position(stage_t *stage, v2f_t *res_position);
+void stage_set_aabb_map(stage_t *stage, stage_map_t map);
+void stage_set_position_map(stage_t *stage, stage_map_t map);
void stage_render(const stage_t *stage);
stage_node_t * stage_node_new(stage_t *stage, int layer, const char *name, void *object, stage_render_func_t render_func, stage_free_func_t free_func);
© All Rights Reserved