Opposite forces
Posted: Tue Apr 01, 2014 8:29 pm
this levelgen moves teams in opposite directions
but I can't get the = sign to work in line 23 (and others) for some reason
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