Opposite forces
but I can't get the = sign to work in line 23 (and others) for some reason
- Code:
- --if Team , then go + score!
--if team , then go - score!
--this will move them in opposite directions..
function main()
subscribe(Event.Tick);
for i=1,50 do
logprint("");
end
score = 2
end
function onTick(delta)
local results = {};
bf:findAllObjects(results, ObjType.Ship);
for i,item in ipairs(results) do
local team = item:getTeamIndex()
local vel = item:getVel();
--do
if(team = 1) then
if(vel.x < 600) then
xvel = vel.x + score
else
xvel = vel.x
end
if(vel.y < 600) then
yvel = vel.y + score
else
yvel = vel.y
end
item:setVel(point.new(xvel, yvel))
end
--now do
if(team = 2) then
xvel = vel.x
yvel = vel.y
if(vel.x > -600) then
xvel = vel.x - score
else
xvel = vel.x
end
if(vel.y > -600) then
yvel = vel.y - score
else
yvel = vel.y
end
item:setVel(point.new(xvel, yvel))
end
end
viewtopic.php?f=33&p=21002#p21002