akimbo bug fixed; some new bugs added
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4598 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
+15
-15
@@ -10,15 +10,15 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1
|
||||
float lx = light.x+(flicker ? (rnd(21)-10)*0.1f : 0);
|
||||
float ly = light.y+(flicker ? (rnd(21)-10)*0.1f : 0);
|
||||
float dx = bx-lx;
|
||||
float dy = by-ly;
|
||||
float dy = by-ly;
|
||||
float dist = (float)sqrt(dx*dx+dy*dy);
|
||||
if(dist<1.0f) return;
|
||||
int reach = light.attr1;
|
||||
int steps = (int)(reach*reach*1.6f/dist); // can change this for speedup/quality?
|
||||
const int PRECBITS = 12;
|
||||
const float PRECF = 4096.0f;
|
||||
int x = (int)(lx*PRECF);
|
||||
int y = (int)(ly*PRECF);
|
||||
int x = (int)(lx*PRECF);
|
||||
int y = (int)(ly*PRECF);
|
||||
int fadescale = (int)(fade*PRECF);
|
||||
int l = light.attr2*fadescale;
|
||||
int stepx = (int)(dx/(float)steps*PRECF);
|
||||
@@ -34,7 +34,7 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1
|
||||
{
|
||||
if(flicker)
|
||||
{
|
||||
int dimness = rnd((((255<<PRECBITS)-(int(light.attr2)+int(light.attr3)+int(light.attr4))*fadescale/3)>>(PRECBITS+4))+1);
|
||||
int dimness = rnd((((255<<PRECBITS)-(int(light.attr2)+int(light.attr3)+int(light.attr4))*fadescale/3)>>(PRECBITS+4))+1);
|
||||
x += stepx*dimness;
|
||||
y += stepy*dimness;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1
|
||||
stepb /= lightscale;
|
||||
loopi(steps)
|
||||
{
|
||||
sqr *s = S(x>>PRECBITS, y>>PRECBITS);
|
||||
sqr *s = S(x>>PRECBITS, y>>PRECBITS);
|
||||
int tl = (l>>PRECBITS)+s->r;
|
||||
s->r = tl>255 ? 255 : tl;
|
||||
tl = (g>>PRECBITS)+s->g;
|
||||
@@ -73,7 +73,7 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1
|
||||
{
|
||||
if(flicker)
|
||||
{
|
||||
int dimness = rnd((((255<<PRECBITS)-(light.attr2*fadescale))>>(PRECBITS+4))+1);
|
||||
int dimness = rnd((((255<<PRECBITS)-(light.attr2*fadescale))>>(PRECBITS+4))+1);
|
||||
x += stepx*dimness;
|
||||
y += stepy*dimness;
|
||||
}
|
||||
@@ -82,9 +82,9 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1
|
||||
|
||||
loopi(steps)
|
||||
{
|
||||
sqr *s = S(x>>PRECBITS, y>>PRECBITS);
|
||||
sqr *s = S(x>>PRECBITS, y>>PRECBITS);
|
||||
int tl = (l>>PRECBITS)+s->r;
|
||||
s->r = s->g = s->b = tl>255 ? 255 : tl;
|
||||
s->r = s->g = s->b = tl>255 ? 255 : tl;
|
||||
if(SOLID(s)) return;
|
||||
x += stepx;
|
||||
y += stepy;
|
||||
@@ -97,7 +97,7 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1
|
||||
{
|
||||
loopi(steps)
|
||||
{
|
||||
sqr *s = S(x>>PRECBITS, y>>PRECBITS);
|
||||
sqr *s = S(x>>PRECBITS, y>>PRECBITS);
|
||||
int light = l>>PRECBITS;
|
||||
if(light>s->r) s->r = s->g = s->b = (uchar)light;
|
||||
if(SOLID(s)) return;
|
||||
@@ -106,7 +106,7 @@ void lightray(float bx, float by, const persistent_entity &light, float fade = 1
|
||||
l -= stepl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void calclightsource(const persistent_entity &l, float fade = 1, bool flicker = true)
|
||||
@@ -116,7 +116,7 @@ void calclightsource(const persistent_entity &l, float fade = 1, bool flicker =
|
||||
int ex = l.x+reach;
|
||||
int sy = l.y-reach;
|
||||
int ey = l.y+reach;
|
||||
|
||||
|
||||
const float s = 0.8f;
|
||||
|
||||
for(float sx2 = (float)sx; sx2<=ex; sx2+=s*2) { lightray(sx2, (float)sy, l, fade, flicker); lightray(sx2, (float)ey, l, fade, flicker); }
|
||||
@@ -165,7 +165,7 @@ void calclight()
|
||||
entity &e = ents[i];
|
||||
if(e.type==LIGHT) calclightsource(e);
|
||||
}
|
||||
|
||||
|
||||
block b = { 1, 1, ssize-2, ssize-2 };
|
||||
postlightarea(b);
|
||||
setvar("fullbright", 0);
|
||||
@@ -207,7 +207,7 @@ void preparedynlight(dlight &d)
|
||||
if(area.x+area.xs>ssize-2) area.xs = ssize-2-area.x;
|
||||
if(area.y+area.ys>ssize-2) area.ys = ssize-2-area.y;
|
||||
|
||||
if(d.area)
|
||||
if(d.area)
|
||||
{
|
||||
if(insidearea(*d.area, area)) return;
|
||||
|
||||
@@ -288,7 +288,7 @@ void dodynlights()
|
||||
}
|
||||
area = d.area;
|
||||
}
|
||||
if(area) postlightarea(*area);
|
||||
if(area) postlightarea(*area);
|
||||
lastcalclight = totalmillis;
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ void undodynlights()
|
||||
{
|
||||
if(dlights.empty()) return;
|
||||
const block *area = NULL;
|
||||
loopvrev(dlights)
|
||||
loopvrev(dlights)
|
||||
{
|
||||
const dlight &d = dlights[i];
|
||||
if(area)
|
||||
|
||||
Reference in New Issue
Block a user