home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 108
/
jogo-disk-108.iso
/
Games
/
Titans
/
beastboy.swf
/
scripts
/
DefineSprite_379
/
frame_1
/
DoAction.as
Wrap
Text File
|
2010-05-15
|
6KB
|
299 lines
function cekbound(changeto)
{
var newpw = r.twidth[changeto];
var newph = r.theight[changeto];
ok = 0;
var left = -99999;
var i = 0;
while(i < b.length)
{
var l = b[i];
if(r.y2 > l.y1 and r.y1 < l.y2)
{
if(p._x > l.x2 and l.x2 > left)
{
left = l.x2;
}
}
i++;
}
var right = 99999;
var i = 0;
while(i < b.length)
{
var l = b[i];
if(r.y2 > l.y1 and r.y1 < l.y2)
{
if(p._x < l.x1 and l.x1 < right)
{
right = l.x1;
}
}
i++;
}
var up = cekup();
var down = cekdown();
if(math.abs(left - right) > 2 * newpw and math.abs(up - down) > newph)
{
ok = 1;
xpos = p._x;
if(changeto == 3)
{
ypos = p._y - 50;
}
else
{
ypos = p._y - 1;
}
if(xpos - left < newpw)
{
xpos = left + newpw;
}
else if(right - xpos < newpw)
{
xpos = right - newpw;
}
if(ypos - up < newph)
{
ypos = up + newph;
}
}
if(ok)
{
return {x:xpos,y:ypos};
}
return 0;
}
function cekup()
{
var up = -9999;
var i = 0;
while(i < b.length)
{
var l = b[i];
if(l.t == 0)
{
if(r.x2 > l.x1 and r.x1 < l.x2)
{
if(r.y2 >= l.y2 and l.y2 > up)
{
up = l.y2;
}
}
}
i++;
}
return up;
}
function cekdown()
{
var down = 9999;
var i = 0;
while(i < b.length)
{
var l = b[i];
if(r.x2 > l.x1 and r.x1 < l.x2)
{
if(r.y2 <= l.y1 and l.y1 < down)
{
down = l.y1;
}
}
i++;
}
r.floatbelow = 0;
var i = 0;
while(i < c.length)
{
var l = c[i];
if(r.x2 > l.x1 and r.x1 < l.x2)
{
if(r.y2 <= l.y1 and l.y1 < down)
{
down = l.y1;
r.floatbelow = l.n;
}
}
i++;
}
return down;
}
movieclip.prototype.cekstep = function()
{
if(!r.jump)
{
var land = 9999;
var i = 0;
while(i < b.length)
{
var l = b[i];
if(r.x2 > l.x1 and r.x1 < l.x2)
{
if(r.y2 == l.y1)
{
land = l.y1;
}
}
i++;
}
var i = 0;
while(i < c.length)
{
var l = c[i];
if(r.x2 > l.x1 and r.x1 < l.x2)
{
if(r.y2 == l.y1)
{
land = l.y1;
}
}
i++;
}
if(land == 9999)
{
r.onfloat = 0;
r.jump = 1;
r.vy = 100;
}
}
};
movieclip.prototype.cekleft = function(bumper)
{
var wall = -99999;
var i = 0;
while(i < b.length)
{
var l = b[i];
if(r.y2 > l.y1 and r.y1 < l.y2)
{
if(p._x + r.pw > l.x2 + bumper and l.x2 + bumper > wall)
{
wall = l.x2 + bumper;
}
}
i++;
}
if(r.nx - r.pw < wall)
{
r.nx = wall + r.pw + 0.1;
r.x1 = r.nx - r.pw;
r.x2 = r.nx + r.pw;
r.xs = 0;
}
return wall;
};
movieclip.prototype.cekright = function(bumper)
{
var wall = 99999;
var i = 0;
while(i < b.length)
{
var l = b[i];
if(r.y2 > l.y1 and r.y1 < l.y2)
{
if(p._x - r.pw < l.x1 - bumper and l.x1 - bumper < wall)
{
wall = l.x1 - bumper;
}
}
i++;
}
if(r.nx + r.pw > wall)
{
r.nx = wall - r.pw - 0.1;
r.x1 = r.nx - r.pw;
r.x2 = r.nx + r.pw;
r.xs = 0;
}
return wall;
};
movieclip.prototype.updatefloat = function()
{
var i = 0;
while(i < c.length)
{
var l = c[i];
if(l.xs != 0)
{
var nx = l.x1 + l.xs;
if(nx < l.xmin)
{
nx = l.xmin;
l.xs = math.abs(l.xs);
}
if(nx > l.xmax)
{
nx = l.xmax;
l.xs = - math.abs(l.xs);
}
ldis = nx - l.x1;
l.x1 = nx;
l.x2 = l.x1 + l.w;
l.xc = l.x1 + 0.5 * l.w;
m[l.n]._x = l.x1;
if(r.onfloat == l.n)
{
r.nx = p._x + ldis;
r.x1 = p._x - r.pw;
r.x2 = p._x + r.pw;
if(ldis < 0)
{
cekleft();
}
else
{
cekright();
}
p._x = r.nx;
}
}
if(l.ys != 0)
{
var ny = l.y1 + l.ys;
if(ny < l.ymin)
{
ny = l.ymin;
l.ys = math.abs(l.ys);
}
if(ny > l.ymax)
{
ny = l.ymax;
l.ys = - math.abs(l.ys);
}
l.y1 = ny;
l.y2 = l.y1 + l.hi;
m[l.n]._y = l.y1;
if(r.onfloat == l.n)
{
r.y1 = l.y1 - r.ph;
r.y2 = l.y1;
r.x1 = p._x - r.pw;
r.x2 = p._x + r.pw;
if(l.ys < 0)
{
up = cekup();
if(r.y1 - l.ys < up)
{
r.y1 = up + 0.1;
r.y2 = up + r.ph;
r.onfloat = 0;
r.jump = 1;
}
}
else
{
down = cekdown();
if(r.y2 + l.ys > down)
{
r.y2 = down;
r.y1 = r.y2 - r.ph;
r.onfloat = 0;
}
}
p._y = r.y2;
}
}
i++;
}
};