--[[
AutoGrapher V1.0
By 10$man
Special credit to w00tguy123

THIS PROGRAM IS FREE OF LICENSE
YOU MAY REDISTRIBUTE IT BUT GIVE
CREDIT WERE CREDIT IS DUE! (ME :P)
--]]
--Init Graphs
yv1 = {}
yv2 = {}
yv3 = {}
--load Color
red = Color.new(255,0,0)
green = Color.new(0,255,0)
blue = Color.new(0,0,255)
graph = Color.new(100,200,140)
graph2 = Color.new(50,100,100)
tracer = Color.new(250,250,0)
--Draw Tracer
trace = Image.createEmpty(4,4)
trace:clear(tracer)
boy = 1
box = 1
--OFFSETS (FOR TESTING PURPOSES)
xof = 103
yof = 135
--Loop
while true do
--Prepare loop
screen:clear()
pad = Controls.read()
oldpad = Controls.read()
for x = -136, 137 do




















	-----------------------------------GRAPHS GO HERE---------------------------------------------------
	y1=-x^3
	y2=-2000
	y3=-2000
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	


	yv1[x+137]=y1
	yv1[x+137]=yv1[x+137]*-1
	yv2[x+137]=y2
	yv2[x+137]=yv2[x+137]*-1
	yv3[x+137]=y3
	yv3[x+137]=yv3[x+137]*-1
end
--Draw the graph
for a = 1, 480/4 do
	screen:drawLine(a*4,0,a*4,272,graph2)
end
for a = 1, 272/4 do
	screen:drawLine(0,a*4,480,a*4,graph2)
end
screen:drawLine(480/2,0,480/2,272,graph)
screen:drawLine(0,272/2,480,272/2,graph)
--Draw the line initialized
for a = 1, 272 do
	screen:drawLine(a+xof,yv1[a]+yof,a+xof+1,yv1[a+1]+yof+1,green)
end
for a = 1, 272 do
	screen:drawLine(a+xof,yv2[a]+yof,a+xof+1,yv2[a+1]+yof+1,green)
end
for a = 1, 272 do
	screen:drawLine(a+xof,yv3[a]+yof,a+xof+1,yv3[a+1]+yof+1,red)
end
--Draw border (to hide line clips)
screen:drawLine(0,0,480,0,red)
screen:drawLine(0,272,480,272,red)
screen:drawLine(0,0,0,272,red)
screen:drawLine(480,0,480,272,red)
--Draw Tracer
if boy > 272 then
	boy = 1
end
if boy < 1 then
	boy = 272
end
if box > 272 then
	box = 1
end 
if box < 1 then
	box = 272
end
if pad:right() then
	box = box + 1
	boy = boy + 1
end
if pad:left() then
	box = box - 1
	boy = boy - 1
end
screen:blit(box+xof,yv1[boy]+yof,trace)
if pad:start() then
	dofile("./System/menu.lua")
	break;
end
--Credit and check done
screen:print(1,10,"Xoffset:" .. xof,red)
screen:print(1,20,"Yoffset:" .. yof,red)
screen:print(300,1,"batt." .. System.powerGetBatteryLifePercent() .. "%",red)
screen:print(1,262,"Current x:" .. box-136 .. " Current y:" .. yv1[boy]*-1, green)
screen:print(1,252,"Box x:" .. box .. " Boy:" .. boy,red)
screen:print(100,0,"By: 10$man",green)
--End loop
screen.flip()
screen.waitVblankStart()
end
