SVEDEN11 [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=21326 Dungeon Song Test v1 <p> <table><tr><td> <a href="/bbs/?pid=73896#p"> <img src="/bbs/thumbs/pico8_dungeonsongtest-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=73896#p"> Dungeon Song Test v1</a><br><br> by <a href="/bbs/?uid=21326"> SVEDEN11</a> <br><br><br> <a href="/bbs/?pid=73896#p"> [Click to Play]</a> </td></tr></table> </p> <p>This is just a small loop I've been working on which I plan to put in one of my games, but thought I'd upload it to see what others think. It doesn't use any custom instruments and so far any additional layers I've attempted to add (drums, other melodies, etc.) haven't really sounded right. I'm curious if folks think this loop stands on its own enough or if it would become annoying to listen to after a while. Any general feedback is welcome.</p> https://www.lexaloffle.com/bbs/?tid=37064 https://www.lexaloffle.com/bbs/?tid=37064 Sat, 14 Mar 2020 00:23:07 UTC How to check for overlapping sprites? <p>When I try to run the code listed below, my game freezes because of the while loop. Can anyone shed some light on how I can prevent the while loop in this code snippet from choking? Or if there's a better way all together?</p> <p>I'm hoping to add additional objects to these functions (though they would be single objects instead of sets of 30 and 15, but I'm not at all an experienced coder.</p> <p>I was trying to borrow code from the following page: <a href="https://level0gamedev.blogspot.com/2016/05/back-to-game-code.html">https://level0gamedev.blogspot.com/2016/05/back-to-game-code.html</a></p> <p>I'm also having a second issue of all 45 sprites being set to foo's sprite instead of 30 for foo and 15 for bar, but i'll have to tackle that later unless someone can weigh in on that as well.</p> <p>Any help is greatly appreciated! Thank you :)</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 _init() test = 0 for i = 1, 30 do spawn_actor(foo) end for i = 1, 15 do spawn_actor(bar) end function spawn_actor(name) local obj = {} obj.type = name obj.frame = nil obj.x = flr(rnd(right_border) + left_border) obj.y = flr(rnd(bottom_border - top_border) + top_border) obj.w = 8 obj.h = 8 obj.x2 = obj.x + obj.w * 8 obj.y2 = obj.y + obj.h * 8 if obj.name == foo then obj.frame = 16 + flr(rnd(3)) elseif obj.name == bar then obj.frame = 32 end overlapped = true while overlapped do overlapped = false foreach(actors, function(actors) if actors.x &lt;= obj.x + obj.w * 8 + 1 and actors.x + actors.w * 8 &gt;= obj.x - 1 and actors.y &lt;= obj.y + obj.h * 8 + 1 and actors.y + actors.h * 8 &gt;= obj.y - 1 then test += 1 overlapped = true obj.x = flr(rnd(right_border) + left_border) obj.y = flr(rnd(bottom_border - top_border) + top_border) end end) end add(actors, obj) end function _draw() cls() foreach (actors, draw_actor) end function draw_actor(obj) spr(obj.frame, obj.x, obj.y, 1, 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> https://www.lexaloffle.com/bbs/?tid=28500 https://www.lexaloffle.com/bbs/?tid=28500 Mon, 09 Jan 2017 02:19:17 UTC Is there any way to simulate z-index? <p>Hi,</p> <p>I'm trying to have a sprite move in front of and behind other objects to simulate z-index ordering, but I'm not sure how to do this in PICO-8. I figured it would work something like if object_a.y &gt; object_b.y, move behind that object. </p> <p>I saw somewhere someone giving each object/sprite a &quot;z&quot; variable that would control what order things were drawn, but that wasn't for PICO-8 so I don't know if that could be recreated here. </p> <p>After some searching, I see that this has been done in The Lair and Kick Wizards, but I'm very new to Lua/PICO-8 so I'm having a hard time finding how they're doing it. Any help is greatly appreciated.</p> <p>The Lair: <a href="https://www.lexaloffle.com/bbs/?tid=4051">https://www.lexaloffle.com/bbs/?tid=4051</a><br /> Kick Wizards: <a href="https://www.lexaloffle.com/bbs/?tid=27697">https://www.lexaloffle.com/bbs/?tid=27697</a></p> <p>Thanks!</p> https://www.lexaloffle.com/bbs/?tid=28469 https://www.lexaloffle.com/bbs/?tid=28469 Sat, 07 Jan 2017 07:38:39 UTC