From 79801b6b794a5fb50a3a013354323a48de37c050 Mon Sep 17 00:00:00 2001 From: neoraider Date: Fri, 20 Oct 2006 12:57:05 +0000 Subject: Physik-Engine angefangen. Lightmaps implementiert. --- player.c | 45 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'player.c') diff --git a/player.c b/player.c index e5b0fdf..7250009 100644 --- a/player.c +++ b/player.c @@ -20,6 +20,7 @@ float rotxspeed = 0, rotyspeed = 0; float objrot = 0; extern LEVEL level; +extern LIGHT light; void MouseInput(int x, int y) { roty += x * 0.3; @@ -188,12 +189,12 @@ void DoInput(int delta) { player.rotysin = s; player.rotycos = c; - for(i = 0; i < level.rooms[player.room].nObjects; i++) { - pos = VectorSub(level.rooms[player.room].objects[i].pos, player.pos); + for(i = 0; i < level.rooms[player.room].nThings; i++) { + pos = VectorSub(level.rooms[player.room].things[i].pos, player.pos); pos.y += 0.9; - switch(level.rooms[player.room].objects[i].type) { - case OBJECT_MEDIPAK100: - if((pos.x*pos.x + (pos.y*pos.y)/3 + pos.z*pos.z) < 0.36) level.rooms[player.room].objects[i].visible = 0; + switch(level.rooms[player.room].things[i].type) { + case THING_MEDIPAK100: + if((pos.x*pos.x + (pos.y*pos.y)/3 + pos.z*pos.z) < 0.36) level.rooms[player.room].things[i].visible = 0; } } @@ -212,4 +213,38 @@ void DoInput(int delta) { } else level.rooms[player.room].gateinfo[i].timer -= delta; } + + static int lightpos = 0; + + lightpos += delta; + lightpos %= 24000; + + if(lightpos < 12000) i = lightpos; + else i = 24000 - lightpos; + + if(i == 0) { + light.pos.x = 0.0; + light.pos.y = 0.0; + light.pos.z = 0.0; + } + else if(i < 4000) { + light.pos.x = 0.0; + light.pos.y = 0.0; + light.pos.z = -i * 0.001; + } + else if(i < 8000) { + light.pos.x = (i-4000) * 0.001; + light.pos.y = 0.0; + light.pos.z = -4.0; + } + else if(i < 12000) { + light.pos.x = 4.0; + light.pos.y = 0.0; + light.pos.z = -4.0 - (i-8000) * 0.001; + } + else { + light.pos.x = 4.0; + light.pos.y = 0.0; + light.pos.z = -8.0; + } } -- cgit v1.2.3