Advertisement
Juaxix

Abudction code for Codea 2/4 - Person

Nov 3rd, 2011
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.47 KB | None | 0 0
  1.  
  2. Person = class()
  3. -- Person states
  4. PERSON_KILL =-1
  5. PERSON_BORN = 0
  6. PERSON_SHIP = 1
  7. PERSON_LEVI = 2
  8. PERSON_LOST = 3
  9. PERSON_SAFE = 4
  10. PERSON_FALL = 5
  11. PERSON_BYE  = 6
  12. function Person:init(x,y,angle)
  13.     -- you can accept and set parameters here
  14.     self.x = x
  15.     self.y = y
  16.     self.angle = angle
  17.     local r= math.random(1,5)
  18.     if r == 1 then
  19.         self.model = "Planet Cute:Character Boy"
  20.         self.points= 3
  21.     elseif r == 2 then
  22.         self.model = "Planet Cute:Character Cat Girl"
  23.         self.points= 3
  24.     elseif r == 3 then
  25.         self.model = "Planet Cute:Character Horn Girl"
  26.         self.points= 6
  27.     elseif r == 4 then
  28.         self.model = "Planet Cute:Character Pink Girl"
  29.         self.points= 5
  30.     else
  31.         self.model = "Planet Cute:Character Princess Girl"
  32.         self.points= 12
  33.     end
  34.     self.state = PERSON_BORN -- in asteroid, lost,waiting for the ship
  35.     self.timeToGo = 2.3
  36.     self.shipId = nil
  37. end
  38.  
  39. function Person:draw()
  40.     pushMatrix()
  41.     --translate(0,0)
  42.     translate(self.x,self.y)
  43.     rotate(self.angle)
  44.     if self.state == PERSON_BYE then
  45.         sprite("Small World:Glow")
  46.     elseif self.state == PERSON_BORN then
  47.         sprite("Small World:Explosion")
  48.     elseif self.state == PERSON_KILL then
  49.         sprite("Small World:Bunny Skull")
  50.     else
  51.         sprite(self.model,0,0)
  52.     end
  53.     popMatrix()
  54. end
  55.  
  56. function Person:touched(touch)
  57.     -- Codify does not automatically call this method
  58. end
  59.  
  60.  
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement