Davi_dash [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=67531 collision <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 box(_x,_y,_w,_h) return{ x=_x, y=_y, w=_w, h=_h } end function get_cols(a) local gx,gy=flr(a.x/8),flr(a.y/8) local ex,ey=flr((a.x+a.w-1)/8),flr((a.y+a.h-1)/8) local list={} for i=gx-1,ex+1 do for ii=gy-1,ey+1 do if fget(mget(i,ii),0) then add(list,box(i*8,ii*8,8,8)) end end end return list end function collide(a,_dx,_dy,list,side) local ca={ x=flr(a.x), y=flr(a.y), w=a.w, h=a.h } for i=1,#list do local v=list[i] if col(v,ca) then if _dx&gt;0 then a.x=v.x-a.w side[&quot;right&quot;]=true elseif _dx&lt;0 then a.x=v.x+v.w side[&quot;left&quot;]=true end if _dy&gt;0 then a.y=v.y-a.h side[&quot;down&quot;]=true elseif _dy&lt;0 then a.y=v.y+v.h side[&quot;up&quot;]=true end end end end --diss code expects that &quot;a&quot; have a --dx and dy function move(a) local sides={ [&quot;left&quot;]=false, [&quot;right&quot;]=false, [&quot;up&quot;]=false, [&quot;down&quot;]=false } local l=get_cols(a) a.x+=a.dx collide(a,a.dx,0,l,sides) a.y+=a.dy collide(a,0,a.dy,l,sides) if sides[&quot;up&quot;] or sides[&quot;down&quot;] then a.dy=0 end if sides[&quot;left&quot;] or sides[&quot;right&quot;] then a.dx=0 end return sides end function col(a,b) return not( (a.x&gt;b.x+b.w-1)or (b.x&gt;a.x+a.w-1)or (a.y&gt;b.y+b.h-1)or (b.y&gt;a.y+a.h-1) ) end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>this is the code that i use for collisions with the map<br /> is not perfect but <strong>it works</strong> </p> <p>hehe</p> <p>the code is based in the pygame way of doing collisions<br /> probably not the best way of doing collisions in pico-8 </p> <p>but it works for me atleast</p> <p>the way to use this, is to just call the move function<br /> in a table that have dx and dy </p> <p>dx=&quot;direction in the x-axis&quot;<br /> dy=&quot;direction in the y-axis&quot;</p> <p>and update dx and dy </p> <p>i not a pico-8 expert so, i probably using a lot of tokens</p> https://www.lexaloffle.com/bbs/?tid=140315 https://www.lexaloffle.com/bbs/?tid=140315 Fri, 23 Feb 2024 18:27:16 UTC star_addicted_full <p> <table><tr><td> <a href="/bbs/?pid=137894#p"> <img src="/bbs/thumbs/pico8_star_addicted_full-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=137894#p"> star_addicted_full</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=137894#p"> [Click to Play]</a> </td></tr></table> </p> <h1>star_addicted</h1> <h2>star addicted is fast passed 2d platformer</h2> <p>you collect star to calm you down, you have a dash abilitty to go faster.<br /> you can also get a keys over time to travel faster using doors </p> <p>have fun.</p> https://www.lexaloffle.com/bbs/?tid=55135 https://www.lexaloffle.com/bbs/?tid=55135 Sat, 25 Nov 2023 21:58:18 UTC raymaster <p> <table><tr><td> <a href="/bbs/?pid=137790#p"> <img src="/bbs/thumbs/pico8_raymaster-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=137790#p"> raymaster</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=137790#p"> [Click to Play]</a> </td></tr></table> </p> <h1>Casting a ray</h1> <p>a basic line_cast algorithm</p> https://www.lexaloffle.com/bbs/?tid=55119 https://www.lexaloffle.com/bbs/?tid=55119 Wed, 22 Nov 2023 21:11:28 UTC proximity_line_VFX <p> <table><tr><td> <a href="/bbs/?pid=133898#p"> <img src="/bbs/thumbs/pico8_hohpojido-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=133898#p"> hohpojido</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=133898#p"> [Click to Play]</a> </td></tr></table> <br /> i dont know i just like to do some cool Visual carts, i guess... enjoy</p> https://www.lexaloffle.com/bbs/?tid=53980 https://www.lexaloffle.com/bbs/?tid=53980 Sun, 03 Sep 2023 20:53:23 UTC birthdayyay <p> <table><tr><td> <a href="/bbs/?pid=133486#p"> <img src="/bbs/thumbs/pico8_birthdayyay-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=133486#p"> birthdayyay</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=133486#p"> [Click to Play]</a> </td></tr></table> <br /> its my birthday yay.</p> https://www.lexaloffle.com/bbs/?tid=53864 https://www.lexaloffle.com/bbs/?tid=53864 Thu, 24 Aug 2023 22:28:56 UTC cube_3d_demo <p> <table><tr><td> <a href="/bbs/?pid=131774#p"> <img src="/bbs/thumbs/pico8_sifepubaru-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=131774#p"> sifepubaru</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=131774#p"> [Click to Play]</a> </td></tr></table> </p> <h1>3d_thing</h1> <p>i been kinda busy , but still trying some game_dev_stuff, diss is a spining cube , using real 3d , i think is neat ,<br /> i been also making a game in godot , a fun engine , more updates in that later.</p> <h2>enjoy the funny 3d shape</h2> https://www.lexaloffle.com/bbs/?tid=53357 https://www.lexaloffle.com/bbs/?tid=53357 Sun, 09 Jul 2023 16:14:30 UTC cdcoolthing <p> <table><tr><td> <a href="/bbs/?pid=121432#p"> <img src="/bbs/thumbs/pico8_cdcoolthing-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=121432#p"> cdcoolthing</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=121432#p"> [Click to Play]</a> </td></tr></table> </p> <h1>third_person_camera</h1> <p>i want to make a 3d game in pico8, but i without time to spend in gamedev ,with the time i have left i doing some camera work , diss a tps style camera(i have to charge some variables to accommodate to the pico8 128x128 screen) , i hope you all can find a good use to it , i also want to thanks the help i got from freds72 (the guy who ported doom to pico8), and again i using sokpop sorce code as reference.</p> https://www.lexaloffle.com/bbs/?tid=50375 https://www.lexaloffle.com/bbs/?tid=50375 Sat, 26 Nov 2022 20:21:03 UTC 3d_menu_demo <p> <table><tr><td> <a href="/bbs/?pid=118278#p"> <img src="/bbs/thumbs/pico8_risodisosi-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=118278#p"> risodisosi</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=118278#p"> [Click to Play]</a> </td></tr></table> </p> <p>This is something a code a long time ago, is a basic 3d menu , the only time i saw a menu like diss was in sonic adveture, and i think a sony console had some menu like diss , but i not so sure , well i hope some one can find good use of diss. </p> https://www.lexaloffle.com/bbs/?tid=49568 https://www.lexaloffle.com/bbs/?tid=49568 Sat, 01 Oct 2022 13:03:12 UTC Mouse_space <h1>mouse_in_world_space</h1> <p>How do you get the mouse x and y based on world space ?</p> https://www.lexaloffle.com/bbs/?tid=48566 https://www.lexaloffle.com/bbs/?tid=48566 Wed, 20 Jul 2022 12:41:33 UTC kindaLike <p> <table><tr><td> <a href="/bbs/?pid=114234#p"> <img src="/bbs/thumbs/pico8_jariputuda-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=114234#p"> kindaLike</a><br><br> by <a href="/bbs/?uid=67531"> Davi_dash</a> <br><br><br> <a href="/bbs/?pid=114234#p"> [Click to Play]</a> </td></tr></table> </p> <p>i saw that pico8 got a free version so i decide to make a small game</p> <p>i kinda new in to developing games ,and that why the game is so simple , or maybe is because pico8 token count said he hates me,<br /> who knows.</p> <p>about the game he is kinda_like a rougue like , he very inspired in the binding of issac, but simpler<br /> every door do something </p> <h1>yellow</h1> <p>is the item room </p> <h1>pink one</h1> <p>is a mystery can have enemies or good_stuff</p> <h1>the brown one</h1> <p>is just a enemy room</p> <p>the controls are the keybord keys and z and x<br /> z are shot<br /> x use card </p> <p>diss game is not that good , is very short and you can see that, is more like train to flex my programing skils that anything .<br /> btw the code is pretty bad , have fun :)</p> https://www.lexaloffle.com/bbs/?tid=48489 https://www.lexaloffle.com/bbs/?tid=48489 Tue, 12 Jul 2022 14:29:12 UTC