First commit of LuaGame with an OpenGL backend.
[luagame.git] / demos / shine_on / scripts / Sparkle.lua
blob53ab49a5e8b764a245b847cc9c3ee3780d1cc832
1 --default values
2 Sparkle = Object:new()
3 Sparkle.type = "Sparkle"
5 Sparkle.image, Sparkle.w, Sparkle.h = get_image("images/sparkle.png")
6 Sparkle.fallspeed = 0 Sparkle.y_accel = 0.035
7 Sparkle.rect = Rect:new({x=8, y=8, w=16, h=16})
9 function Sparkle:new(o)
10 o = o or {}
11 setmetatable(o, self)
12 self.__index = self
13 return o
14 end
17 function Sparkle:update(delta)
18 Object.update(self, delta)
20 self.fallspeed = self.fallspeed + self.y_accel
22 --gravity
23 self.y = self.y + self.fallspeed
25 --bounds checking (ensure it's inside the game screen)
26 if self.x > s_width or self.y > s_height or self.x + self.w < 0 or self.y + self.h < 0 then
27 self.collect = true
28 end
30 end
33 function Sparkle:collide(ids, object)
34 if object.type == "Darkle" then
35 phazon_list:push_back(Phazon:new({x=self.x,y=self.y}))
36 end
37 if object.type == "Rectangle" then
38 dark_height = dark_height - 1.5
39 if dark_height < 0 then dark_height = 0 end
40 end
41 self.collect = true
42 end
45 function Sparkle:draw()
46 Object.draw(self)
47 end