From bf2520d71e770c303c6878a1515e069b22eb4452 Mon Sep 17 00:00:00 2001 From: esquizo Date: Wed, 3 Jun 2026 23:39:16 -0300 Subject: game: adicionado goal entity --- game.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'game.c') 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; @@ -132,6 +143,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) { -- cgit v1.2.3