Skip to content

Instantly share code, notes, and snippets.

@aglassman
Created May 20, 2022 03:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aglassman/fb0ee5393e1001c930891c167de57cd7 to your computer and use it in GitHub Desktop.
Save aglassman/fb0ee5393e1001c930891c167de57cd7 to your computer and use it in GitHub Desktop.
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