alexthescott.bad fidget alt

-- bad fidget alt
-- alexthescott
-- 9/10/21

p={143,142,133,13,141,130,140,131,129}
pal(p,1)

function new_cluster(a,col,row,state)
	c={}
	c.state=state
	-- row x pos
	c.row=row
	--timer
	c.t=0
	c.a=a
	c.c=col
	-- rotate radius
	c.r=44
	c.a_x=64+cos(c.a)*c.r
	c.a_y=64+sin(c.a)*c.r
	--point size
	c.ps=10
	c.p1={}
	c.p1.a=0
	c.p1.x=c.a_x+cos(c.p1.a)*c.ps
	c.p1.y=c.a_y+sin(c.p1.a)*c.ps
	c.p1.xg=c.a_x+cos(c.p1.a)*c.ps
	c.p1.yg=c.a_y+sin(c.p1.a)*c.ps
	c.p2={}
	c.p2.a=1/3
	c.p2.x=c.a_x+cos(c.p2.a)*c.ps
	c.p2.y=c.a_y+sin(c.p2.a)*c.ps
	c.p2.xg=c.a_x+cos(c.p2.a)*c.ps
	c.p2.yg=c.a_y+sin(c.p2.a)*c.ps
	c.p3={}
	c.p3.a=2/3
	c.p3.x=c.a_x+cos(c.p3.a)*c.ps
	c.p3.y=c.a_y+sin(c.p3.a)*c.ps
	c.p3.xg=c.a_x+cos(c.p3.a)*c.ps
	c.p3.yg=c.a_y+sin(c.p3.a)*c.ps
	
	c.draw=function(self)
		p1=self.p1
		p2=self.p2
		p3=self.p3
		circfill(p1.x,p1.y,6,0)
		circfill(p2.x,p2.y,6,0)
		circfill(p3.x,p3.y,6,0)
		circfill(p1.x,p1.y,5,self.c)
		circfill(p2.x,p2.y,5,self.c)
		circfill(p3.x,p3.y,5,self.c)
	end
	
	c.update=function(self)
		if self.state=='rotate' then
			-- floor self.a
			-- floor self.p1.a & others
			self.a+=0.001
			
			if self.a>=1 then
				self.a=0
			end
			
			self.a_x=64+cos(self.a)*self.r
			self.a_y=64+sin(self.a)*self.r
			
			self.p1.a+=0.003
			self.p2.a+=0.003
			self.p3.a+=0.003
			
			if self.p1.a==0 then
				self.p1.a=0
			end
			if self.p2.a==0 then
				self.p2.a=0
			end
			if self.p3.a==0 then
				self.p3.a=0
			end
			
			self.p1.xg=self.a_x+cos(self.p1.a)*self.ps
			self.p1.yg=self.a_y+sin(self.p1.a)*self.ps
		
			p1_xd=(self.p1.xg-self.p1.x)/20
			p1_yd=(self.p1.yg-self.p1.y)/20
			self.p1.x+=p1_xd
			self.p1.y+=p1_yd
		
			self.p2.xg=self.a_x+cos(self.p2.a)*self.ps
			self.p2.yg=self.a_y+sin(self.p2.a)*self.ps
			
			p2_xd=(self.p2.xg-self.p2.x)/20
			p2_yd=(self.p2.yg-self.p2.y)/20
			self.p2.x+=p2_xd
			self.p2.y+=p2_yd
			
			self.p3.xg=self.a_x+cos(self.p3.a)*self.ps
			self.p3.yg=self.a_y+sin(self.p3.a)*self.ps
		
			p3_xd=(self.p3.xg-self.p3.x)/20
			p3_yd=(self.p3.yg-self.p3.y)/20
			self.p3.x+=p3_xd
			self.p3.y+=p3_yd
		else
			self.p1.xg=self.row
			self.p1.yg=32
			
			p1_xd=(self.p1.xg-self.p1.x)/10
			p1_yd=(self.p1.yg-self.p1.y)/10
			p1.x+=p1_xd
			p1.y+=p1_yd
			
			self.p2.xg=self.row
			self.p2.yg=64
			
			p2_xd=(self.p2.xg-self.p2.x)/10
			p2_yd=(self.p2.yg-self.p2.y)/10
			p2.x+=p2_xd
			p2.y+=p2_yd
			
			self.p3.xg=self.row
			self.p3.yg=96
			
			p3_xd=(self.p3.xg-self.p3.x)/10
			p3_yd=(self.p3.yg-self.p3.y)/10
			p3.x+=p3_xd
			p3.y+=p3_yd
		end
		
		self.t+=1
		
		if self.t==1200 then
			if self.state=='rotate' then
				self.row+=32
				if self.row>96 then
					self.row=32
				end
				self.state='grid'
			else
				self.state='rotate'
			end
			self.t=0
		end
	end
	
	c.debug=function(self)
		print(c.a_x,0,0,7)
		print(c.a_y,0,6,7)
	end
	
	add(clusters,c)
end

function burn()
	for i=1,600 do

		x=(rnd(64)\1)*2
		y=(rnd(64)\1)*2
		x=rnd(128)\1
		y=rnd(128)\1
		pc=pget(x,y)
		if pc%3!=0 then
			if rnd(3)\1==0 then
				nc=rnd(2)\1
				circfill(x,y,2,pc+1)
				circfill(x,y-2,2,pc+nc)
				circfill(x,y+2,2,pc+nc)
				circfill(x-2,y,2,pc+nc)
				circfill(x+2,y,2,pc+nc)
				
				if nc==1 then
					circ(x,y+1,2,pc+nc)
					circ(x,y-1,2,pc+nc)
					circ(x,y+3,2,pc+nc)
					circ(x,y-3,2,pc+nc)
				end
			end
		else
			circfill(x,y,1,0)
		end
	end
end

screen_wipe={}
clusters={}
fc=0

if rnd(2)\1==0 then
	state='rotate'
else
	state='grid'
end
new_cluster(0,1,32,state)
new_cluster(1/3,4,64,state)
new_cluster(2/3,7,96,state)

_set_fps(60)
cls()
::♥::
if t()<2 then
	print("bad fidget alt",36,64,4)
else
	burn()
	
	fc+=1
	if fc==1000 then
		fc=0
	end
	
	for clr in all(screen_wipe) do
		clr:draw()
		clr:update()
		clr:destroy()
	end
	
	for c in all(clusters) do
		c:draw()
		c:update()
	end
end
flip()
goto ♥