Fixed Cam, consider clipping map to always show sky

This commit is contained in:
Alan Youngblood 2022-08-11 23:06:58 -04:00
parent 0282c21b18
commit d0ed65a75b

View File

@ -63,8 +63,8 @@ function _init()
confirm_trigger=false confirm_trigger=false
cancel_trigger=false cancel_trigger=false
camx=0 cam_x=0
camy=0 cam_y=0
end end
--<<<=====update======>>> --<<<=====update======>>>
function _update() function _update()
@ -118,11 +118,11 @@ function _draw()
--center camera on player --center camera on player
camera_follow() camera_follow()
--do the shaking --do the shaking
doshake() -- doshake()
--sky --sky
rectfill(0,5,64,17,skyclr2) rectfill(cam_x,cam_y+5,cam_x+64,cam_y+17,skyclr2)
rectfill(0,5,64,7,skyclr1) rectfill(cam_x,cam_y+5,cam_x+64,cam_y+7,skyclr1)
spr(sun.sprt,sun.x,sun.y) spr(sun.sprt,sun.x+cam_x,sun.y+cam_y)
--map --map
rectfill(0,17,64,64,4) rectfill(0,17,64,64,4)
map(0,0,0,12,33,18) map(0,0,0,12,33,18)
@ -199,15 +199,15 @@ function _draw()
--draw rain --draw rain
if(israining) then _draw_rain() end if(israining) then _draw_rain() end
--menu --menu
rectfill(0,0,64,5,0) rectfill(cam_x,cam_y,cam_x+64,cam_y+5,1)
spr(48,0,0) spr(48,0+cam_x,0+cam_y)
line(5,2,14,2,10) line(5+cam_x,2+cam_y,14+cam_x,2+cam_y,10)
spr(49,16,0) spr(49,16+cam_x,0+cam_y)
line(21,2,30,2,8) line(21+cam_x,2+cam_y,30+cam_x,2+cam_y,8)
spr(50,32,0) spr(50,32+cam_x,0+cam_y)
line(37,2,46,2,12) line(37+cam_x,2+cam_y,46+cam_x,2+cam_y,12)
print(camx,48,0,10) -- print(camx,48+cam_x,cam_y,10)
print(camy,56,0,11) -- print(camy,56+cam_x,cam_y,11)
end end
function doshake() function doshake()
@ -236,7 +236,7 @@ end
-- 2,1,3,0 Up,Right,Down,Left -- 2,1,3,0 Up,Right,Down,Left
function _build(button) function _build(button)
--israining=true --israining=true
print(tostring(button),0,16,10) -- print(tostring(button),0,16,10)
--energy --energy
--battery --battery
--house --house
@ -369,6 +369,7 @@ function camera_follow()
--of the screen, we need to --of the screen, we need to
--set the camera's x,y to the --set the camera's x,y to the
--player's x,y minus 60. --player's x,y minus 60.
cam_x=p.x-28 cam_x=p.x-28
cam_y=p.y-28 cam_y=p.y-28
@ -381,8 +382,12 @@ function camera_follow()
--position can't move past --position can't move past
--coordinates that would show --coordinates that would show
--past the edge of the map. --past the edge of the map.
cam_x=mid(0,cam_x,896)
cam_y=mid(0,cam_y,128) cam_x=mid(0,cam_x,476)
cam_y=mid(0,cam_y,76)
--cam_x+=1
--cam_y+=1
--change the camera position --change the camera position
camera(cam_x,cam_y) camera(cam_x,cam_y)