-
Notifications
You must be signed in to change notification settings - Fork 4
/
vanilla_seeds.lua
76 lines (61 loc) · 1.89 KB
/
vanilla_seeds.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
local balloon_seed = {}
local api = require("api")
balloon_seed.granularity=50
function balloon_seed.inject(type)
end
function balloon_seed.init(obj)
obj.offset = 0
obj.__tas_seed = 0
end
function balloon_seed.set_seed(obj, new_seed)
obj.offset = obj.offset - obj.__tas_seed + new_seed
obj.y=obj.start+api.sin(obj.offset)*2
obj.__tas_seed = new_seed
end
function balloon_seed.increase_seed(obj)
balloon_seed.set_seed(obj, (obj.__tas_seed + 1/balloon_seed.granularity)%1)
end
function balloon_seed.decrease_seed(obj)
balloon_seed.set_seed(obj, (obj.__tas_seed-1/balloon_seed.granularity)%1)
end
function balloon_seed.draw(obj)
setPicoColor(9)
local x,y = math.floor(obj.x), math.floor(obj.y)
love.graphics.rectangle("line", x-1, y-1, 10, 10)
love.graphics.printf(tostring(math.floor(obj.__tas_seed*balloon_seed.granularity + 0.5)),x,y+11, 8 ,"center")
end
local chest_seed = {}
function chest_seed.inject(pico8)
local _upd = pico8.cart.chest.update
pico8.cart.chest.update = function(this)
local _rnd = pico8.cart.rnd
if this.timer <= 1 then
pico8.cart.rnd = function()
--add a small value becase noninteger rng values give the berry a slightly bigger hitbox
return this.__tas_seed + 1 + 0x0.0001
end
end
_upd(this)
pico8.cart.rnd = _rnd
end
end
function chest_seed.init(obj)
-- make sure not to double inject
obj.__tas_seed = 0
end
function chest_seed.set_seed(obj, new_seed)
obj.__tas_seed = new_seed
end
function chest_seed.increase_seed(obj)
chest_seed.set_seed(obj, (obj.__tas_seed+2)%3-1)
end
function chest_seed.decrease_seed(obj)
chest_seed.set_seed(obj, (obj.__tas_seed)%3-1)
end
function chest_seed.draw(obj)
setPicoColor(9)
local x,y = math.floor(obj.x) + obj.__tas_seed, math.floor(obj.y)
love.graphics.rectangle("line", x-1, y-1, 10, 10)
love.graphics.printf(tostring(obj.__tas_seed),x,y+11, 8 ,"center")
end
return {balloon = balloon_seed, chest=chest_seed}