Forum

> > CS2D > Scripts > Vectors
Forums overviewCS2D overview Scripts overviewLog in to reply

English Vectors

4 replies
To the start Previous 1 Next To the start

old Vectors

xSkyLordx
User Off Offline

Quote
Hi all
i need help
Bug video:
http://www.youtube.com/watch?v=09lwcalAggg&context=C3f38ba4ADOEgsToPDskJtp6pILg25QYtPaYVC6ApW

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function _bug(id,x,y,rot)
local b={x = x,y = y,rot = rot,id = id,img = image("gfx/bug.bmp",1,1,3),inmap = 1,speed=0.1}
table.insert(o,b)
imagepos(b.img,x,y,0)
end

addhook("say","_createbug")
function _createbug(id,t)
if t=="!lbug" then
_bug(id,player(id,"x"),player(id,"y"),player(id,"rot"))
end
end

timer(1,"bugopt","",0)

function bugopt()
for k, v in ipairs(o) do
if o[k].inmap == 1 then
o[k].speed = o[k].speed + 0.1/2
local rot = o[k].rot
if rot < -90 then rot = rot + 360 end
local ang = math.abs(math.rad( rot + 90 )) - math.pi
local x = o[k].x + math.cos(ang) * o[k].speed
local y = o[k].y + math.sin(ang) * o[k].speed
imagepos(o[k].img,x,y,o[k].rot)
o[k].x = x
o[k].y = y
if tile(math.floor(x/32),math.floor(y/32),"wall") then
o[k].rot = 180-o[k].rot
end
end
end
end

1
o[k].rot = 180-o[k].rot --BUG

Help me please, i looking LaserMod but i cant understand

old Re: Vectors

Starkkz
Moderator Off Offline

Quote
seems that the walls do have different collisions

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function bugopt()
	for k, v in ipairs(o) do
		if o[k].inmap == 1 then
			o[k].speed = o[k].speed + 0.1/2
			local rot = o[k].rot
			local ang = math.rad(rot)
			local x = o[k].x + math.sin(ang) * o[k].speed
			local y = o[k].y - math.cos(ang) * o[k].speed
			
			if tile(math.floor(o[k].x/32),math.floor(y/32),"wall") then
				o[k].rot = o[k].rot - 180
			end
			if tile(math.floor(x/32),math.floor(o[k].y/32),"wall") then
				o[k].rot = -o[k].rot
			end
			
			imagepos(o[k].img,x,y,o[k].rot)
			o[k].x = x
			o[k].y = y
		end
	end
end

try that one

old Re: Vectors

DannyDeth
User Off Offline

Quote
When checking for collisions, simply check if 1 pixel above, below, left and right, that way it will never go between the the joints of the two walls.

old Re: Vectors

Infinite Rain
Reviewer Off Offline

Quote
Itäs because the image appear in the wall, speed = teleporting image
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview