stefvdw [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=33069 my first bezier(an eazy curve function) <p> <table><tr><td> <a href="/bbs/?pid=65926#p"> <img src="/bbs/thumbs/pico8_bezzy-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=65926#p"> bezzy</a><br><br> by <a href="/bbs/?uid=33069"> stefvdw</a> <br><br><br> <a href="/bbs/?pid=65926#p"> [Click to Play]</a> </td></tr></table> <br /> Hi guys,</p> <p>I was working on a train game when it hit me that i have no idea how to make a smooth curve.<br /> So I came across bezier curves and after reading some math articles I managed to write a function myself.<br /> Even though many other people have shared thier version here is my bezier curve, with only a single control point sadly (I will figure out the rest later). </p> <p>Here is the code i have tried to make it very eazy to implement into other projects (since I was gonna use it for my train haha).</p> <hr /> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function lv(v1,v2,t) return (1-t)*v1+t*v2 end --Quadratic Bezier Curve Vector function qbcvector(v1,v2,v3,t) return lv(lv(v1,v3,t), lv(v3,v2,t),t) end --draw Quadratic Bezier Curve --x1,y1 = starting point --x2,y2 = end point --x3,y3 = 3rd manipulating point --n = &quot;amount of pixels in curve&quot;(just put it higher than you expect) --c = color function drawqbc(x1,y1,x2,y2,x3,y3,n,c) for i = 1,n do local t = i/n pset(qbcvector(x1,x2,x3,t),qbcvector(y1,y2,y3,t),c) end end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <hr /> <p> <table><tr><td> <a href="/bbs/?pid=65926#p"> <img src="/bbs/thumbs/pico8_bezzy_cubic-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=65926#p"> bezzy_cubic</a><br><br> by <a href="/bbs/?uid=33069"> stefvdw</a> <br><br><br> <a href="/bbs/?pid=65926#p"> [Click to Play]</a> </td></tr></table> </p> <p>update: ive added cubic aswell here is the code:</p> <div> <div class=scrollable_with_touch style="width:100%; max-width:800px; overflow:auto; margin-bottom:12px"> <table style="width:100%" cellspacing=0 cellpadding=0> <tr><td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> <td background=/gfx/code_bg0.png> <div style="font-family : courier; color: #000000; display:absolute; padding-left:10px; padding-top:4px; padding-bottom:4px; "> <pre>function lv(v1,v2,t) return (1-t)*v1+t*v2 end --Quadratic Bezier Curve Vector function qbcvector(v1,v2,v3,t) return lv(lv(v1,v3,t), lv(v3,v2,t),t) end -- cubic bezier curve vector function cbcvector(v1,v2,v3,v4,t) return lv(qbcvector(v1,v2,v3,t), qbcvector(v1,v2,v4,t),t) end --draw cubic bezier curve function drawcbc(x1,y1,x2,y2,x3,y3,x4,y4,n,c) for i = 1,n do local t = i/n pset(cbcvector(x1,x2,x3,x4,t),cbcvector(y1,y2,y3,y4,t),c) end end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> https://www.lexaloffle.com/bbs/?tid=34770 https://www.lexaloffle.com/bbs/?tid=34770 Thu, 18 Jul 2019 20:21:03 UTC boaty (sailing test) <p> <table><tr><td> <a href="/bbs/?pid=65326#p"> <img src="/bbs/thumbs/pico8_boaty-2.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=65326#p"> boaty (sailing test)</a><br><br> by <a href="/bbs/?uid=33069"> stefvdw</a> <br><br><br> <a href="/bbs/?pid=65326#p"> [Click to Play]</a> </td></tr></table> <br /> Hi, I wanted to make a pirate game and I thought it would be cool if there were actual sailing mechanics.<br /> So I decided that I would start with that.<br /> I'm quite happy with the results so far but would no like to add land, birds and also make a bigger ship with some cannons or something.But i think the basics are here. </p> <p>--controls<br /> left and right - sailing<br /> Z - sail up or down</p> <p>If you have any suggestions feel free to give them.</p> https://www.lexaloffle.com/bbs/?tid=34560 https://www.lexaloffle.com/bbs/?tid=34560 Fri, 21 Jun 2019 16:26:19 UTC SpaceRace <p> <table><tr><td> <a href="/bbs/?pid=61474#p"> <img src="/bbs/thumbs/pico8_space_race-3.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=61474#p"> space_race</a><br><br> by <a href="/bbs/?uid=33069"> stefvdw</a> <br><br><br> <a href="/bbs/?pid=61474#p"> [Click to Play]</a> </td></tr></table> </p> <p>its gonna be a race</p> <p>update:I added more sattelites and a cow (very productive I know).<br /> Still thinking about the gameplay, I think I am going to make them be able to bump into eachother and collide with astroids and maybe sattelites aswell. and when they eventually get to the moon. maybe do a moonlander mini-game or something. </p> https://www.lexaloffle.com/bbs/?tid=33132 https://www.lexaloffle.com/bbs/?tid=33132 Sun, 03 Feb 2019 00:35:10 UTC