Log In  13  Some things that might be useful.

### Dark palette

Usage:
l: how strong the darkness effect should be

 ```dpal={0,1,1,2,1,13,6,2,4,9,3,13,5,2,9} function dark(l) l=l or 0 if l>0 then for i=0,15 do col=dpal[i] or 0 for a=1,l-0.5 do col=dpal[col] end pal(i,col) end end end``` ### Circle map

Usage:
x,y: coordinates to draw the map
r: radius of the map to draw

 ```function circmap(x,y,r) for y2=-r,r do x2=sqrt(abs(y2*y2-r*r)) tline(x-x2,y+y2,x+x2,y+y2,(x-x2)/8,(y+y2)/8) end end``` Can be used with dark palette to make a light:

 ```-- circle map function function circmap(x,y,r) for y2=-r,r do x2=sqrt(abs(y2*y2-r*r)) tline(x-x2,y+y2,x+x2,y+y2,(x-x2)/8,(y+y2)/8) end end -- function to darken the palette function dark(l) l=l or 0 if l>0 then for i=0,15 do col=dpal[i] or 0 for a=1,l-0.5 do col=dpal[col] end pal(i,col) end end end function _init() -- dark palette dpal={0,1,1,2,1,13,6,2,4,9,3,13,5,2,9} t=0 x=64 y=64 r=32 end function _update() -- circle position and size x=64+sin(t/100)*32 y=64+cos(t/100)*32 r=32+sin(t/50)*16 -- timer and loop t+=1 end function _draw() cls() -- darkens the palette 2 times dark(2) -- draws map map() -- resets palette pal() -- draws circmap circmap(x,y,r) end```  P#79480 2020-07-17 07:00 ( Edited 2020-12-01 08:11)

:: dredds  Awesome!

P#79487 2020-07-17 08:48
:: cubee  @dredds

Thanks!

P#79489 2020-07-17 11:56  @cubee this is fantastic! Could you add a code snippit example for the palette swapped circmap function gif?

P#84884 2020-12-01 01:56
:: cubee 1 @zerkdev

 ```-- circle map function function circmap(x,y,r) for y2=-r,r do x2=sqrt(abs(y2*y2-r*r)) tline(x-x2,y+y2,x+x2,y+y2,(x-x2)/8,(y+y2)/8) end end -- function to darken the palette function dark(l) l=l or 0 if l>0 then for i=0,15 do col=dpal[i] or 0 for a=1,l-0.5 do col=dpal[col] end pal(i,col) end end end function _init() -- dark palette dpal={0,1,1,2,1,13,6,2,4,9,3,13,5,2,9} t=0 x=64 y=64 r=32 end function _update() -- circle position and size x=64+sin(t/100)*32 y=64+cos(t/100)*32 r=32+sin(t/50)*16 -- timer and loop t+=1 end function _draw() cls() -- darkens the palette 2 times dark(2) -- draws map map() -- resets palette pal() -- draws circmap circmap(x,y,r) end```

P#84893 2020-12-01 08:10  Thank you!

P#84928 2020-12-02 02:01  @cubee Your circle map function is exactly what I need for a WIP game! Would it be OK if I used it, and if so, what is your preferred method of attribution?

P#85726 2020-12-24 03:16
:: cubee 1 @2bitchuck

yes. just leave a little note somewhere saying you used it

P#85752 2020-12-24 22:51  @cubee Thank you, I will. This saved me a ton of time!

P#85754 2020-12-24 23:56