Created
October 13, 2015 01:37
-
-
Save tylerneylon/5c7fc6cf2775e3f6ba9a to your computer and use it in GitHub Desktop.
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
--[[ Summary: Below, "entity" and "item" may be different types. | |
They simply implement same-name methods. | |
--]] | |
-- A bit from entities.lua: | |
function entities.runloop(dt) | |
for _, entity in pairs(all_entities) do | |
entity:update_and_draw(dt) | |
end | |
end | |
-- A bit from Model.lua (caps because it's a type): | |
-- Call this as in model:look_at({x, y, z}). | |
-- This expects the input vector to be approximately a unit vector. | |
function Model_mt:look_at(dir) | |
-- Check that the input direction is close to being a unit vector. | |
assert(math.abs(Vec3.length(dir) - 1.0) < 0.001) | |
for _, item in pairs(self.items) do | |
item:look_at(unpack(dir)) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment