Allow display wrapping to be specified per shape
This commit is contained in:
19
main.c
19
main.c
@@ -32,6 +32,7 @@ typedef struct {
|
||||
int entity;
|
||||
unsigned vert_count;
|
||||
vec2_t verts[MAX_VERTS];
|
||||
uint8_t flags;
|
||||
} shape_t;
|
||||
|
||||
typedef struct {
|
||||
@@ -57,6 +58,7 @@ static shape_t shapes[MAX_SHAPES] = {
|
||||
{ 0.0, -0.04 },
|
||||
{ -0.05, -0.07 },
|
||||
},
|
||||
.flags = WRAP | CONNECT,
|
||||
},
|
||||
{
|
||||
.visible = false,
|
||||
@@ -67,6 +69,7 @@ static shape_t shapes[MAX_SHAPES] = {
|
||||
{ 0.015, -0.07 },
|
||||
{ -0.015, -0.07 },
|
||||
},
|
||||
.flags = WRAP | CONNECT,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -114,6 +117,7 @@ static void shoot()
|
||||
s->entity = id;
|
||||
s->vert_count = NELEMS(shot_verts);
|
||||
memcpy(s->verts, shot_verts, sizeof(shot_verts));
|
||||
s->flags = 0;
|
||||
|
||||
e->shapes[0] = shape_id;
|
||||
e->shape_count = 1;
|
||||
@@ -251,12 +255,11 @@ static void update()
|
||||
e->pos.x -= 2 * aspect;
|
||||
else if (e->pos.x < -aspect)
|
||||
e->pos.x += 2 * aspect;
|
||||
} else {
|
||||
if (e->pos.y > 1 || e->pos.y <= -1 || e->pos.x >= aspect
|
||||
|| e->pos.x < -aspect) {
|
||||
remove_entity(i--);
|
||||
continue;
|
||||
}
|
||||
} else if (
|
||||
e->pos.y > 1 || e->pos.y <= -1 || e->pos.x >= aspect
|
||||
|| e->pos.x < -aspect) {
|
||||
remove_entity(i--);
|
||||
continue;
|
||||
}
|
||||
|
||||
transforms[i] = entity_transform(i);
|
||||
@@ -270,7 +273,9 @@ static void draw()
|
||||
continue;
|
||||
|
||||
const mat3_t transform = transforms[shapes[i].entity];
|
||||
renderer_draw(shapes[i].verts, shapes[i].vert_count, transform);
|
||||
renderer_draw(
|
||||
shapes[i].verts, shapes[i].vert_count, transform,
|
||||
shapes[i].flags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user