summaryrefslogtreecommitdiff
path: root/game.c
diff options
context:
space:
mode:
Diffstat (limited to 'game.c')
-rw-r--r--game.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/game.c b/game.c
index d305318..a3a1e66 100644
--- a/game.c
+++ b/game.c
@@ -11,13 +11,16 @@
static EntityCollisionProc bulletcollproc;
static EntityCollisionProc ghostcollproc;
+static EntityCollisionProc teleportercollproc;
+
static EntityUpdateProc playerproc;
static EntityUpdateProc ghostproc;
static EntityUpdateProc bulletproc;
static EntityCollisionProc *collisionProcs[LASTEntity] = {
- [EBULLET] = bulletcollproc,
- [EGHOST] = ghostcollproc,
+ [EBULLET] = bulletcollproc,
+ [EGHOST] = ghostcollproc,
+ [ETELEPORTER] = teleportercollproc,
};
static EntityUpdateProc *updateprocs[LASTEntity] = {
@@ -63,6 +66,17 @@ entinit()
e->life = 2;
e->alive = true;
}
+
+ for(int i = 0; i < telessize; i++) {
+ Entity *e = allocentity();
+ e->type = ETELEPORTER;
+ e->body.pos[0] = teles[i].x * ENTITY_SIZE * 2;
+ e->body.pos[1] = teles[i].y * ENTITY_SIZE * 2;
+ e->body.size[0] = ENTITY_SIZE;
+ e->body.size[1] = ENTITY_SIZE;
+ e->telex = floorf(teles[i].x);
+ e->teley = floorf(teles[i].y);
+ }
}
void
@@ -105,6 +119,20 @@ ghostcollproc(Entity *self, Entity *target)
}
void
+teleportercollproc(Entity *self, Entity *target)
+{
+ if(target->type == EPLAYER && target->alive) {
+ for(int i = 0; i < telemapsize; i++) {
+ if(self->telex == telemap[i].ftx && self->teley == telemap[i].fty) {
+ target->body.pos[0] = telemap[i].ttx * ENTITY_SIZE * 2;
+ target->body.pos[1] = telemap[i].tty * ENTITY_SIZE * 2;
+ break;
+ }
+ }
+ }
+}
+
+void
playerproc(Entity *e, float delta)
{
Entity *bullet;