Log in

Wiggleswerth #2 [457.9]

407 rounds, 363 wins, 44 losses, 0 draws

Ships

Pea Shooter II

{"name": "Pea Shooter II", "parts": [{"type": "brain","pos": [0,0],"rot": 0,"welds": [1,22,24]},{"type": "reinforced_hull","pos": [1,0],"rot": 0,"welds": [3,9]},{"type": "reinforced_hull","pos": [-2,0],"rot": 0,"welds": [4,6,24]},{"type": "reinforced_hull","pos": [2,0],"rot": 0,"welds": [5,7]},{"name": "thrustBL","type": "thruster","pos": [-2,-1],"rot": 0},{"name": "thrustBR","type": "thruster","pos": [2,-1],"rot": 0},{"name": "thrustFL","type": "thruster","pos": [-2,1],"rot": 2},{"name": "thrustFR","type": "thruster","pos": [2,1],"rot": 2},{"type": "reinforced_hull","pos": [-1,1],"rot": 0,"welds": [11,22,24]},{"type": "reinforced_hull","pos": [1,1],"rot": 0,"welds": [12,22]},{"type": "reinforced_hull","pos": [-2,2],"rot": 0,"welds": [11,14,18]},{"type": "reinforced_hull","pos": [-1,2],"rot": 0,"welds": [16]},{"type": "reinforced_hull","pos": [1,2],"rot": 0,"welds": [13,17]},{"type": "reinforced_hull","pos": [2,2],"rot": 0,"welds": [15,19]},{"type": "reinforced_hull","pos": [-3,2],"rot": 0,"welds": [20]},{"type": "reinforced_hull","pos": [3,2],"rot": 0,"welds": [21]},{"name": "gun4","type": "rocket_launcher","pos": [-1,3],"rot": 0},{"name": "gun3","type": "rocket_launcher","pos": [1,3],"rot": 0},{"name": "gun5","type": "rocket_launcher","pos": [-2,3],"rot": 0},{"name": "gun2","type": "rocket_launcher","pos": [2,3],"rot": 0},{"name": "gun6","type": "rocket_launcher","pos": [-3,3],"rot": 0},{"name": "gun1","type": "rocket_launcher","pos": [3,3],"rot": 0},{"name": "gyro","type": "gyroscope","pos": [0,1],"rot": 0,"welds": [23]},{"name": "ranger","type": "ranger","pos": [0,2],"rot": 0},{"name": "gps","type": "gps","pos": [-1,0],"rot": 0}]}
local turnLeft = false

function Update()
		-- Store our angular velocity in a variable to make it easier to use
		local angVel = gyro:AngVel()
		
		if ranger:Range() > 0 and not ranger:IsAlly() then
				-- We see another ship, stop spinning, start ramming,
				-- and remember which way to turn if we lose it again
				
				-- Use the standard thrusters to cancel out our angular velocity
				thrustFL:SetThrust(-angVel)
				thrustFR:SetThrust(angVel)
				thrustBL:SetThrust(angVel)
				thrustBR:SetThrust(-angVel)
				
				gun1:Fire()
				gun2:Fire()				
				gun3:Fire()
				gun4:Fire()
				gun5:Fire()
				gun6:Fire()
				
				-- Figure out which way to turn if we lose the ship again
				if angVel > 0 then
						-- We were spinning left when we saw this target,
						-- so we should turn right if we lose it.
						turnLeft = false
				else
						-- We were spinning right when we saw this target,
						-- so we should turn left if we lose it.
						turnLeft = true
				end
		else
						-- We don't see another ship, spin around to find one
						
						-- Figure out which way to turn
						local desiredAngVel = turnLeft and 90 or -90
						
						-- Use the standard thrusters to spin the ship at the desired angular speed.
						thrustFL:SetThrust(desiredAngVel - angVel)
						thrustFR:SetThrust(angVel - desiredAngVel)
						thrustBL:SetThrust(angVel - desiredAngVel)
						thrustBR:SetThrust(desiredAngVel - angVel)
		end		
		
		if not ranger:IsAlly() then
		
				gps:Pos()
				
		end				
end

Pea Shooter

{"name": "Pea Shooter", "parts": [{"type": "brain","pos": [0,0],"rot": 0,"welds": [1,2,23]},{"type": "reinforced_hull","pos": [-1,0],"rot": 0,"welds": [3,9]},{"type": "reinforced_hull","pos": [1,0],"rot": 0,"welds": [4,10]},{"type": "reinforced_hull","pos": [-2,0],"rot": 0,"welds": [5,7]},{"type": "reinforced_hull","pos": [2,0],"rot": 0,"welds": [6,8]},{"name": "thrustBL","type": "thruster","pos": [-2,-1],"rot": 0},{"name": "thrustBR","type": "thruster","pos": [2,-1],"rot": 0},{"name": "thrustFL","type": "thruster","pos": [-2,1],"rot": 2},{"name": "thrustFR","type": "thruster","pos": [2,1],"rot": 2},{"type": "reinforced_hull","pos": [-1,1],"rot": 0,"welds": [12,23]},{"type": "reinforced_hull","pos": [1,1],"rot": 0,"welds": [13,23]},{"type": "reinforced_hull","pos": [-2,2],"rot": 0,"welds": [12,15,19]},{"type": "reinforced_hull","pos": [-1,2],"rot": 0,"welds": [17]},{"type": "reinforced_hull","pos": [1,2],"rot": 0,"welds": [14,18]},{"type": "reinforced_hull","pos": [2,2],"rot": 0,"welds": [16,20]},{"type": "reinforced_hull","pos": [-3,2],"rot": 0,"welds": [21]},{"type": "reinforced_hull","pos": [3,2],"rot": 0,"welds": [22]},{"name": "gun4","type": "rocket_launcher","pos": [-1,3],"rot": 0},{"name": "gun3","type": "rocket_launcher","pos": [1,3],"rot": 0},{"name": "gun5","type": "rocket_launcher","pos": [-2,3],"rot": 0},{"name": "gun2","type": "rocket_launcher","pos": [2,3],"rot": 0},{"name": "gun6","type": "rocket_launcher","pos": [-3,3],"rot": 0},{"name": "gun1","type": "rocket_launcher","pos": [3,3],"rot": 0},{"name": "gyro","type": "gyroscope","pos": [0,1],"rot": 0,"welds": [24]},{"name": "ranger","type": "ranger","pos": [0,2],"rot": 0}]}
local turnLeft = false

function Update()
		-- Store our angular velocity in a variable to make it easier to use
		local angVel = gyro:AngVel()
		
		if ranger:Range() > 0 and not ranger:IsAlly() then
				-- We see another ship, stop spinning, start ramming,
				-- and remember which way to turn if we lose it again
				
				-- Use the standard thrusters to cancel out our angular velocity
				thrustFL:SetThrust(-angVel)
				thrustFR:SetThrust(angVel)
				thrustBL:SetThrust(angVel)
				thrustBR:SetThrust(-angVel)
				
				gun1:Fire()
				gun2:Fire()				
				gun3:Fire()
				gun4:Fire()
				gun5:Fire()
				gun6:Fire()
				
				-- Figure out which way to turn if we lose the ship again
				if angVel > 0 then
						-- We were spinning left when we saw this target,
						-- so we should turn right if we lose it.
						turnLeft = false
				else
						-- We were spinning right when we saw this target,
						-- so we should turn left if we lose it.
						turnLeft = true
				end
		else
						-- We don't see another ship, spin around to find one
						
						-- Figure out which way to turn
						local desiredAngVel = turnLeft and 90 or -90
						
						-- Use the standard thrusters to spin the ship at the desired angular speed.
						thrustFL:SetThrust(desiredAngVel - angVel)
						thrustFR:SetThrust(angVel - desiredAngVel)
						thrustBL:SetThrust(angVel - desiredAngVel)
						thrustBR:SetThrust(desiredAngVel - angVel)
		end		
end