drawing overhaul

This commit is contained in:
James Turk 2023-05-06 17:35:40 -05:00
parent a10945a215
commit d368be4d7c

View File

@ -58,41 +58,61 @@ end
function start_level()
walls = {}
walls[30]={{0,10}, {25,30}, {38,44}}
walls[40]={{5,15}, {20,25}, {40,50}}
walls[50]={{5,10}, {20,30}, {45,55}}
walls[60]={{5,15}, {20,25}, {40,50}}
walls[70]={{0,10}, {20,30}, {44,55}}
walls[80]={{5,15}, {20,25}, {40,50}}
walls[90]={{0,10}, {25,30}, {38,44}}
the_line = 64
spr_frame = 1
opp_frame = 1
floor = 0
jump_time = 0
end
function draw_side(right)
function draw_platforms()
for y, platforms in pairs(walls) do
for plat in all(platforms) do
if right then
line(128-plat[1], y, 128-plat[2], y, DARK)
else
if plat[2] < the_line then
line(plat[1], y, plat[2], y, LIGHT)
elseif plat[1] > the_line then
line(plat[1], y, plat[2], y, DARK)
else
line(plat[1], y, the_line, y, LIGHT)
line(the_line, y, plat[2], y, DARK)
end
end
end
end
function collide_platforms()
local left = the_line - 6
local right = the_line + 6
for y, platforms in pairs(walls) do
for plat in all(platforms) do
-- check if there's a platform at this level
if floor > y and floor - y < 8 then
-- check if either edge of player+opp is between edges
if (left > plat[1] and left < plat[2]) or (right > plat[1] and right < plat[2]) then
printh("xcol "..(the_line-6).." "..plat[1].."-"..plat[2])
crush_line = y
end
end
end
end
end
function draw_player()
spr(spr_frame, the_line-8, 120-floor, 1, 1, false)
pal({[LIGHT]=DARK})
spr(opp_frame, the_line, 120-floor, 1, 1, true)
pal()
end
function draw_level()
-- left side
cls(0)
draw_side(false)
spr(spr_frame, the_line-8, 120-floor, 1, 1, false)
rectfill(the_line, 0, 128, 128, LIGHT)
-- right side
draw_side(true)
pal({[LIGHT]=DARK})
spr(spr_frame, the_line, 120-floor, 1, 1, true)
pal()
rectfill(the_line, -128, 128, 128, LIGHT)
draw_platforms()
draw_player()
-- floor
rectfill(0, 128-floor, the_line, 129-floor, LIGHT)
rectfill(the_line, 128-floor, 128, 129-floor, DARK)
@ -101,14 +121,18 @@ function draw_level()
fillp(0b0111101111011110)
rectfill(the_line, 130-floor, 128, 128, LIGHT)
fillp()
if floor > 120 then
camera(0, -(floor-120)*16)
if floor > 128 then
floor = 0
camera(0, 0)
end
end
end
function update_level()
spr_frame += .1
if spr_frame >= 4 then
spr_frame = 1
end
floor += 0.2
floor += floor_speed
-- No button pressed: <
-- Right button pressed: |
@ -121,13 +145,34 @@ function update_level()
end
if btn(1) then
dx += 0.25
if t() - jump_time < 1 then
if t() - jump_time < 0.5 then
dx += 0.25
end
end
the_line += dx
-- collision
collide_platforms()
-- player frames:
-- still: 1
-- walking: 1, 2
-- back slide: 3, 4
-- cramped: 5
local mod = (t()*4) % 2
if dx == 0 then
spr_frame = 3
opp_frame = 3
elseif dx < 0 then
spr_frame = 4
opp_frame = 1 + mod
else
spr_frame = 1 + (t() % 2)
opp_frame = 3
end
end
floor_speed = 0.4
LIGHT = 6
DARK = 0
_scenes.title = {start=nil, draw=draw_title, update=update_title}
@ -136,11 +181,11 @@ _scenes.level = {start=start_level, draw=draw_level, update=update_level}
__gfx__
00000000000060000000600000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000666000006660000066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000060060000600600006006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000666660006666600066666000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000666000006660000066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000666000006660000066600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000606000006060000060600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000600600006060000600600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000060000000600000006000000060000000600000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000666000006660000066600000666000006660000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000060060000600600006006000060060600600600000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000666660006666600066666000666660666666600000000000000000000000000000000000000000000000000000000000000000000000000000000
00077000000666000006660000066600000666000006660000000000000000000000000000000000000000000000000000000000000000000000000000000000
00700700000666000006660000066600000666000006660000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000606000006060000060600000606000006060000000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000606000006006000600600006000600060006000000000000000000000000000000000000000000000000000000000000000000000000000000000