Created
May 20, 2022 03:50
-
-
Save aglassman/fb0ee5393e1001c930891c167de57cd7 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
weed = { | |
position={0,0}, | |
new=function(self, position) | |
local new_weed = {position=position} | |
setmetatable(new_weed, self) | |
return new_weed | |
end, | |
draw=function(self) | |
pset(self.position[1], self.position[2], 11) | |
end | |
} | |
park = { | |
weeds={}, | |
init=function(self, num_weeds) | |
for i=1, 10 do | |
self.weeds[i] = weed:new({5*i, 5*i}) | |
end | |
end, | |
draw=function(self) | |
rectfill(0,0,127,127,3) | |
rect(0,0,127,127,4) | |
for w in all(self.weeds) do | |
-- This does not work!! | |
w:draw() | |
-- This works | |
weed.draw(w) | |
end | |
end | |
} | |
function pcord(position) | |
printh("{" .. position[1] .. ", " .. position[2] .. "}", "demo_log.txt") | |
end | |
function _init() | |
cls() | |
park:init(1) | |
end | |
function _update() | |
end | |
function _draw() | |
cls() | |
park:draw() | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment