Log In  
Follow
ThePoopLord

ello

I made a half working cart about bezier curves and wanted to see what people think about my code, so if you want to pls give feedback

note: you can add points by using the up and down arrow keys then move the points by using the mouse and cycle between them using X and O

--bezier curve time
function clone(t)--clone a table
	return{unpack(t)}
end

function lerp(s,e,m)
	return s*(1-m)+e*m
end

function lerp2d(p1,p2,t)--lerp
	lx=lerp(p1[1],p2[1],t)--two 2d
	ly=lerp(p1[2],p2[2],t)--points
	return lx,ly
end

poke(0x5f2d,1) --devkit mouse
p1={64,64} --first point
ptt={ p1} --point table
pts=0 --number of desired points
ind=1 --index used for selected point
t=.5 --time value used across lerps

function lerpcheck()--lerp the points
	po1=lerp2d(ptt[1],ptt[2],t)
	l=#ptt-2
	for i=0,#ptt-1,1 do
		if(ptt[i+2]~=nil)lx,ly=lerp2d(ptt[i+1],ptt[i+2],t) --lx stands for lerped x

[ [size=16][color=#ffaabb] [ Continue Reading.. ] [/color][/size] ](/bbs/?pid=116089#p)
2 comments