Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
dmoa
committed
Mar 9, 2019
0 parents
commit 454c842
Showing
15 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
Drop = {} | ||
|
||
Drop.new = function() | ||
local self = {} | ||
|
||
self.x = love.math.random(128, 512) | ||
self.y = love.math.random(100) * - 1 | ||
self.yv = love.math.random(200, 400) | ||
|
||
self.draw = function() | ||
love.graphics.rectangle("fill", self.x, self.y, 5, 30) | ||
end | ||
|
||
self.update = function(dt) | ||
self.y = self.y + self.yv * dt | ||
if self.y > 256 then | ||
self.y = love.math.random(100) * - 1 | ||
self.x = love.math.random(128, 512) | ||
self.yv = love.math.random(200, 400) | ||
end | ||
end | ||
|
||
self.mouseUpdate = function(x, y) | ||
if x > self.x and x < self.x + 5 and y > self.y and y < self.y + 30 then | ||
self.y = love.math.random(100) * - 1 | ||
self.x = love.math.random(128, 512) | ||
growth = growth + 1 | ||
if not sans then | ||
if growth == 27 then | ||
music:stop() | ||
sans = love.audio.newSource("oof.mp3", "static") | ||
currentImg = currentImg + 1 | ||
sans:setLooping(true) | ||
sans:play() | ||
elseif growth % 3 == 0 then | ||
if currentImg < 10 then | ||
currentImg = currentImg + 1 | ||
end | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
return self | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
function love.conf(t) | ||
t.window.title = "starting small | click the raindrops to grow your tree" | ||
t.window.height = 256 | ||
t.window.icon = "1.png" | ||
t.window.width = 512 | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
function love.load() | ||
require("Drop") | ||
love.graphics.setDefaultFilter("nearest", "nearest", 1) | ||
growthimgs = {} | ||
for i = 1, 10 do | ||
table.insert(growthimgs, love.graphics.newImage(i..".png")) | ||
end | ||
currentImg = 1 | ||
|
||
imgtext = {"seed", "grass", "greenery", "plants!", "splits", "branches", "?", "!", "?!!?!?", "sans"} | ||
|
||
rain = {} | ||
|
||
for i = 1, 20 do | ||
table.insert(rain, Drop.new()) | ||
end | ||
growth = 0 | ||
|
||
music = love.audio.newSource("music.mp3", "stream") | ||
music:setLooping(true) | ||
music:play() | ||
end | ||
|
||
function love.draw() | ||
love.graphics.draw(growthimgs[currentImg], 0, 0, 0, 4, 4) | ||
love.graphics.printf(imgtext[currentImg], 128, 128, 100) | ||
for k, drop in ipairs(rain) do | ||
drop.draw() | ||
end | ||
end | ||
|
||
function love.update(dt) | ||
for k, drop in ipairs(rain) do | ||
drop.update(dt) | ||
end | ||
if love.keyboard.isDown("escape") then | ||
love.event.quit() | ||
end | ||
end | ||
|
||
function love.mousepressed(x, y) | ||
for k, drop in ipairs(rain) do | ||
drop.mouseUpdate(x, y) | ||
end | ||
end |
Binary file not shown.
Binary file not shown.