-
Notifications
You must be signed in to change notification settings - Fork 2
/
scrolling.p8
166 lines (155 loc) · 10.1 KB
/
scrolling.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
pico-8 cartridge // http://www.pico-8.com
version 16
__lua__
-- there's more to the world
-- bright moth games
step = .03333 -- our framerate, 1/30
function _init()
menuitem(1, "next demo", loadnextdemo)
frames = { 3, 4, 2, 1}
frametime = 0
frameidx = 1
speed = 30
x,y = 60, 60
walking = false
left = false
jumping = false
onground = true
jumptime = 0
crouched = false
-- setup our camera's x coord
camx = 0
end
function _update()
frametime += 1
walking = false
jumping = false
crouched = false
-- don't walk off the left edge
if(btn(0) and x > 0) then
x -= speed * step
walking = true
left = true
-- if we move left, and the
-- camera isn't at the edge,
-- move the camera
if(camx > 0 and x - camx < 28) camx -= speed * step
end
-- don't walk off the right edge
if(btn(1) and x < 248) then
x += speed * step
walking = true
left = false
-- if we move right, and the
-- camera isn't at the edge,
-- move the camera
if(camx + 128 < 256 and x - camx > 100) camx += speed * step
end
if(btn(3) and not walking and onground) then
frameidx = 9
crouched = true
end
if(btn(5) and (onground or jumptime < 15)) then
jumping = true
onground = false
y -= speed * step
end
if(not onground) then
if(jumping) then
frameidx = 5
jumptime += 1
else
frameidx = 6
y += speed * step
jumptime = 15
if(y >= 60) then
onground = true
y = 60
jumptime = 0
end
end
elseif(walking) then
if(frametime > 5) then
frametime = 0
frameidx += 1
end
if(frameidx > 4) then
frameidx = 1
end
elseif(not crouched) then
frametime = 0
frameidx = 0
end
end
function _draw()
-- set our camera offset.
-- only need to set x for now
camera(camx, 0)
cls(12)
map(0,0,0,28,32,16)
if(onground and walking) then
spr(frames[frameidx], x, y, 1, 1, left)
else
spr(frameidx,x,y,1,1,left)
end
-- reset the camera to print
-- our slide title using
-- absolute position
camera(0, 0)
print("scrolling", 92, 122, 7)
end
-->8
-- demo switching
function loadnextdemo()
load('simplecollision.p8', 'previous demo')
end
__gfx__
002d2200002d2200002d2200002d2200002d2200002d2200028d2200220000000000000000000000000000000000000000000000000000000000000000000000
00822400008224000082240000822400008224000882440028224400022800000000000000000000000000000000000000000000000000000000000000000000
008244000082440000824400008244000082440008224400222244000282d200028d2200002d2200000000000000000000000000000000000000000000000000
00229a0000229a0000229a0000229a0000229a0002229a4004429a00022244002822440000822400000000000000000000000000000000000000000000000000
00024a0000024a000004aa400042a40000024a000049aa000009aa40002244002222440000824400000000000000000000000000000000000000000000000000
000a4a00000aa4000009490000099a40000aa400049aad0000aaad0000049a4000029a4000229a40000000000000000000000000000000000000000000000000
0000d5000001d50000050d00000d05000001dd0000d01000000d01000049aad00004aaa000024a90000000000000000000000000000000000000000000000000
000011000000100000100100001001000000100001000000000010000000151000914a100091a410000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000777700000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000007777770077000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000077777677777707700000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000077777767777677770000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000067777767777767770000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000067777777677767760000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000006667777766777000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000066666677000000000000000000000000000000000000000000000000000000000000000000000
3b3b3b3b444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
b3b3b3b3444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
44344434444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
44444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
44444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
44444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
44444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
44444444444444440000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
__map__
0000000026270000000000002627000000000026270000000026270000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0026270000000000000000000000000026270000000000000000000026270000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000002627002627000026270000000000000026270000000000000026270000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3030303030303030303030303030303030303030303030303030303030303030000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
3131313131313131313131313131313131313131313131313131313131313131000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000