added ag::exit() and ag::import() to exit the lua script and import other lua modules
git-svn-id: svn://anubis/anaglym/trunk@146 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
1 parent
f8b15d60ff
commit
2081cf7277
7 files changed
+80
-10
No files matched your search
@@ -3,11 +3,20 @@ ground = ag.createStaticPlane(0, 0, 0, 0, 0, 0)
|
||||
ground:setColor(0.2, 1.0, 0.2)
|
||||
ag.setCamera(10, -10, 10, 0, 0, 0)
|
||||
|
||||
if (ag.import("rot_camera") ~= true) then
|
||||
ag.println("error importing rot_camera")
|
||||
ag.exit()
|
||||
end
|
||||
|
||||
function init(obj)
|
||||
obj:setColor(math.random(), math.random(), math.random())
|
||||
obj:setPosition((math.random() - 0.5) * 10, (math.random() - 0.5) * 10, 10)
|
||||
end
|
||||
|
||||
function update_event()
|
||||
rot_camera()
|
||||
end
|
||||
|
||||
function key_down_event(key)
|
||||
if (key == "b") then
|
||||
box = ag.createBox(1, 1, 1)
|
||||
@@ -21,5 +30,7 @@ function key_down_event(key)
|
||||
elseif (key == "s") then
|
||||
sphere = ag.createSphere(0.8)
|
||||
init(sphere)
|
||||
elseif (key == "q") then
|
||||
ag.exit()
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
function rot_camera()
|
||||
local angle = ag.elapsedTime() / 5000 * math.pi
|
||||
ag.setCamera(15 * math.cos(angle), 15 * math.sin(angle), 12, 0, 0, 2)
|
||||
end
|
||||
Reference in new issue
Block a user