Skip to content

Instantly share code, notes, and snippets.

@Powersaurus
Created September 9, 2019 22:06
Show Gist options
  • Save Powersaurus/2d204de7ae6e2586139951a8a668f602 to your computer and use it in GitHub Desktop.
Save Powersaurus/2d204de7ae6e2586139951a8a668f602 to your computer and use it in GitHub Desktop.
Ray caster demo in PICO-8, now with fancier walls
pico-8 cartridge // http://www.pico-8.com
version 18
__lua__
-- raycaster demo
-- by @powersaurus
-- based heavily on http://lodev.org/cgtutor/raycasting.html
-- and http://lodev.org/cgtutor/raycasting2.html
-- and inspired by the work of @matthughson
-- thanks for advice from @kometbomb and @doyousketch2
debug=true
frames=0
function _init()
timer=0
id=1
dist_table={}
detail_limit_table={}
create_palettes()
msg=""
projectiles={}
player=make_player()
-- turn_player(player,45)
turn_player(player,270)
world=make_world()
sprites={}
cats={}
local cat=make_cat(5,5,0)
add(sprites,cat)
add(cats,cat)
for y=0,128 do
dist_table[y]=128/(2*y-128)
detail_limit_table[y]=flr(98+7*sin(y/256))
end
-- build tex lookup table
-- experimental, not used atm
world2={}
for y=1,#world do
for x=1,#world[y] do
poke(0x4300+y*32+x,abs(world[y][x]))
world2[y*32+x]=world[y][x]
end
end
stars={}
for s=0,50 do
local x=rnd(20)-10
local y=rnd(20)-10
local z=32+rnd(64)
local star={
x=x,
y=y,
z=z
}
add(stars,star)
end
particles={}
_draw=draw
_update=update
end
strafe=false
draw_map=false
hvy=0 -- move hand
function update()
timer+=1
hy=clamp(hvy,0,20)
hvy=max(hvy-4,-3)
update_doors(doors)
if btnp(5) then
draw_map=not draw_map
end
local sp=0.08
if btnp(4) then
hvy+=20
add_projectile(player,projectiles)
end
--[[if btn(4) then
strafe=true
else
strafe=false
end]]
if btn(0) then
if strafe then
strafe_in_current_dir(player,-sp)
else
turn_player2(player,-1.0)
end
end
if btn(1) then
if strafe then
strafe_in_current_dir(player,sp)
else
turn_player2(player,1.0)
end
end
if btn(2) then
move_in_current_dir(player,sp)
end
if btn(3) then
move_in_current_dir(player,-sp)
end
player:update()
for _,p in pairs(projectiles) do
p:update()
if (p.life==0) del(projectiles,p)
end
for _,s in pairs(sprites) do
if (s.update) s:update()
end
-- hack
if timer%1==0
and #cats<5 then
local cy=1
local cx=1
-- this has a habit of blowing up
while world[cy][cx]>2 do
cy=flr(rnd(#world-1))+1
print(cy)
cx=1+flr(rnd(#world[cy]))
cls()
print(cx..","..cy)
end
local cat=make_cat(
cx+0.5,
cy+0.5,
0)
add(sprites,cat)
add(cats,cat)
end
end
hy=0
function draw()
reset_palette()
calculate_fps(time())
-- timer+=1
--[[msg=player.pos.x.." "..player.pos.y
.."\n"..player.dr.x.." "..player.dr.y
.."\n"..player.cam.x.." "..player.cam.y]]
if draw_map then
draw_map_view(world,player)
else
draw_perspective(world,player,dist_table,detail_limit_table)
--hand
sspr(96,16,32,16,64+hy/2,96+hy,64,32)
if debug then
reset_palette()
print(fps,2,2,7)
print("cpu: "..stat(1),2,10,7)
-- print("pos: "..player.pos.x.." "..player.pos.y.." "..player.a,2,19,7)
-- print("msg: "..msg,2,19,10)
end
end
end
-->8
-- raycasting
-- draw the 3d view
function draw_perspective(world,player,dist_table,detail_limit_table)
-- sky
rectfill(0,0,128,64,0)
local cam=player.cam
local dr=player.dr
-- stars
for _,s in pairs(stars) do
local invdet=1/(cam.x*dr.y-cam.y*dr.x)
local tfx=invdet*(dr.y*s.x-dr.x*s.y)
local tfy=invdet*(-cam.y*s.x+cam.x*s.y)
local sx=64*(1+tfx/tfy)
local sy=abs(64-s.z)
pset(sx,sy,7)
end
-- put another rect fill to hide the stars behind the walls
rectfill(0,64,128,128,1)
--0.6971->0.7227
-- -> 0.7368
-- first raycast pass
local floors,
zbuf,
dr_start,
dr_end=ray_cast(
world,
player,
dist_table,
detail_limit_table,
0,
127,
false)
floor_cast(floors,world,player,dist_table)
-- pass for walls over doors
ray_cast(
world,
player,
dist_table,
detail_limit_table,
dr_start,
dr_end,
true)
-- draw sprites
ce_heap_sort(sprites,player)
for _,s in pairs(sprites) do
draw_billboard_sprite(s,player,zbuf)
end
reset_palette()
end
function ray_cast(
world,player,
dist_table,detail_limit_table,
s_x,e_x,
bad_wall_hack)
local floors={}
local zbuf={}
local check=0
local camx1=player.cam.x
local camy=player.cam.y
local rayx=player.pos.x
local rayy=player.pos.y
local perpwalldist=0
local wallx=0
local raydirx=0
local raydiry=0
local mapx=0
local mapy=0
local dr_start=0
local dr_end=0
local old_p=0
local old_h=0
local old_side=0
local dond=0
local dend=0
local half_height=0
local texwidth=0
for x=s_x,e_x do
rayx=player.pos.x
rayy=player.pos.y
local camx=2*x/128 -1
raydirx=player.dr.x+camx1*camx
raydiry=player.dr.y+camy*camx
mapx=flr(rayx)
mapy=flr(rayy)
--.5143->.4703 wow! thanks lodev tut
local ddx=abs(1/raydirx)
local ddy=abs(1/raydiry)
if abs(raydirx)<0.01 then
if raydirx<0 then
raydirx=-0.01
else
raydirx=0.01
end
ddx=100
end
if abs(raydiry)<0.01 then
if raydiry<0 then
raydiry=-0.01
else
raydiry=0.01
end
ddy=100
end
-- printh("r:"..raydiry,"debug")
local hit=0
local side=0
local stepx=0
local stepy=0
local sidedistx=0
local sidedisty=0
local texidx=0
local last_texidx=0
local d=nil--door
if raydirx<0 then
stepx=-1
sidedistx=(rayx-mapx)*ddx
elseif raydirx>0 then
stepx=1
sidedistx=(mapx+1-rayx)*ddx
else
-- perpendicular so 'infinite'
sidedistx=20000
end
if raydiry<0 then
stepy=-1
sidedisty=(rayy-mapy)*ddy
elseif raydiry>0 then
stepy=1
sidedisty=(mapy+1-rayy)*ddy
else
sidedisty=20000
end
while hit==0 do
if sidedistx<sidedisty then
sidedistx+=ddx
mapx+=stepx
side=0
else
sidedisty+=ddy
mapy+=stepy
side=1
end
last_texidx=texidx
texidx=world[mapy][mapx]
-- check moving from outside->inside
if texidx==0 then
if bad_wall_hack then
hit=1
texidx=6
end
if last_texidx~=0 then
if (dr_start==0) dr_start=x
dr_end=x
end
-- check for wall texture tiles
elseif texidx>2 then
-- wall over door
if texidx==3
and bad_wall_hack then
hit=1
texidx=6
elseif texidx==3 or texidx==5 then
-- door handling
if (dr_start==0) dr_start=x
dr_end=x
-- do a load of extra calculations
-- for the offset door
local map_x2=mapx
local map_y2=mapy
if (rayx<map_x2) map_x2-=1
if (rayy>map_y2) map_y2+=1
local adj=1
local ray_mult=1
if side==0 then
adj=(map_x2-rayx)+1
ray_mult=adj/raydirx
else
adj=map_y2-rayy
ray_mult=adj/raydiry
end
local rxe=rayx+raydirx*ray_mult
local rye=rayy+raydiry*ray_mult
d=door_for(mapx,mapy)
local rdy2=raydiry*raydiry
local rdx2=raydirx*raydirx
if side==0 then
local ddx2=sqrt(1+rdy2/rdx2)
local y_step=sqrt(ddx2*ddx2-1)
if flr(rye+(stepy*y_step)/2)==mapy then
if texidx==5 or (rye+(stepy*y_step)/2)-mapy>d.open_pcnt/100 then
hit=1
mapx+=stepx/2
end
end
--[[ if hit==0 then
mapx+=5
rayx+=5
end]]
else
local ddy2=sqrt(1+rdx2/rdy2)
local x_step=sqrt(ddy2*ddy2-1)
if flr(rxe+(stepx*x_step)/2)==mapx then
if texidx==5 or (rxe+(stepx*x_step)/2)-mapx>d.open_pcnt/100 then
hit=1
mapy+=stepy/2
end
end
end
else
hit=1
end
end
end
--0.7424
if side==0 then
perpwalldist=(mapx-rayx+
(1-stepx)/2)/raydirx
wallx=rayy+perpwalldist*raydiry
else
perpwalldist=(mapy-rayy+
(1-stepy)/2)/raydiry
wallx=rayx+perpwalldist*raydirx
end
--[[if x==64 then
msg=""..perpwalldist
end]]
zbuf[x]=perpwalldist
zbuf[x+1]=perpwalldist
wallx-=flr(wallx)
local texx=flr(wallx*16)
local stack_tex={}
stack_tex[0]=texidx
stack_tex[1]=texidx
local stacks=0
if (last_texidx==1 or last_texidx==2) stacks=1
local stack_start=0
if (bad_wall_hack) stack_start=1
if texidx==3 then
if d.open_pcnt>0 then--whuuuuuut
texx+=1
end
texx-=(d.open_pcnt/100)*16
if stacks>0 then
stack_tex[1]=6
end
end
local lheight=flr(128/perpwalldist)
if lheight~=old_h
or side~=old_side then
half_height=lheight/2
local dstart=-(half_height)+64
dend=half_height+64
-- hack for being very close
-- to the wall. doesn't quite
-- work
if dstart>dend then
dstart=0
dend=128
end
if (dend<64) dend=128
if lheight==0 then
dstart=0
dend=128
end
dend=dend or 128
local dcol=
min(15,flr((dend-dstart)/2))
if (side==1) dcol=max(dcol-3,0)
local p=clamp(15-dcol,0,7)
--0.7368
if p~=old_p then
palette(p)
old_p=p
end
dond=dend-dstart+1
-- texwidth=clamp(perpwalldist/2,1,2)
-- if (perpwalldist>4) texwidth=2
end
-- if half_height~=old_h then
for i=stack_start,stacks do
local foo=half_height*(max(1,i*3))
local dstart2=-foo+64
-- sspr(stack_tex[i]*16+texx,0,1,16,x,dstart2,1,dond)
sspr(stack_tex[i]*16+texx,0,1,16,x,dstart2,1,dond)
end
-- end
old_h=lheight
old_side=side
-- draw every other vertical line
if x%2==0 and dend<128 then
add(floors,
{
x,
check%2,
dend,
raydirx,
raydiry,
flr(max(
detail_limit_table[x],
dend)),
stacks })
check+=1
end
end
reset_palette()
local par_col={}
par_col[0]=4
par_col[1]=9
par_col[2]=10
par_col[3]=10
par_col[4]=7
par_col[5]=7
local cam=player.cam
local dr=player.dr
for _,s in pairs(particles) do
s.z+=1
s.life-=1
if s.z>30 or s.life==0 then
del(particles,s)
end
local s_x=s.x-player.pos.x
local s_y=s.y-player.pos.y
local invdet=1/(cam.x*dr.y-cam.y*dr.x)
local tfx=invdet*(dr.y*s_x-dr.x*s_y)
local tfy=invdet*(-cam.y*s_x+cam.x*s_y)
local scr_x=64*(1+tfx/tfy)
local scr_y=64-(s.z/tfy)
-- int drawstarty = -spriteheight / 2 + h / 2 + vmovescreen;
if tfy>0 and tfy<128 then
-- msg=">> "..(tfy/tfx)
local sz=
flr(clamp(5-sqrt(s_x*s_x+s_y*s_y),0,3))
rectfill(
scr_x,
scr_y,
scr_x+sz,
scr_y+sz,
par_col[clamp(flr(s.life/10),0,5)])
end
end
return floors,zbuf,dr_start,dr_end
end
function floor_cast(floors,world,player,dist_table)
local h=128
local px=player.pos.x
local py=player.pos.y
for _,f in pairs(floors) do
local x=f[1]
local x_width=x+3
local check=f[2]
local dend=f[3]
local raydirx=f[4]
local raydiry=f[5]
local start_dither=f[6]
local stacks=f[7]
--653 to beat
local curdist=0
local cfloorx=0
local cfloory=0
local floortex=0
local floortexx=0
local floortexy=0
if stacks==0 then
rectfill(x,128-start_dither,x+2,128-(dend+3),1)
end
-- for y=start_dither-check,dend+5,-2 do
for y=start_dither-check,dend+5,-2 do
curdist=dist_table[y]
cfloorx=curdist*raydirx+px
cfloory=curdist*raydiry+py
floortex=world[flr(cfloory)][flr(cfloorx)]
-- floortex=abs(world[flr(cfloory)*32+flr(cfloorx)])
-- floortex=peek(0x4300+32*flr(cfloory)+flr(cfloorx))
floortexx=(cfloorx*16)%16
floortexy=(cfloory*16)%16
local tcol=sget(floortex*16+floortexx,floortexy)
pset(x,y,tcol)
if floortex==0 then
local trcol=sget(floortexx,floortexy+16)
pset(x,128-y,trcol)
end
end
for y=h-check,start_dither,-2 do
curdist=dist_table[y]
cfloorx=curdist*raydirx+px
cfloory=curdist*raydiry+py
floortex=world[flr(cfloory)][flr(cfloorx)]
-- floortex=abs(world[flr(cfloory)*32+flr(cfloorx)])
--6503->6374
-- floortex=peek(0x4300+32*flr(cfloory)+flr(cfloorx))
if floortex==3 or floortex==5 then
floortex=0
end
floortexx=(cfloorx*16)%16
floortexy=(cfloory*16)%16
local tcol=sget(floortex*16+floortexx,floortexy)
-- local tcol2=sget(floortex*16+floortexx,floortexy+1)
rectfill(x,y,x_width,y,tcol)
if floortex==0 then
local trcol=sget(floortexx,floortexy+16)
rectfill(x,128-y,x_width,128-y,trcol)
end
end
end
end
-->8
-- cats/sprites
-- creating sprites, drawing them,
-- some update stuff
function make_cat(x,y,a)
local c=make_sprite(x,y,32,32,a,false)
c.v=0
c.sv=0
c.think_timer=1
c.id=id
id+=1 --each cat needs their own id
c.do_plan=function(self)
local accel=0.01
local dx=self.pos.x-self.target.x
local dy=self.pos.y-self.target.y
if dx*dx+dy*dy>0.2 then
local r_diff=abs(self.target_r-self.a)%360
if r_diff>20 then
local rot=15
local cw=
loop_angle(self.target_r-self.a)
local ccw=
loop_angle(self.a-self.target_r)
if cw>ccw then
rot=-15
end
--msg=cw.." v "..ccw
turn_player(self,rot)
else
self.think_timer=1
accel=0.04
end
else
self.think_timer=1
end
move_in_current_dir(self,accel)
update_p(self)
end
c.update=function(c)
c.think_timer-=1
if c.think_timer==0 then
c.think_timer=30
c.target=pick_target(c,player)
local o=c.target.y-c.pos.y
local a=c.target.x-c.pos.x
local new_r=atan2(-o, -a)*360-90
if (new_r>360)new_r-=360
if (new_r<0)new_r+=360
rotate_to(c,new_r)
--msg=c.target_r.."!"
--end plan
end
c:do_plan()
end
return c
end
function pick_target(picker,potential)
local dx=picker.pos.x-potential.pos.x
local dy=picker.pos.y-potential.pos.y
local dist_to_target=dx*dx+dy*dy
if potential.prev then
dx=picker.pos.x-potential.prev.x
dy=picker.pos.y-potential.prev.y
if dx*dx+dy*dy<dist_to_target then
return {x=player.prev.x,y=player.prev.y}
end
end
return {x=potential.pos.x,y=potential.pos.y}
end
function make_sprite(x,y,width,height,a,flat)
local s={
a=0,
target_r=0,
dr={x=1,y=0},
pos={x=x,y=y},
flat=flat,
width=width,
height=height
}
return s
end
function draw_billboard_sprite(s,player,zbuf)
local pos=player.pos
local dr=player.dr
local cam=player.cam
local t_w=s.width
local t_h=s.height
local s_x=s.pos.x-pos.x
local s_y=s.pos.y-pos.y
local s_dist=
sqrt(s_x*s_x+s_y*s_y)
local invdet=1.0/
(cam.x*dr.y-
cam.y*dr.x
)
local t_x=invdet*(
dr.y*s_x-
dr.x*s_y
)
local t_y=invdet*(
-cam.y*s_x+
cam.x*s_y
)
-- if t_y>0 and t_y<128 then
local sscr_x=flr(64*(1+t_x/t_y))
local s_height=flr(abs(128/t_y))
local ds_y=-s_height/2+64
local s_width=s_height
local ds_x=-s_width/2+sscr_x
if ds_x<0 then
ds_x=0
end
local de_x=s_width/2+sscr_x
if (de_x>=128) de_x=127
if t_y>0 and t_y<128 then
local a_to_spr=(s.a-player.a)
if a_to_spr>360 then
a_to_spr-=360
elseif a_to_spr<0 then
a_to_spr+=360
end
-- msg="a="..a_to_spr
local rot_tex_idx=0
if a_to_spr<45
or a_to_spr>315 then
rot_tex_idx+=t_w*2
elseif a_to_spr>=45
and a_to_spr<125 then
rot_tex_idx+=t_w
elseif a_to_spr>225 then
rot_tex_idx+=t_w*3
end
palette(clamp(flr(s_dist-2),0,15))
for i=ds_x,de_x do
if zbuf[flr(i)]>s_dist then
local texx=(
i-(-s_width/2+sscr_x))*(t_w-1) /s_width
sspr(rot_tex_idx+texx,64,1,t_h,i,ds_y,1,s_height)
end
end
end
end
-->8
-- utils
function is_between(e,a,b)
local tmp=a
if b<a then
a=b
b=tmp
end
if e>=a and e<=b then
return true
end
return false
end
function is_between_v(e,a,b)
if is_between(e.x,a.x,b.x)
and is_between(e.y,a.y,b.y)
then
return true
end
return false
end
function loop_angle(a)
if (a>360) return abs(a-360)
if (a<0) return abs(a+360)
return a
end
function clamp(val,mi,ma)
return max(mi,min(ma,val))
end
function add_v(a,b)
return {x=a.x+b.x,y=a.y+b.y}
end
function sub_v(a,b)
return {x=b.x-a.x,y=b.y-a.y}
end
function dot(a,b)
return a.x*b.x+a.y*b.y
end
function v_len(x,y)
return sqrt(x*x+y*y)
end
function normalize(a)
local len=v_len(a.x,a.y)
return {x=a.x/len,y=a.y/len}
end
-- adapted from heap sort
-- originally by @casualeffects
function ce_heap_sort(data,player)
if (#data==0) return
local n = #data
local p_pos=player.pos
for d in all(data) do
local dx=(d.pos.x-p_pos.x)/10
local dy=(d.pos.y-p_pos.y)/10
d.key=dx*dx+dy*dy
end
-- form a max heap
for i = flr(n / 2) + 1, 1, -1 do
-- m is the index of the max child
local parent, value, m = i, data[i], i + i
local key = value.key
while m <= n do
-- find the max child
if ((m < n) and (data[m + 1].key < data[m].key)) m += 1
local mval = data[m]
if (key < mval.key) break
data[parent] = mval
parent = m
m += m
end
data[parent] = value
end
-- read out the values,
-- restoring the heap property
-- after each step
for i = n, 2, -1 do
-- swap root with last
local value = data[i]
data[i], data[1] = data[1], value
-- restore the heap
local parent, terminate, m = 1, i - 1, 2
local key = value.key
while m <= terminate do
local mval = data[m]
local mkey = mval.key
if (m < terminate) and (data[m + 1].key < mkey) then
m += 1
mval = data[m]
mkey = mval.key
end
if (key < mkey) break
data[parent] = mval
parent = m
m += m
end
data[parent] = value
end
end
function calculate_fps(now)
frames+=1
local newnow=flr(now)
if (newnow!=lastclock) then
fps=frames
frames=0
lastclock=newnow
end
end
-->8
-- player
function make_player()
return {
id=0,
a=0,
vr=0,
v=0,
sv=0,
--pos={x=3.6,y=3.8},
pos={x=6.5,y=18},
prev={x=3.6,y=3.8},
dr={x=1,y=0}, -- looking west
cam={x=0,y=0.66},
update=update_player_with_input
}
end
function update_player_with_input(self)
update_p(self)
self.vr*=0.9
self.a+=self.vr
if self.a>359 then
self.a-=359
end
local r=self.a/360
local olddrx=self.dr.x
self.dr.x=cos(r)
self.dr.y=-sin(r)
if self.cam then
local r2=self.vr/360
local oldplanex=self.cam.x
self.cam.x=oldplanex*cos(r2)+
self.cam.y*sin(r2)
self.cam.y=-oldplanex*sin(r2)+
self.cam.y*cos(r2)
end
if timer%60==0 then
self.prev.x=self.pos.x
self.prev.y=self.pos.y
end
end
function move_in_current_dir(s,amount)
s.v=clamp(s.v+amount,-0.3,0.3)
end
function strafe_in_current_dir(s,amount)
s.sv=clamp(s.sv+amount,-0.3,0.3)
end
-- todo:remove i think
function turn_player(player,ar)
player.a+=ar
if player.a>359 then
player.a-=359
end
player.a=flr(player.a)
local r=player.a/360
local olddrx=player.dr.x
player.dr.x=cos(r)
player.dr.y=-sin(r)
if player.cam then
local r2=ar/360
local oldplanex=player.cam.x
player.cam.x=oldplanex*cos(r2)+
player.cam.y*sin(r2)
player.cam.y=-oldplanex*sin(r2)+
player.cam.y*cos(r2)
end
end
function turn_player2(player,ar)
player.vr=clamp(player.vr+ar,-6,6)
end
function update_p(s)
s.v*=0.6
s.sv*=0.6
local mvx=player.cam.x*s.sv+s.dr.x*s.v
local mvy=player.cam.y*s.sv+s.dr.y*s.v
local movex=s.pos.x+mvx
local movey=s.pos.y+mvy
local move_sq=world
[flr(s.pos.y)]
[flr(movex)]
if move_sq<3
or (move_sq==3 and door_for(
flr(movex), flr(s.pos.y)).open_pcnt>70)
-- and abs(flr(movex)-movex)>0.1
then
s.pos.x=movex
end
move_sq=world
[flr(movey)]
[flr(s.pos.x)]
if move_sq<3
or (move_sq==3 and door_for(
flr(s.pos.x), flr(movey)).open_pcnt>70)
-- and abs(flr(movey)-movey)>0.1
then
s.pos.y=movey
end
end
function rotate_to(s,targetrotation)
s.target_r = targetrotation
end
-->8
-- map utils/doors
-- map creation, door updating
-- also drawing the map view
doors={}
map_to_tex_mapping={}
map_to_tex_mapping[96]=0
map_to_tex_mapping[97]=1
map_to_tex_mapping[98]=2
map_to_tex_mapping[99]=3
map_to_tex_mapping[100]=4
map_to_tex_mapping[101]=5
map_to_tex_mapping[102]=6
map_to_tex_mapping[103]=7
tex_to_map_mapping={}
tex_to_map_mapping[0]=96
tex_to_map_mapping[1]=97
tex_to_map_mapping[2]=98
tex_to_map_mapping[3]=99
tex_to_map_mapping[4]=100
tex_to_map_mapping[5]=101
tex_to_map_mapping[6]=102
tex_to_map_mapping[7]=103
function map_to_tex(mapval)
return map_to_tex_mapping[mapval]
end
function make_world()
local new_world={}
for y=0,32 do
new_world[y+1]={}
for x=0,32 do
--local tex=map_to_tex(mget(x,48+y))
local tex=map_to_tex(mget(x,y))
new_world[y+1][x+1]=tex
if tex==3 then
add(doors,{x=x+1,y=y+1,open_pcnt=0,open_vel=0})
end
end
end
return new_world
end
function door_for(x,y)
for _,d in pairs(doors) do
if d.x==x and d.y==y then
return d
end
end
return nil
end
function check_door(d,p)
local dx=p.pos.x-(d.x+0.5)
local dy=p.pos.y-(d.y+0.5)
local dtd=abs(dx*dx+dy*dy)
-- msg=player.pos.x.." "..player.pos.y.." "..d.x.." "..d.y.." "..dtd
-- msg=""
if dtd<2 then
-- msg="door "..dtd.." "..d.x.." "..d.y.." "..player.pos.x.." "..player.pos.y
return true
else
return false
end
end
function update_doors(doors)
for _,d in pairs(doors) do
local near_door=check_door(d,player)
for _,c in pairs(cats) do
near_door=near_door or check_door(d,c)
end
if near_door then
if d.open_pcnt<100 then
d.open_vel=5
end
else
if d.open_pcnt>0 then
d.open_vel=-5
end
end
d.open_pcnt=clamp(d.open_pcnt+d.open_vel,0,100)
end
end
function draw_map_view(world,player)
cls(5)
pal(7,7)
-- camera((player.pos.x*8),(player.pos.y*8))
reset_palette()
for y=1,#world do
for x=1,#world[y] do
local sp=world[y][x]
-- if (sp==-1) sp=16
-- spr(sp,(x-1)*8,#world*8-y*8)
spr(tex_to_map_mapping[sp],(x-1)*8,(y-1)*8)
end
end
local px=8*(player.pos.x-1)
local py=8*(player.pos.y-1)
local pxe=px+player.dr.x*5
local pye=py+player.dr.y*5
line(
px,py,
pxe,pye,
10)
pset(px,py,9)
circfill(8*(player.prev.x-1),8*(player.prev.y-1),1,9)
for _,s in pairs(sprites) do
local px=8*(s.pos.x-1)
local py=8*(s.pos.y-1)
local pxe=px+s.dr.x*5
local pye=py+s.dr.y*5
line(
px,py,
pxe,pye,
9)
pset(px,py,8)
end
for _,p in pairs(projectiles) do
line(
8*(p.pos.x-1),8*(p.pos.y-1),
8*(p.en.x-1),8*(p.en.y-1),
8)
if (p.closest)pset(8*(p.closest.x-1),8*(p.closest.y-1),11)
end
for _,p in pairs(particles) do
pset(8*(p.x-1),8*(p.y-1),11)
end
-- print("msg: "..msg,2,120,7)
camera()
end
-->8
--projectiles
-- creation+raycasting projectiles
function add_projectile(player,projectiles)
add(projectiles,{
id=player.id,
pos={x=player.pos.x,y=player.pos.y},
dr={x=player.dr.x,y=player.dr.y},
life=4,
update=function(self)
local rxe,rye=single_ray_cast(
self.pos,self.dr,world
)
self.en={x=rxe,y=rye}
local dr=normalize(sub_v(self.pos,self.en))
-- hardcoded so hardcoded!
for _,e in pairs(sprites) do
local ac=sub_v(self.pos,e.pos)
local dist=dot(ac,dr)
local proj={x=dr.x*dist,y=dr.y*dist}
self.closest=add_v(self.pos,proj)
--msg=self.pos.x.." "..proj.x.." "..proj.y
if abs(e.pos.x-self.closest.x)<0.5
and abs(e.pos.y-self.closest.y)<0.5
and is_between_v(
e.pos,
player.pos,
self.en
)
then
self.hit=true
del(sprites,e)
del(cats,e)
for i=0,1,0.1 do
local d=0.5
add(particles,{
x=e.pos.x+d*sin(i),
y=e.pos.y+d*cos(i),
z=rnd(50)-30,
life=10+rnd(5)})
end
end
end
-- wall particle puff
if not self.hit then
self.hit=true
for i=0,1,0.1 do
local d=0.1
add(particles,{
x=rxe+d*sin(i)+rnd(0.1),
y=rye+d*cos(i)+rnd(0.1),
z=rnd(50)-30,
life=10+rnd(5)})
end
end
-- msg=self.closest.x.." "..self.closest.y
self.life-=1
end
})
end
function single_ray_cast(p,ray,world)
local map_x=flr(p.x)
local map_y=flr(p.y)
local side=0
local step_x=0
local step_y=0
local dx=abs(1/ray.x)
local dy=abs(1/ray.y)
local hit=0
local rxe=0
local rye=0
if ray.x<0 then
step_x=-1
side_x=(p.x-map_x)*dx
else
step_x=1
side_x=(map_x+1-p.x)*dx
end
if ray.y<0 then
step_y=-1
side_y=(p.y-map_y)*dy
else
step_y=1
side_y=(map_y+1-p.y)*dy
end
while hit==0 do
if side_x<side_y then
side_x+=dx
map_x+=step_x
side=0
else
side_y+=dy
map_y+=step_y
side=1
end
if world[map_y][map_x]>2 then
hit=1
if (p.x<map_x) map_x-=1
if (p.y>map_y) map_y+=1
local adj=1
local ray_mult=1
if side==1 then
adj=map_y-p.y
ray_mult=adj/ray.y
else
adj=(map_x-p.x)+1
ray_mult=adj/ray.x
end
rxe=p.x+ray.x*ray_mult
rye=p.y+ray.y*ray_mult
end
end
return rxe,rye
end
-->8
--palette stuff
function reset_palette()
palette(0)
end
function palette(z)
memcpy(0x5f00,0x5000+16*z,16)
end
function create_palettes()
for z=0,7 do
for i=0,15 do
local col=sget(i,z+32)
if i==12 then
col=bor(0x80,i)
end
poke(0x5000+16*z+i,col)
end
end
end
-- for extended pico palette
function new_palette()
--[[ for i=0,15 do
pal(i,i+128,1)
end]]
--[[ext_pal(1)
ext_pal(2)
ext_pal(4)
ext_pal(5)
ext_pal(6)
ext_pal(8)
ext_pal(13)
ext_pal(14)]]
poke(0x5f2e,1)
end
function ext_pal(c)
pal(c,c+128,1)
end
function original_palette()
--[[ for i=0,15 do
pal(i,i,0)
end]]
end
__gfx__
ddddd555d5dddddd5111511311b1153b442444642244422411111111111111111122211111122211112d3111111222115d5d515d5d5d5d5d111111111111111d
dd5d6d5d5dd5ddd51311131b11311131544524444464445419a29a59a29a29a1411111442211511441d3b34422115114111111111111111115d15d15d15d15dd
ddddd5d5d5dddddd1331111b11311111445224424442244414954944954954a12211142222211142221b3422222111425d6761111d67671515d15d15d15d15dd
dd5ddddddd6dd6dd1b31511b511513114422164454421444144244244544249122211222222211222223b222222211225dddd155ddddd61515d15d15d15d15dd
d5d5d5dddddddddd13b3111b1113135144444464524454461494494494494441252112225552112225213222525211225d5d51555d5d551515d15d15d15d15dd
dd5ddddddd5d5d5d1b33131313311b114224544421244224144244244254244155111555511111125211152525211112111551111115115115d15d15d1dd15dd
5d65ddddd555d5dd1b3b111331311b112122444422242124122222222222222111111111114421111111111111111111115111111111111115d15d15515d15dd
dd555ddd5d5d5ddd1b3315111111131122144124444252141424524254244241114422111442211111442211143d3311551155d66767155615515d15d15d15dd
d555d5ddd5d5dd5d13b3111311531351444442244444444414444444444dd1411422221442222111142222144223b211551155555556155515d15d15d15d15dd
5d5d5ddddd555ddd1b3135131511111124444444454224641222222222221121122225122222214412222512222b3111d51ddddddd5515d515d15d15d1dd155d
d5ddd56dddd555dd131b31b11111515112442444244114421111111111111111112551122222114211252112222231445d11ddddddd5115d15d15d15d15d15dd
dd5dddd6d5dd5dd5151331b5311111312246442124422442122122122122122121111122525114222111112252511422d51111111d5511d515d15d15d15d15dd
d6ddd56dddd5d5dd1115133131511131244464124444442412424525524414415111112555111222511331252511122211111111511111111551551d5155155d
dddd5d5ddddd5d5d51111111111131b34424424444644444121144144145114111442112511411521143b11251141152555d6d6711555d55155155155155155d
5d5dd5dd5dddd5dd115311151131313b52124464224442241111211121121111142222111142211114223211114221115555d5d61155d6d5155155155155156d
dddd5d5dddd6d5d61113311111b1113b41225442212452221111111111111111122222111122221112222211112222111111111511111d6d11d11d11d11d11d6
111111111111111d112d311111122211222222224524422211c111111ccd111155555551d55555551111111111111111cccccccccccccccccccccccccccccccc
15d15d15d15d15dd41d3b3442211511422224522442242521cc11111dcccd111dddddd51dddddddd19a29a59a29a29a1cccccccccccccccccccccccccccccccc
15d15d15d15d15dd221b3422222111422452442224222242ccdc1111ccdccccc76676651d676766614954222222454a1cccccccccfffffffcccccccccccccccc
15d15d15d15d15dd2223b222222211225452422222225222111ccccccdddcc1167667651d667676614422cccccc22491ccccccfffff9fffffffffffccccccccc
15d15d15d15d15dd25213222525211224442424452255225111c1111c1111c11667676515676677614942cccccc24441cccccf79fff99fffffffffffcccccccc
15d15d15d1dd15dd5211152525211112445222244424442411ccd11dc1111c11676676515766766614422cccccc22441ccccf7f9ffffffffffffffffcccccccc
15d15d15515d15dd11111111111111114422222224244422ccddc11cc111cccc677676515676676712222cccccc22221cccc7ff4999ffffff99999fffccccccc
15515d15d15d15dd11442211143d33112425524224224222c11dcccccc11cc1c766776515666767614242cccccc24241cccc79f49ff99ff99111dddddd6ccccc
15d15d15d15d15dd142222144223b2112224524424122221c1111c11dccccd1c776767515676666714441cccccc1d141cccff9994f99999111ddddddddddd6cc
15d15d15d1dd155d12222512222b31112224424422224412c1111c111111c11c667667515667667612221cccccc11121cccfff492f9991111ddddddddddddd6c
15d15d15d15d15dd11252112222231441214422221214422cc11cc111111ccc167667751567667661111111111111111cccf29942f991111111dddddddddddd6
15d15d15d15d15dd211111225251142222244214411242241ccccccccd111ccc67767651576677671221221221221221cccc4242ff99111111111ddddddddddd
1551551d5155155d51133125251112224212211244122144cc1dcd1dccd1ccd167677651567676761242421421441441ccff422f99911111111111dddddddddd
155155155155155d1143b1125114115242244221442242441c1c11111ccccd1166666651566666661211421421451141ccf9fff99991111111111111dddddddd
155155155155156d1422321111422111121441122224412411cc11111dccd111d7dd75155dd6dd6d1111211121121111ccff999999111111111111111ddddddd
11d11d11d11d11d61222221111222211211121111414111211c111111cc1111111111111111111111111111111111111ccfff9999911111111111111111ddddd
0123456789abcdefcccccccc00000000666d6ddd666d66d61242424214242421010010150010010066fff66f666fff6611294441111911110123456789ab1def
012325562493dde9cccccccc00000000dddddddddddddddd149494a219494942005000001005000555dd5555555dd5551124494141149111012325562493dde9
2123255d2493d524cccccccc00000000111111111111111114a494a219494a421010010100000100005500000005500011244941411449112123255d2493d524
0111215d2243d524cccccccc0000000000000000000000001494a4a21a494a420000100001100001101101111101101111224941491244910111215d2243d524
0111111512211522cccccccc0000000001010100100010101494a492194a49420500050100001000101101111101101111224441441149410111111512211522
0001111112211122cccccccc00000000111111111111111114949492194949420001000010510050101101111101101111122441249124990001111112211122
000011111221112211cccccc00000000212212122121222114949142191949425100010100000001101101111101101111122441244112440000111112211122
0000101111111111e1cccccc0000000052252155d212d2d214911142191119420001500050111000101101010101101191112241224912240000101111111111
0000001100000000e11111cccccccccc55d5d515512155551491d142191d19421500001000000050101101010101101044111241124411240000001100000000
0000000100000000ee1ee11ccccccccc5555155d5515555512915142191519420001000000100001001100000001100049111244124441220000000100000000
0000000000000000e11111111ccccccc5d555d555dddd5d512911142192119421000150010010100d5115d555d5115d544411124112241220000000000000000
0000000000000000eee11e1111cccccc555dd55ddddd5ddd12949442194449420150001005000005666666666666666624441111111221220000000000000000
00000000000000001eee1ee1e1cccccc5d5ddddddddddddd12949442124449420000000001050001111111111111111122441111111111110000000000000000
00000000000000001eee1ee1e11ccccc555dddd5555dd55512949492124949420101001000000100555555555555555522244144499111110000000000000000
00000000000000001eeee1e1ee1ccccc5155d555d55551d512929292122929225050000050010010ff65d6656f6d55d612224124444911110000000000000000
0123456789abcdef11eee1e1ee1ccccc111115151115111111424242112424210000501000100500f6d56f65d66d5d6f11224412444491110123456789abcdef
2555555255355333442444341111111100111100111111111111111111111111dd666dd6ddd666dd00000000000000001111111111111111ccc5dcccccc5dccc
5d5ddd55333333135445244419a29a5111525491115211411d1d1dd115d115d155dd5555555dd55504409909904409901224941249912499ccc1f555555fdccc
5dddddd53351355344522442149549411295542112113b211d6761d11565156100110000000110000990aa0490990aa01111111111111111ccc19555555dcccc
5d6666d513353533242213441442442112415221124132211dddd15115651561105501111105501100000000000000002444124444124441ccc111a7551a7ccc
556665d555333335444444421494494115211221152112211d5d515115d51561105501111105501100000000000000001111111111111111ccc1190a5190accc
5dd66dd555333335422454421442442115215451152154511115511115d515d110550111110550110330a902209901101111112244412444ccc11aaa51aaaccc
5dddddd5533513332142444412222221151155111511551111511d6115d115d110550111110550110bb0a90440a90d101111111111111111ccc1511150011ccc
5555555533555533421441241111111101101110111111111111111111121112105501010105501100000000000000004441244441111112cccc1155115dcccc
000000005111511533553bb30000000000000000776ff77700000000100f0000105501010105501000000000000000001111111111111111ccc11111111ccccc
0000000015b3355133333333000000000000000076deff7700000000200e0000005500000005500004401109909909a01224441244412444ccc111155dddcccc
000000001333b3313553355300000000000000006d58ef770000000050089f7055dd5555555dd5550990dd0a909a09a01111111111111111cc11115555dddccc
0000000013baab31333bab330000000000000000d51249f700000000d00200a06d66d6d6d6d66d6d00000000000000004411111112444122cc111155555dddcc
00000000133abab13333333300000000000000006d51249f000000006d51249f111111111111111100000000000000001111111111111111cc111155555dddcc
0000000013b3333135355333000000000000000076d349af0000000070030040555555555555555509904409902209902444412444412441cc1111155555ddcc
000000001b3b3b513bb333550000000000000000766baa7700000000d00b002066ddddddd6dddddd0aa0aa09a0440a902222222222222222cc1111115555ddcc
00000000111515113333333300000000000000007776777700000000500600106dddd6ddddddddd600000000000000004444444444444444ccc111111111dccc
cccc1111ccccccccccccc11111ccccccccccccc111ccccc155cccccccccccccccccccc11111cccccccccc11111cccccccccccccccccccc511ccccc111ccccccc
cccc155511cc111111c115f551ccccccccccccc15f55cc155fcccccccccccccccccccc1555511c1111c1155551ccccccccccccccccccccf551cc55f51ccccccc
cccc155ff9115555551555f51cccccccccccccc15ff5551559ccccccccccccccccccccc155555155551555551ccccccccccccccccccccc9551555ff51ccccccc
ccccc15ff9155555555519f51cccccccccccccc159ff5555555cccccccccccccccccccc151155555555551151cccccccccccccccccccc5555555ff951ccccccc
ccccc15f99155555555551951cccccccccccccc1599555551155ccccccccccccccccccc151155555555551151ccccccccccccccccccc5511555559951ccccccc
ccccc15011511115555511151cccccccccccccc155555551aa155cccccccccccccccccc111555555555555111cccccccccccccccccc551aa155555551ccccccc
cccccc11151aaaa15551aaa1ccccccccccccccc115555551a0155ccccccccccccccccccc5555555555555555ccccccccccccccccccc5510a155555511ccccccc
cccccc11151aa0a15551a0a1ccccccccccccccc115555551a015555ccccccccccccccccc5555555555555555ccccccccccccccccc555510a155555511ccccccc
ccccccc1151aa0a15551a0a1ccccccccccccccc115555551aa155500cccccccccccccccc5555555555555555cccccccccccccccc005551aa155555511ccccccc
ccccccc1151aaaa15551aaa15cccccccccccccc115555551aa155000ccccccccccccccc555555555555555555ccccccccccccccc000551aa155555511ccccccc
ccccccc115511115115511155cccccccccccccc11555555511555050ccccccccccccccc155555555555555551ccccccccccccccc05055511555555511ccccccc
ccccccc111555555005555555cccccccccccccc11155555555555055cccccccccccccc11155555555555555111cccccccccccccc11055555555555111ccccccc
ccccccc11100555000055505ccccccccccccccc11155555555550555cccccccccccccccc1155551111555511cccccccccccccccc11505555555555111ccccccc
ccccccc11110000055000015ccccccccccccccc11115555555005515ccccccccccccccc111111111111111111ccccccccccccccc11150055555551111ccccccc
cccccccc111111555555115ccccccccccccccccc111115555555511cccccccccccccccccc11111111111111cccccccccccccccccc111155555551111cccccccc
ccccccc111111111155555ccccccccccccccccc1111111111115cccccccccccccccccccccc111111111111cccccccccccccccccccccc11155511111ccccccccc
ccccccc111111115555555ccccccccccccccccc1111111111155ccccccccccccccccccc111111111555551cccccccccccccccccccc111115555555cccccccccc
cccccc11111555555555555ccccccccccccccc111115555555555ccccccccccccccccc11111555555555555cccccccccccccccccc11555555555555ccccccccc
ccccc1111155555555555555ccccccccccccc11111555555555555ccccccccccccccc1111155555555555555cccccccccccccccc1155555555555555cccccccc
ccccc11111555555555555555cccccccccccc111115555555555555cccccccccccccc11111555555555555555cccccccccccccc111555555555555555ccccccc
ccccc111115555555555555555ccccccccccc111115555555555555cccccccccccccc111115555555555555555ccccccccccccc1115555555555555555cccccc
cccc1111115555555555555555cccccccccc11111155555555555555cccccccccccc1111115555555555555555ccccccccccccc1115555555555555555cccccc
cccc1111115555555555555555cccccccccc11111155555555555555cccccccccccc1111115555555555555555cccccccccccc11115555555555555555cccccc
cccc1111115555555555555555cccccccccc111111555555555555555ccccccccccc1111115555555555555555cccccccccccc11115555555555555555cccccc
cccc11111155555555555555555ccccccccc111111555555555555555ccccccccccc11111155555555555555555ccccccccc11111155555555555555555ccccc
ccc111111115555555555555555cccccccc1111111555555555555555cccccccccc111111115555555555555555cccccccc111111155555555555555555ccccc
ccc111111115555555555555555cccccccc1111111155555555555555cccccccccc111111115555555555555555cccccccc111111115555555555555555ccccc
ccc111111115555555555555555cccccccc11111111555555555555555ccccccccc111111115555555555555555cccccccc111111115555555555555555ccccc
ccc111111115555555555555555cccccccc11111111555555555555555ccccccccc111111111111111115555555cccccccc111111115555555555555555ccccc
ccc111111111111115555555555cccccccc11111111111111555555555ccccccccc111111111111111111111555cccccccc111111111111115555555555ccccc
ccccc11111111111111111155ccccccccccc111111111111111111155cccccccccccc11111111111111111111ccccccccccc1111111111111111111555cccccc
ccccccc1111111111111111cccccccccccccc1111111111111111111cccccccccccccc111111111111111111ccccccccccccc11111111111111111111ccccccc
46464646464646464646464646464646000000000000000000000000000000000000000000000000cccc1111ccccccccccccc11111ccccccccc5dcccccc5dccc
00000000000000000000000000000000000000000000000000000000000000000000000000000000cccc155511cc111111c115f551ccccccccc1f555555fdccc
46261616161616464616161616161646000000000000000000000000000000000000000000000000cccc155ff9115555551555f51cccccccccc19555555dcccc
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccc15ff9155555555519f51cccccccccc111a7551a7ccc
46261626261616461616166666661646000000000000000000000000000000000000000000000000ccccc15f99155555555551951cccccccccc1190a5190accc
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccc15011511115555511151cccccccccc11aaa51aaaccc
46261616161616262616660606361646000000000000000000000000000000000000000000000000cccccc11151aaaa15551aaa1ccccccccccc1511150011ccc
00000000000000000000000000000000000000000000000000000000000000000000000000000000cccccc11151aa0a15551a0a1cccccccccccc1155115dcccc
46262626262626262626360606661646000000000000000000000000000000000000000000000000ccccccc1151aa0a15551a0a1ccccccccccc11111111ccccc
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccccc1151aaaa15551aaa15cccccccccc111155dddcccc
46161616161616462616666666161646000000000000000000000000000000000000000000000000ccccccc115511115115511155ccccccccc11115555dddccc
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccccc111555555005555555ccccccccc111155555dddcc
46262616162616462616161616161646340034340000000000000000000000000000000000000000ccccccc11100555000055505cccccccccc111155555dddcc
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccccc11110000055000015ccccccccc11111155555dddc
46262646464646462616464616161646000000000000000000000000000000000000000000000000cccccccc111111555555115cccccccccc11111115555dddc
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccccc111111111155555ccccccccccc11111111111dddc
46262666060606662616164616161646000000000000000000000000000000000000000000000000ccccccc111111115555555cccccccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000cccccc11111555555555555ccccccccc0000000000000000
46166606060606062616164646161646000000000000000000000000000000000000000000000000ccccc1111155555555555555cccccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccc11111555555555555555ccccccc0000000000000000
46160606066666062616462626161646000000000000000000000000000000000000000000000000ccccc111115555555555555555cccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000cccc1111115555555555555555cccccc0000000000000000
46160606060606062646262626261646000000000000000000000000000000000000000000000000cccc1111115555555555555555cccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000cccc1111115555555555555555cccccc0000000000000000
46166606060606662626262626461646000000000000000000000000000000000000000000000000cccc11111155555555555555555ccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccc111111115555555555555555ccccc0000000000000000
46161666666666662616462646461646000000000000000000000000000000000000000000000000ccc111111115555555555555555ccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccc111111115555555555555555ccccc0000000000000000
46161616161616261616161616161646000000000000000000000000000000000000000000000000ccc111111115555555555555555ccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccc111111111111115555555555ccccc0000000000000000
46464646464646464646464646464646000000000000000000000000000000000000000000000000ccccc11111111111111111155ccccccc0000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000ccccccc1111111111111111ccccccccc0000000000000000
__label__
55552211212500000000000000000000000000000000000000000000011444442244444222222222222222222222222200000000000000000000000000000000
55552211112500000000000000000070000000000000000000000000011444442244422222222222222222222222222200000000000000000070000000000000
55777177712500000000000000000000000000070000000000000000011444442222222222222222222222222222222400000000000000000000000000000000
55557171712500000000000000000000000000000000000000000000011444442222222222222222222222222222222400000000000000000000000000000000
55577171712500000000000000000000000000000000000000000000011442222222222222222222222222222444222400000000000000000000000000000000
55557171712500000000000000000000000000000000000007000000011222222222222222222222222224444444222400000000000000000000000000000000
55777177712500000000000000000000000000000000000000000000011222222222222222222222242224444444222400000000000000000000000000000000
55551111112100000000000000000000000000000000000000000000011222222222222222222254442224444444222400000000000000000000000000000011
55551111111100070000000000000000000000000000000000000000011222222222222222222554442224444444222400000000000000000000000000111111
55551111111100000000000000000000000000000000000000000000011222222222222244222554442224444444222400000000000000000000001111111111
55577177717170000000007770000077707770777077700000000000011222222222222444222554442224444444222400000000000000000011111111111111
55711171717170070000007070000070007070707700700000000000011222222255522444222554442224444444222400000000000000111111111111111111
11711177717170000000007070000077707770707007700000000000011222224455522444222554442224444444222400000000111111111111111111111111
11711171117170070000007070000000700070707000700000000000011224224455522444222554442224444444222400001111111111111111111222111111
11177171111770000000007770070077700070777077700000000000011444224455522444222554442224444ddd111411111111111111111112222222111111
111111111111000000000000000000000000000000000000000000000114442244555224442225544422244ddddd111411111111111111122222222222111111
1111111111110000000000000000000000000000000000000000000001144422445552244422255444224ddddddd111411111111122222222222222222111111
1111111211110000000000000000000000000000000700000000000001144422445552244422254444444ddddddd111411111111122222222222222222111111
1111122211110000000000000000000000000070000000000000000001144422445552244424444444444ddddddd111111111111122222222221122111111111
11aaa22aa11aa000000000000000000000000007000000000000000001144422445552244444444444444ddddd11111111111111122222211111111111111111
11aaa2a211a1000a0000000000000000000000000000000000000000011444224444444444444444444411111111444411111111122111111111111111111111
11a4a2aaa1a100000000000000000007000000000000000000000000011444224444444444444444445555111144442222111111111111111111111111111111
11a4a222a1a1a00a0000000000000000000000000000000000000000011444444444444444442222555511111111222211441111111111111111111111111111
11a4a2aa11aaa0000000000000000000000000000000000000000000011444444444441111111111111111444422222222441111111111111111111111114411
11442222111100000000000000000000000000000000000000000000011444444444111111111111111111114444222244441111111111111111111111444444
11442222111100000000000000000000000000000000000000000000011444111111112222111122221111111144442222441111111111111111111111444444
11442222111100000000000000000000000000000000000000000000011411111111444422222222111111112222222244441111111111111111111111444444
11422222111100000000000000000000000000000011100000000022225555111111112222222255551111111111112222441122211111111111111111444444
44222222111100000000000000000000000000111111111000002222555555551111444422222222555511111111111114222222211111111111111111444444
44222222111100000000000000000000111111111111114444222222222222111111114444222255551111221122111111222222211111111111111111444444
11122222111100000000000000001111111111111111111111112222222211111111111122222211111122115511551112222222211111111111111111442222
11111112111100000000000011111111111111111111111111111111111111111111111111111111112211221155551222222222211111111111111111222222
11111111111110000000111111111111111111111111111122111111111111112211551111114411221122111111111222222222211111111111111111222222
11111111111111111111111111111111122222111111111111221111114411221122111111111144111222221111111222222222211222211111111111222222
11111111111111111000111111111112222222114422111111111111111122112211221111111222222222221111111122222222222222211111111111222222
11111111111110000222111111111112225111114422211111111111114411221122111222222222222222221111111122222222222222211111111111222222
11111111111101122222111111111111155111114422211111111111111122111222222222222222222211111111111122222222222222211111111111222222
11111221111111122222111111222111155111114422211111111111111222222222222222222211111111111111111122222222222222211111111111222222
22222221111111122222114442222111155111142421211111111111111222222222211111111111111111111111111122222222222222211111111111222222
22222221111111122111144442222111151111442211111111111122111221111111111111111111111111111111111122222255222222211111111111222222
22222221111141111111144442222121111111442211111111111122211111111111111111111111111111111111111122225555522222211111111111222222
22222221144141111111142242222221111111442211111111112122211111111111111111111111111111111111111122225555522222211111111111222222
22222211444141111111422222222221111111442211111111112211211111111111111111111111111111111111111122225555522222211111111111222222
22222211444142211111422222222221111111422211111111112211111111111111111111111111111111111111111122225555522222211111111111225522
22222211444122211111422222222222211111222211111111112211111111111111111111111111111111111111111122225555522222211111111111555555
22222211444122211111422222222222211111222211111111111211111111111111111111111111111111111111111222225555522112211111111111555555
22222211444122211111222222222222211111222211111111111111111111111111111111111111111122221111222222555555511111111111111111555555
22222211444122221111222222222222211111222211111111111111111111111111111111222221112222221111222255555555511111111111111111555555
22222211444122221111222222552252211111222211111111111111111112221122222111222221112222221111222255555555511111111111111111555555
22222211422122221111222225555552211111222211111111111111111222221122222111222221112222221111222255555555511111111111111111555555
22222114222225521111222225555552211111222211111111111111111222221122222111222221112222221111222255555555511111111111111111551155
55251114222225521111222225555552211111212211111111111111111222221122222111222221112222221111222255555511511111111111111111111111
55251114222225521111225525555551111111112211111111111111111222221122222111222221112222221111222255111111111111111111111111111111
55251114222225521111555555555551111111112211111111111111111222221122222111222221112222221111222211111111111111111111111111111111
55251114222255511111555555555551111111112211111111111111111222221122222111222221112222221111222211111111111111111111111111111111
55251114222255511111555555555551111111111211111111111111111222221122222111222221112222221111222211111111111111111111111111111111
55251114222255511111551155115511111111111111111111111111111222221122222111222221112244421111444411111111111111111111111111111111
55251114222251111111111111111111111111111111111111111111111222441144455222555552224444441111444411111111111441144114211221112211
55551112222511111111111111111111111111111111111111111111111222442244455222555552224444441111444411111111144444444444222222222222
55511112222511111111111111111111112221111111111111111111111222442244455222555552224444441111444411111111144444444444222222222222
55511112222511111422111111141142222222111111111221111111111222442244455222555552224444441111444411111111144444444444222222222222
55511112222511144422211111144442222222111111111222111111111222442244455222555552224444441111444411111111144444444444222222222222
55511112222511144422211111144442222222111111111222111111111222442244455222555552224444441111444411111111144444444444222222222222
55511112222511144422211111144442222222111111111222111111111222442244455222555552224444441111444411111111144444444444222222222222
55511112222514444222211411424422222222111111122212111111111222442244455222555552224444441111444411111144144224422442222222222222
55511112222514422222211444422222222222111111122111111111211222442244455222555552224444441111444411114444422222222222222222222222
55114411552514422222211444422222222222111111122111111111211222112244455211455541124445541111444411114444422222222222222222222222
55114411552112222222211244222222222222111111122111111111211222111144444111444441114445551111111411114444422222222222222222222222
55114411552112222222511222222222222112111111111111111111111222111144444111444441114445551111111411114444422222222222222222222222
55114411552112222222511222222222222111111111111111111111111222111144444111444441114445551111111411114444422222222222222222222222
55114411552111122222511222222222222111111111111111111111111222111144444111444441114445551111111411114422422222222222222222225522
55114411552111122555511222222222222111111111111111111111111222111144444111444441114445551111111411112222222222222222222222555555
55114411552111125555111222222222221111144111111111111111111222111144444111444441114445551111111411112222222222222222222222555555
55114411552111125555111222222222211111444411111111111111111222111144444111444441114445551111111411112222222222222222222222555555
11142221511111125111111222222222211111444411111111111111111222111144444111444441114445551111111411112222222222222222222222555555
11142221111121111111112222522251211111444411111111111111111111111144444111444441114445551111111411112222222222222222222222555555
11142221111121111111122225522551211441422411111111111111111111111122211111144421114445551111111411112211222222255225522222555555
11142221111121111111122225522551111444222211111111111111111111111122211111111221111112221111111111111111122222255555522552551155
11142221111151111111122525522551111444222211111111111111111111111122211111111221111112221111111111111111122222255555555555111111
11142221111151111111122525552511111444222211111111111111111111111122211111111221111112221111111111111111122222255555555555111111
11142221111151111111122555555111111224222211111111111111111111111122211111111221111112221111111111111111122222255555555555111111
11142221111151111422122555555111111222222211111111111111111111111122211111111221111112221111111111221111122222255555555555111111
11122221111111144422121255555111111222222211111111111111111111111122211111111221111112221111111122221111122112211555555555111111
11122222111111144422111255515114111222222211111121111111111111111122211111111221111112221111111122221111111111111551155115111111
11122222111114444422111225511114111112252211111122111111111111111122211111111221111112221111111122221111111111111111111115111111
11122222111114444222111225511114411111552211111222111111111111111111111111111221111112221111111122221111111111111111111111111111
11122222111114422222111125111114411111552211111222111111111111111111111111111111111112221111111122221111111111111111111111111111
11122222111114422222211111111142411111552211111212111111111111111111111111111111111111121111111122551111111111111111111111111111
11122222111112222222211111111442412111552211122211111111111111111111111111111111111111111111111155551111111111111111111111111111
11122222111112222222211111111442222111511211122111111111111111111111111111111111111111111111111155551111111111111111111111111111
11111112111112222222211111111442222111111111122111111111111111111111111111111111111111111111111155551111111111111111111111111111
11111111111111122222211111111422222111111111122111111111111111111111111111111111111111111111111155551111111111111111111111111111
111111111111111221112111111112222222211111111111111111111111aaaa1111111111111111111111111111111155551111111111111111111111111111
11111111111111111111211111111222222221111111111111111111119999444444441111111111111111111111111155111111111111111111111111111111
11111111111111111111111111111222222222111111111111111111aaaa44444444444422221111111111111111111111111111111441111111111111111111
11111111113111bbbb11111111111111112222111111111111111199999999444444442222222244441111111111111111111111144441144111111111111111
31511111111111113333555511111111222255551111111111112222555544449999444444444444222211111111111111111111144444444114211221111111
11111111111111111133331111555511111111111111111111aaaa99992222444444442222444422221111222255551111111111144444444444222221111111
11113333333311111111111111113333bbbbbbbbbbbb111199994444444444442222222255554444111111115555444411111111144444444444222222111111
11333311115555111155551111111111113333bbbbbbbb1111111144449999444422224444444422221111111122221111111111144444444444222222111111
33331111555511111111111111113333111133333333111111111111444444442222222244442222111122225555111111111144144444444444222222111111
11111111115555111111111111333333331111555533331111111111111111222244444444222211112222444444441111114444144224422444222222111111
11111111555511111111555511111111111155551111111111111111111111111111444422221111111122224444222211114444422222222442222222111111
11333311111111111155551111111111111111111111113333555511111111111111112222111111112222222211112222114444422222222222222222111111
33331111333333331111111133331111111111111111333333331111111111111111111111111111222244441111111111114444422222222222222222112211
11111155553333111111111111bbbbbbbb1111111111111111bbbbbbbb1111111111111111111122222222111111111111114444422222222222222222222222
bbbb555511111111111111111111bbbb33331111555511111111bbbbbbbb11115555111111111111111122222222111111114422422222222222222222222222
11bbbb11111111111111111111111133333333555533331111111111113333333311115555111111111111111111111111112222422222222222222222222222
bbbb3333111155551111111111111111111111111111111111111111111133331111111155551111111111111111111111112222222222222222222222222222
11333311111111111133331111111111111111111111111111111111111111111111115555333333333333333311111111112222222222222222222222222222
3333111111111111333333331111111111111111111133331111111133331111111111111111333333333333bbbb111111112222222222222222222222222222
1111111111111111113333bbbb11115555111111113333333311111111333311115555111111113333bbbb3333bbbbbbbb111122222222222222222222222222
11111111111111111111bbbbbbbb55551111111133331111111111113333111155555555111111111111bbbb3333bbbbbbbb1111222222222222222222222222
1111111111111111111111bbbbbbbb11111111111111111111111155551111111111111111111111111111333333333333bbbb11112222222222222222222222
111111111111333311111111bbbbbbbbbbbb11113333111111115555111111111111111111111111111111111111333333331111111111112222222222222222
11333355553333333311111111bbbbbbbb3333333333331111111111111111111111111111111133333333111111113333333333331111111122222222222222
3333555511113333111111111111bbbb333333333333111111111111555511111111111111111111333333331111111155553333333311111111111122222222
11555511111111111111111111111111113333333311111111111155551111111111115555111111113333333311115555111133331111111111111111555522
11111111111111111111111111111111111133331111111111111111555511111111111155551111111111111111111155551111111111111111111111111111
11111111111111555511111111111111111111111111113333111111111111111111115555111111111111111111111111111111111111111111115555111111
11111111111155555555111133331111111111111111333333331111111111111111111155551111333311111111111111111111111111113333555555551111
11111111115555555511113333333311111111111133333333333311111111333311111111111133333333111111111111111111111111333333335555111111
111111111111555511111111333311111111111111113333333311111111333333331111111111113333bbbb1111111111111111111111113333333333331111
11111111111111111111111111111111115555111111113333333311113333333333331111111111113333bbbbbbbb1111111111111111111133333333bbbb11
333311111111333311111111111111115555111111111111111111115555333333333333111111111111bbbbbbbbbbbb1111111111111111111111113333bbbb
11333311113333333311111111111155555555111111111111bbbb11115555111133331111111111111111bbbbbbbbbbbb111111111111111111111111bbbbbb
333333333333333333331111111111115555111155551111bbbbbbbb555555551111111111111111111111111111bbbb3333333311115555555511111111bbbb
113333bbbb333333333333111111111111111111115555bbbbbbbbbbbb5555111111111111111111111111111111113333333333331111555555551111111111
__map__
64646464646464646464646464646464646666646464646464646464646464640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c2
6464646464646464616161616161616161616166646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464616161616060676767616166646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464616161616161606067616166646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464616161616161606067616166666464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464606063616161616161606067616160606664646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464606064616161616060676767616160606066666464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464606064616161616161616161616166606060666464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464606064646464646464646464666664666060606664646460606064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646060606060646762626262626262626764616262626161616463646364000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6460646067606760646262626262626262626264616262616161616460646064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6460636060606060646262616161616262626264616262626261616460646064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6460646060606060646262616161616262626264616162626261616460646064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646060606060646262616161616262626264616161616262616460646064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646067606760646262626262626262626264616161626262616463646364000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646060606060646762626262626262626764616262626161616460606064000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646460606064646464646464636464646464646364646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464606064646460676067606464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646060646460676067606464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646460606360606060606464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646460606060606464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646364646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464606060646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464606060646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
6464646464646464646464646464646464646464646464646464646464646464000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment