Created
December 17, 2013 13:37
-
-
Save domgetter/8005000 to your computer and use it in GitHub Desktop.
basic incomplete code for the logic of a heat seeking rocket projectile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function init(args) | |
end | |
function main() | |
if collision() then asplode() end | |
local found_monster = false | |
local sensor_range = 10 | |
for radius = 1, sensor_range do | |
--checks for any nearest monster within sensor range | |
monsters = world.monsterQuery(object.position(), radius) | |
if monster[1] then | |
set_kill_course(monster[1].postion) | |
found_monster = true | |
end | |
if found_monster then break end | |
end | |
if not found_monster then | |
--if no monster was within sensor range, just go straight | |
continue_course() | |
end | |
end | |
function set_kill_course(destination) | |
--modifies the trajectory of the rocket to match its target | |
end | |
function continue_course() | |
--continue trajectory in straight path to its inevitable doom | |
end | |
function collision() | |
--check to see if rocket has collided with anything like a wall, monster, or npc | |
end | |
function asplode() | |
-- explode and die/delete object | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment