Fixed Cam, consider clipping map to always show sky
This commit is contained in:
parent
0282c21b18
commit
d0ed65a75b
41
continuum.p8
41
continuum.p8
@ -63,8 +63,8 @@ function _init()
|
||||
confirm_trigger=false
|
||||
cancel_trigger=false
|
||||
|
||||
camx=0
|
||||
camy=0
|
||||
cam_x=0
|
||||
cam_y=0
|
||||
end
|
||||
--<<<=====update======>>>
|
||||
function _update()
|
||||
@ -118,11 +118,11 @@ function _draw()
|
||||
--center camera on player
|
||||
camera_follow()
|
||||
--do the shaking
|
||||
doshake()
|
||||
-- doshake()
|
||||
--sky
|
||||
rectfill(0,5,64,17,skyclr2)
|
||||
rectfill(0,5,64,7,skyclr1)
|
||||
spr(sun.sprt,sun.x,sun.y)
|
||||
rectfill(cam_x,cam_y+5,cam_x+64,cam_y+17,skyclr2)
|
||||
rectfill(cam_x,cam_y+5,cam_x+64,cam_y+7,skyclr1)
|
||||
spr(sun.sprt,sun.x+cam_x,sun.y+cam_y)
|
||||
--map
|
||||
rectfill(0,17,64,64,4)
|
||||
map(0,0,0,12,33,18)
|
||||
@ -199,15 +199,15 @@ function _draw()
|
||||
--draw rain
|
||||
if(israining) then _draw_rain() end
|
||||
--menu
|
||||
rectfill(0,0,64,5,0)
|
||||
spr(48,0,0)
|
||||
line(5,2,14,2,10)
|
||||
spr(49,16,0)
|
||||
line(21,2,30,2,8)
|
||||
spr(50,32,0)
|
||||
line(37,2,46,2,12)
|
||||
print(camx,48,0,10)
|
||||
print(camy,56,0,11)
|
||||
rectfill(cam_x,cam_y,cam_x+64,cam_y+5,1)
|
||||
spr(48,0+cam_x,0+cam_y)
|
||||
line(5+cam_x,2+cam_y,14+cam_x,2+cam_y,10)
|
||||
spr(49,16+cam_x,0+cam_y)
|
||||
line(21+cam_x,2+cam_y,30+cam_x,2+cam_y,8)
|
||||
spr(50,32+cam_x,0+cam_y)
|
||||
line(37+cam_x,2+cam_y,46+cam_x,2+cam_y,12)
|
||||
-- print(camx,48+cam_x,cam_y,10)
|
||||
-- print(camy,56+cam_x,cam_y,11)
|
||||
end
|
||||
|
||||
function doshake()
|
||||
@ -236,7 +236,7 @@ end
|
||||
-- 2,1,3,0 Up,Right,Down,Left
|
||||
function _build(button)
|
||||
--israining=true
|
||||
print(tostring(button),0,16,10)
|
||||
-- print(tostring(button),0,16,10)
|
||||
--energy
|
||||
--battery
|
||||
--house
|
||||
@ -369,6 +369,7 @@ function camera_follow()
|
||||
--of the screen, we need to
|
||||
--set the camera's x,y to the
|
||||
--player's x,y minus 60.
|
||||
|
||||
cam_x=p.x-28
|
||||
cam_y=p.y-28
|
||||
|
||||
@ -381,8 +382,12 @@ function camera_follow()
|
||||
--position can't move past
|
||||
--coordinates that would show
|
||||
--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
|
||||
camera(cam_x,cam_y)
|
||||
|
Loading…
Reference in New Issue
Block a user