Skip to content

Instantly share code, notes, and snippets.

Created November 22, 2011 03:16
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 anonymous/1384797 to your computer and use it in GitHub Desktop.
Save anonymous/1384797 to your computer and use it in GitHub Desktop.
Wizard's Fire House class
House = class()
HOUSE_DESTROYED = 0
HOUSE_STANDARD = 1
HOUSE_TOWER = 5
function House:init(x)
    -- you can accept and set parameters here
    self.x = x
    self.type = HOUSE_STANDARD
end
function House:distance(x)
    return math.abs(self.x - x)
end
    
function House:draw()
    -- Codify does not automatically call this method
    if self.type == HOUSE_DESTROYED then
        sprite("Small World:Dirt Patch", self.x, 60)
    elseif self.type == HOUSE_STANDARD then
        sprite("Small World:House", self.x, 80)
    elseif self.type == HOUSE_TOWER then
        sprite("Small World:Watch Tower", self.x, 110)
    end
end
function House:touched(touch)
    -- Codify does not automatically call this method
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment