This function points an entity at another entity.
function App:Start()
--Create a window
self.window = Window:Create()
self.context = Context:Create(self.window)
self.world = World:Create()
local camera = Camera:Create()
camera:SetRotation(35,0,0)
camera:Move(0,0,-6)
local light = DirectionalLight:Create()
light:SetRotation(35,35,0)
--Create a model
self.entity1 = Model:Box()
self.entity1:SetColor(0.0,0.0,1.0)
self.entity1:SetRotation(0,-90,0)
--Create another model to point at the one that goes in circles
self.entity2 = Model:Box()
self.entity2:SetColor(0.0,1.0,0.0)
self.entity2:SetPosition(0,0,2)
return true
end
function App:Loop()
if self.window:Closed() or self.window:KeyHit(Key.Escape) then return false end
--Make the model move in a circle
self.entity1:Turn(0,Time:GetSpeed()*0.5,0);
self.entity1:Move(0,0,0.1);
--Point this at the moving box when the space key is pressed
if (self.window:KeyDown(Key.Space)) then
self.entity2:Point(self.entity1,2,Time:GetSpeed()*0.1);
end
Time:Update()
self.world:Update()
self.world:Render()
self.context:Sync()
return true
end