The game I am working on has several user-controlled objects; if any of them enter an 'enemy zone' its short ID is sent to a "tellEnemy" function. That function invokes the "enemyDetected" command for all visible robots.
Here is the code for my "enemyDetected" command:
Code: Select all
on enemyDetected
global whatToKill
local mySpot, enemySpot
put the loc of me into mySpot
put the loc of img ID whatToKill into enemySpot
-- get close enough to fire
repeat until distance(mySpot, enemySpot) < 100
set the moveLinear["startpoint"] of me to mySpot
set the moveLinear["endpoint"] of me to enemySpot
moveLinear
-- location refresh
put the loc of me into mySpot
put the loc of img ID whatToKill into enemySpot
end repeat
// attack
put the short ID of me into myName
get attack(whatToKill, myName)
end enemyDetected
Okay, now for my questions.
(1) How do I control the speed in which the robots approach the enemy? Currently, it is unrealistically fast.
(2) How do I ensure the robots do not land on each other?
Thanks in advance,
Ed