known_stars={}
num=128
px=63
py=9
pal({-15,1,-13,-4,12},1)
cx=0
cy=0
cam_v_x=0
cam_v_y=0
p_v_x=0
p_v_y=0
mx=0
my=0
_srand,_circfill,_rnd=srand,circfill,rnd
::_::
--dale's four direction control handler
_btn=btn()
p_v_x+=(_btn\2%2-_btn%2)/4
p_v_y+=(_btn\8%2-_btn\4%2)/4
--[[
create a seed from time so
the background works
]]--
_srand(t())
--[[
magic part:
draw a circ at a random position with a reduced color of that pixel 400 times
clears the screen but creates a nice fade
]]--
for i=0,400do
rx=_rnd(num)
ry=_rnd(num)
circ(rx,ry,1,abs(pget(rx,ry)-1))
end
--camera velocity update
camera(cx,cy)
cx*=.8
cy*=.8
--randomness is set to the system seed
_srand(r)
--draw a bunch of dots as background stars
for i=0,99do
rx=_rnd(num)
ry=_rnd(num)
_circfill(rx,ry,0,5)
end
--[[
star system generation:
-pick between 1 and 9 bodies
-give each a random angle from the center
-draw them
-add their distance+size+rnd to the distance of the next body
]]--
l=0
for i=0,_rnd(9)do
a=_rnd()+t()/i/9
f=i<1and _rnd(5)+5or _rnd(i)
_circfill(l*cos(a)+63,l*sin(a)+63-i,f,7)
l+=f+_rnd(9)+4
end
--add player velocity to their pos
px+=p_v_x
py+=p_v_y
--when player goes off screen add a camera offset and change their system coridinate
if(px<0or px>num)mx+=sgn(p_v_x)cx=num*-p_v_x
if(py<0or py>num)my+=sgn(p_v_y)cy=num*-p_v_y
?(#known_stars/4^7*100).."% "..mx.." "..my,2,2
--generates unique seed for 128x128 star systems
r=mx+num*my
--loop the player around the screen
px%=num
py%=num
--draw player and reduce their velocity
_circfill(px,py,1)
p_v_x*=.9
p_v_y*=.9
flip()
--check if current star is known.
--if it finds it, skips to the start of the loop
--if not add it to the list.
for i=1,#known_stars do
if(known_stars[i]==r)goto _
end
add(known_stars,r)goto _
*edit* also should mention still tweaking the code. this version differs from the one in html/desc rn
← Return to game
Comments
Log in with itch.io to leave a comment.
This is amazing, and kind-of hypnotically beautiful!!!
Cool star system generation! I've got a lot of percents left to go...
Great lord! This is a good looking game.
Do you have a non-minimized version of the p8 to share for learning purposes?
not before you asked!
known_stars={} num=128 px=63 py=9 pal({-15,1,-13,-4,12},1) cx=0 cy=0 cam_v_x=0 cam_v_y=0 p_v_x=0 p_v_y=0 mx=0 my=0 _srand,_circfill,_rnd=srand,circfill,rnd ::_:: --dale's four direction control handler _btn=btn() p_v_x+=(_btn\2%2-_btn%2)/4 p_v_y+=(_btn\8%2-_btn\4%2)/4 --[[ create a seed from time so the background works ]]-- _srand(t()) --[[ magic part: draw a circ at a random position with a reduced color of that pixel 400 times clears the screen but creates a nice fade ]]-- for i=0,400do rx=_rnd(num) ry=_rnd(num) circ(rx,ry,1,abs(pget(rx,ry)-1)) end --camera velocity update camera(cx,cy) cx*=.8 cy*=.8 --randomness is set to the system seed _srand(r) --draw a bunch of dots as background stars for i=0,99do rx=_rnd(num) ry=_rnd(num) _circfill(rx,ry,0,5) end --[[ star system generation: -pick between 1 and 9 bodies -give each a random angle from the center -draw them -add their distance+size+rnd to the distance of the next body ]]-- l=0 for i=0,_rnd(9)do a=_rnd()+t()/i/9 f=i<1and _rnd(5)+5or _rnd(i) _circfill(l*cos(a)+63,l*sin(a)+63-i,f,7) l+=f+_rnd(9)+4 end --add player velocity to their pos px+=p_v_x py+=p_v_y --when player goes off screen add a camera offset and change their system coridinate if(px<0or px>num)mx+=sgn(p_v_x)cx=num*-p_v_x if(py<0or py>num)my+=sgn(p_v_y)cy=num*-p_v_y ?(#known_stars/4^7*100).."% "..mx.." "..my,2,2 --generates unique seed for 128x128 star systems r=mx+num*my --loop the player around the screen px%=num py%=num --draw player and reduce their velocity _circfill(px,py,1) p_v_x*=.9 p_v_y*=.9 flip() --check if current star is known. --if it finds it, skips to the start of the loop --if not add it to the list. for i=1,#known_stars do if(known_stars[i]==r)goto _ end add(known_stars,r)goto _*edit* also should mention still tweaking the code. this version differs from the one in html/desc rn
Awesome. Thanks!