-
Notifications
You must be signed in to change notification settings - Fork 0
/
ugene_functions.p8
130 lines (116 loc) · 3 KB
/
ugene_functions.p8
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
pico-8 cartridge // http://www.pico-8.com
version 18
__lua__
function update_ugene()
--apply friction and keep in bounds
if (ugene.dx<0) ugene.dx+=friction
if (ugene.dx>0) ugene.dx-=friction
ugene.dx=mid(-accel_max,ugene.dx,accel_max)
-- buoyancy
if btn(⬆️) then
ugene.y-=1
burnfuel(.02)
end
if btn(⬇️) then
ugene.y+=1
burnfuel(.01)
end
ugene.y=mid(min_y,ugene.y,max_y-ugene.h)
-- accelerate right
if btn(➡️) then
if ugene.left then
ugene.left=false
ugene.aim="right"
end
ugene.dx+=accel
burnfuel(.03)
end
-- accelerate left
if btn(⬅️) then
if not(ugene.left) then
ugene.left=true
ugene.aim="left"
end
ugene.dx-=accel
burnfuel(.03)
end
-- fire nerfgun
if btnp(❎) and ugene.weapon and ugene.weapon.id=="nerfgun" then
timeouts["shooting"]=5
if nerf>0 then
sfx(2)
createbullet()
nerf-=1
if nerf==12 then
dialog="running low on ammo!"
end
if nerf==1 then
dialog="this is my/last nerf!"
end
else
dialog="need to find/more ammo!"
--timeouts["flashammo"]=30
sfx(7)
end
end
-- fire lasergun
if btnp(❎) and ugene.weapon and ugene.weapon.id=="lasergun" then
if power>0 then
sfx(21)
createlaser()
power=mid(0,power-2,99)
end
if power<10 then
dialog="low on power!"
end
if power<=0 then
dialog="out of juice!"
sfx(26)
end
end
--fire squirtgun
if btnp(❎) and ugene.weapon and ugene.weapon.id=="squirtgun" then
if h2o>0 then
sfx(13)
for i=1,rnd(20) do
createstream(i)
end
h2o-=1
else
dialog="out of water!"
--timeouts["flashammo"]=30
sfx(7)
end
end
--put down
if btnp(🅾️) and ugene.weapon then
dialog="who needs that /"..ugene.weapon.n.." anyway."
putdownweapon()
end
--wrap ugene
if (ugene.x<0) ugene.x=map_w
if (ugene.x>map_w) ugene.x=0
--move horizontally
ugene.x+=ugene.dx
end
function drawugene()
local sprite,drip_ox
--debug_hitbox(ugene)
foreach(smoke,drawsmoke)
if (timeouts["ugenewhite"]>0) setspritecolor(8)
if (timeouts["shooting"]>0) then
sprite=4
else
sprite=ugene.sprite[ugene.action][1]
end
spr(sprite,ugene.x,ugene.y,ugene.sprite[ugene.action][2],3,ugene.left)
pal()
if timeouts["dripping"]==0 and not(ugene.left) then
addpart(ugene.x+2,ugene.y+10,0,1,1,7,16)
timeouts["dripping"]=flr(rnd(500))
end
--shadow
spr(54,ugene.x+4,max_y+3,2,1,ugene.left)
-- dialog
if (not(dialog=="")) say(dialog,ugene.x+12,ugene.y,500,false)
end