notsanequarium/constructors.lua

78 lines
1.4 KiB
Lua
Raw Normal View History

2021-01-22 22:33:08 +00:00
require 'const'
local self = {}
2021-01-25 14:48:31 +00:00
function self.fish(x, y, type)
type = type or 0
2021-01-22 22:33:08 +00:00
local fish = {
x = x,
y = y,
2021-01-25 14:48:31 +00:00
size = type, -- 0 for small, 1 for medium, 2 for big, 3 for king, 4 for carnivore
2021-01-22 22:33:08 +00:00
eattimer = 0 + math.random() * 2, -- starts out hungry, with a 2s delay
2021-01-23 19:42:56 +00:00
moneytimer = 10 + math.random() * 5, -- min 10s before it can make money
2021-01-23 10:10:38 +00:00
dead = false,
2021-01-22 22:33:08 +00:00
lifetime = 0,
eases = {
},
render = {
x = 0,
y = 0,
2021-01-23 13:46:02 +00:00
prevx = math.random() - 0.5,
prevy = math.random() - 0.5,
turn = math.random(),
2021-01-22 22:33:08 +00:00
swim = 0,
angle = 0,
xspeed = 0,
yspeed = 0,
eattimer = 1,
hungry = 0,
2021-01-23 10:10:38 +00:00
deathanim = 0,
2021-01-22 22:33:08 +00:00
}
}
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,
2021-01-23 14:22:14 +00:00
type = type
2021-01-22 22:33:08 +00:00
}
return food
end
2021-01-23 19:42:56 +00:00
function self.money(x, y, type)
local money = {
x = x,
y = y,
speed = 0.12,
2021-01-23 19:42:56 +00:00
time = math.random(),
deathtimer = 0,
collected = false,
collecttimer = 0,
type = type
}
return money
end
2021-01-22 22:33:08 +00:00
return self