Created
November 22, 2011 03:16
-
-
Save anonymous/1384797 to your computer and use it in GitHub Desktop.
Wizard's Fire House class
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
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