Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --PROJECT CANDYLAND SAGA
- --MAIN.LUA
- --CANDY.LUA
- local class = require 'middleclass'
- Candy = class('Candy')
- function Candy:initialize(x, y, PLAYER)
- self.active = true
- self.x = x
- self.y = y
- self.h2 = 40
- self.h = 40
- self.vel = 2.5
- if PLAYER.lessRainbows then
- rN = math.random(1, 14)
- else
- rN = math.random(1, 9)
- end
- self.id = rN
- if rN == 1 or rN == 10 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_blue.png")
- elseif rN == 2 or rN == 11 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_green.png")
- elseif rN == 3 or rN == 12 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_yellow.png")
- elseif rN == 4 or rN == 13 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_red.png")
- elseif rN == 5 or rN == 14 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_teal.png")
- elseif rN == 6 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_purple.png")
- elseif rN == 7 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_orange.png")
- elseif rN == 8 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_pink.png")
- elseif rN == 9 then
- self.img = love.graphics.newImage("/art/yaycandies/size1/lollipop_rainbow.png")
- end
- end
- function Candy:update(dt, PLAYER)
- if self.active then
- self.y = self.y + self.vel
- if self.y > love.window.getHeight() then
- self.y = 0
- if self.id == 9 then
- PLAYER.lifes = PLAYER.lifes - 1
- end
- end
- end
- end
- function Candy:draw()
- love.graphics.draw(self.img, self.x, self.y)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement