Dad Jr. [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=48774 Tribute &amp; Game: Coffin Dance <p> <table><tr><td> <a href="/bbs/?pid=116355#p"> <img src="/bbs/thumbs/pico8_coffin_dance_tributengame-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=116355#p"> Tribute N Game: Coffin Dance</a><br><br> by <a href="/bbs/?uid=48774"> Dad Jr.</a> <br><br><br> <a href="/bbs/?pid=116355#p"> [Click to Play]</a> </td></tr></table> </p> <p>Howdy BBS community!</p> <p>As usual I'm indebted to the expertise of the users on here! This is my first complete game and I suspect it's barely held together code-wise. I'm super happy to get any feedback if you see something in the code that could be improved or makes your toes curl. </p> <p>This is Coffin Dance! Why are you dancing? Play to find out!</p> <p>Credits:<br /> &quot;Coffin Dance&quot; by AJJ<br /> Originally written by Ben Gallaty and Sean Bonnette<br /> Screen FX using routines by <a href="https://www.lexaloffle.com/bbs/?uid=49140">ZerkDev</a><br /> Art, arrangement, and dirty code by me, aka dreams.EGA, who you can find on Twitter and Instagram!</p> https://www.lexaloffle.com/bbs/?tid=49067 https://www.lexaloffle.com/bbs/?tid=49067 Sat, 27 Aug 2022 16:25:16 UTC Deciphering Advanced Micro Platformer Code <p>I'm at a loss trying to decipher some code to better my understanding of core principles. Using the fantastic Advanced Micro Platformer by <a href="https://www.lexaloffle.com/bbs/?uid=15406"> @mhughson</a> as a subject of study I was reading into how the engine detects horizontal collision for the player. It does this through a collide_side function</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 collide_side(self) local offset=self.w/3 for i=-(self.w/3),(self.w/3),2 do --if self.dx&gt;0 then if fget(mget((self.x+(offset))/8,(self.y+i)/8),0) then self.dx=0 self.x=(flr(((self.x+(offset))/8))*8)-(offset) return true end --elseif self.dx&lt;0 then if fget(mget((self.x-(offset))/8,(self.y+i)/8),0) then self.dx=0 self.x=(flr((self.x-(offset))/8)*8)+8+(offset) return true end -- end end --didn't hit a solid tile. return false 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>So I'm trying to make sense of this, and I can't seem to parse it in a way that makes sense. Breaking it down it assigns a local value offset to 2.66 roughly, because self.w is 8. And then it runs a for loop beginning at -2.66 through 2.66, with a &quot;stride&quot; of 2? So it counts up from -2.66 to 2.66 in increments of 2, and adds the current i to the y value? I assume this is checking for collision along the y axis of the sprite from top to bottom, but I cannot figure why it seems to check the y coord + -2.66, -.66, etc. So I assume I am misunderstanding something big.</p> <p>And then it sets dx to 0, and then sets the player x to what I assume is the start of the wall tile. But I can't see where it accounts for player acceleration to adjust the end value, or how it compensates to avoid a &quot;clip&quot; into the wall.</p> <p>I'm at my wits end trying to decipher this and further my understanding of how this math works. I've resorted to pen and paper drawing out different runs through this function, and it just seems like magic. </p> <p>I'm wondering if anyone can help me, or otherwise direct me towards something to help me with these fundamentals. Happy Holidays!</p> <p>Edit: Figured I'd link to the cart itself as well:</p> <p><a href="https://www.lexaloffle.com/bbs/?tid=28793">https://www.lexaloffle.com/bbs/?tid=28793</a></p> https://www.lexaloffle.com/bbs/?tid=40939 https://www.lexaloffle.com/bbs/?tid=40939 Sun, 27 Dec 2020 05:24:52 UTC Mget Issues on Tile-Based Game <p>Hi everyone! First time posting on the BBS, long time fan but relatively new coder!</p> <p>I've been going through the various tutorials found in fanzines, youtube, etc. and decided I'd start the foundations of a barebones strategy game using a fixed map grid of 8x8.</p> <p>My logic was like this:</p> <p>Draw the map using the map editor, then use a for loop to iterate through each cell and add it to a set of nested tables for x and y, getting its sprite value as a foundation for what can be done. Plains, mountains, water, etc.</p> <p>The code in this cart is very rough but I wanted to print the contents of the tile the cursor was currently on. There's probably other issues but every time I try to call maptable via the this 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 gamedraw() local xs = curs.x local ys = curs.y cls() map_draw() cursor_draw() location = maptable[xs][ys] print(location) 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>the maptable returns a &quot;?&quot; value and crashes the cart.</p> <p>For reference here is where maptable gets filled:</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 build_map_table() maptable={} for x=1,8 do maptable[x]={} for y=1,8 do maptable[x][y]=mget((x-1),y-1) end 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> <p>I've attached the cart for reference as well. Really I figure its an issue with mget values being printed but I also wanted to see if this entire concept is ill-conceived or if there is an easier way to accomplish the same task.</p> <p>Thanks y'all!</p> <p> <table><tr><td> <a href="/bbs/?pid=85218#p"> <img src="/bbs/thumbs/pico8_munodonuge-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=85218#p"> munodonuge</a><br><br> by <a href="/bbs/?uid=48774"> Dad Jr.</a> <br><br><br> <a href="/bbs/?pid=85218#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=40728 https://www.lexaloffle.com/bbs/?tid=40728 Wed, 09 Dec 2020 23:16:16 UTC