Log In  


Is there a wise, benevolent soul out there willing to explain to my feeble mind why this alpha effect doesn't seem to work with a scrolling camera? I can't seem to anchor the light circle to the center of my player character.

function _init()
	px,py=64,64
end

function _draw()
	cls()
	map()
	camera(cx,cy)
	draw_light() --draw alpha effect
	print("🐱",px,py) --player
end

function _update()
	if (btn(0)) px-=1
	if (btn(1)) px+=1
	if (btn(2)) py-=1
	if (btn(3)) py+=1

	cx=px-64 --cam
	cy=py-64
end

Here is the draw function for the alpha effect:

function draw_light()
	poke(0x5f54,0x60) 
	pal({2}) 
	--draw a circle
	for i=-24,24 do 
		x=sqrt(24*24-i*i)
		sspr(px-x,py+i, x*2,1, 
		    (px-x)+cx,(py+cy)+i)
	end

	poke(0x5f54,0x00)
	pal() 
end


Nevermind, I seem to have fixed it by subtracting the camera values from the first two sspr parameters:

for i=-24,24 do 
		x=sqrt(24*24-i*i)
		sspr(px-x-cx,py+i-cy,  x*2,1,  px-x,py+i, x*2,1)--dest
end

1

You're setting the camera after you draw the map, and never resetting it, so the map will be drawn wrong the first frame... You might want to reset the camera at the end and set it before you draw the map.



[Please log in to post a comment]