summaryrefslogtreecommitdiff
path: root/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'game.c')
-rw-r--r--game.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/game.c b/game.c
index a3a1e66..e2cb381 100644
--- a/game.c
+++ b/game.c
@@ -12,6 +12,7 @@
static EntityCollisionProc bulletcollproc;
static EntityCollisionProc ghostcollproc;
static EntityCollisionProc teleportercollproc;
+static EntityCollisionProc goalcollproc;
static EntityUpdateProc playerproc;
static EntityUpdateProc ghostproc;
@@ -21,6 +22,7 @@ static EntityCollisionProc *collisionProcs[LASTEntity] = {
[EBULLET] = bulletcollproc,
[EGHOST] = ghostcollproc,
[ETELEPORTER] = teleportercollproc,
+ [EGOAL] = goalcollproc,
};
static EntityUpdateProc *updateprocs[LASTEntity] = {
@@ -47,6 +49,8 @@ entrestart()
void
entinit()
{
+ Entity *e;
+
player = allocentity();
player->type = EPLAYER;
player->body.pos[0] = player_x * ENTITY_SIZE * 2;
@@ -56,6 +60,13 @@ entinit()
player->life = 1;
player->alive = true;
+ e = allocentity();
+ e->type = EGOAL;
+ e->body.pos[0] = goalx * ENTITY_SIZE * 2;
+ e->body.pos[1] = goaly * ENTITY_SIZE * 2;
+ e->body.size[0] = ENTITY_SIZE;
+ e->body.size[1] = ENTITY_SIZE;
+
for(int i = 0; i < ghostcount; i++) {
Entity *e = allocentity();
e->type = EGHOST;
@@ -133,6 +144,28 @@ teleportercollproc(Entity *self, Entity *target)
}
void
+goalcollproc(Entity *self, Entity *target)
+{
+ static int goal = 0;
+ if(goal)
+ return;
+
+ if(target->type == EPLAYER && target->alive) {
+ goal = 1;
+ printf("GOAL!\n");
+
+ for(int i = 0; i < ebufi; i++) {
+ Entity *e = entitybuffer + i;
+ if(!e->active)
+ continue;
+
+ if(e->type == EGHOST)
+ e->alive = false;
+ }
+ }
+}
+
+void
playerproc(Entity *e, float delta)
{
Entity *bullet;