diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | game.c | 21 | ||||
| -rw-r--r-- | map.png | bin | 905 -> 913 bytes | |||
| -rw-r--r-- | map_data.c | 8 |
4 files changed, 29 insertions, 3 deletions
@@ -2,7 +2,8 @@ OBJ=\ sdl3_main.o\ physics.o\ map.o\ - game.o + game.o\ + map_data.o LDFLAGS=`pkg-config --libs sdl3` -lm CFLAGS=`pkg-config --cflags sdl3` -O2 -Iinclude @@ -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] = { @@ -116,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; Binary files differdiff --git a/map_data.c b/map_data.c new file mode 100644 index 0000000..e673de8 --- /dev/null +++ b/map_data.c @@ -0,0 +1,8 @@ +struct { + int ftx, fty; + int ttx, tty; +} telemap[] = { + { 10, 5, 131, 3 }, + { 138, 6, 3, 4 }, +}; +int telemapsize = sizeof telemap / sizeof telemap[0]; |
