notsanequarium/constructors.lua
jill e2703105dd
a proper money system and progressive upgrades
the game is now officially playable! this marks 1.0b and perfectly recreates the "tutorial" stage of insaniquarium, with some audio and visual changes, no king guppies and no egg pieces
2021-01-23 23:04:16 +03:00

77 lines
1.3 KiB
Lua

require 'const'
local self = {}
function self.fish(x, y)
local fish = {
x = x,
y = y,
size = 0, -- 0 for small, 1 for medium, 2 for big, 3 for king
eattimer = 0 + math.random() * 2, -- starts out hungry, with a 2s delay
moneytimer = 10 + math.random() * 5, -- min 10s before it can make money
dead = false,
lifetime = 0,
eases = {
},
render = {
x = 0,
y = 0,
prevx = math.random() - 0.5,
prevy = math.random() - 0.5,
turn = math.random(),
swim = 0,
angle = 0,
xspeed = 0,
yspeed = 0,
eattimer = 1,
hungry = 0,
deathanim = 0,
}
}
for i = 1, FISH_SPLINE_QUALITY do
table.insert(fish.eases, { -- we insert a fake ease that ends instantly and just hope the update loop replaces it with a valid, random one
x = x,
y = y,
fromx = x,
fromy = y,
a = 1,
speed = 1
})
end
return fish
end
function self.food(x, y, type)
local food = {
x = x,
y = y,
speed = 0.2,
time = math.random(),
deathtimer = 0,
type = type
}
return food
end
function self.money(x, y, type)
local money = {
x = x,
y = y,
speed = 0.12,
time = math.random(),
deathtimer = 0,
collected = false,
collecttimer = 0,
type = type
}
return money
end
return self