timeandspace [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=44894 Need help refining collision routine <p>I'm working on a collision routine for pixel based movement (not grid movement). There's no jumping, it's a from-above perspective:</p> <div> <div style="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>if btn(⬅️) then if intersect(pl.crect1,cage_crect) and pl.crect1.x&gt;=cage_crect.x+1 then pl.x1+=1 end pl.x1-=1 end if btn(➡️) then if intersect(pl.crect1,cage_crect) and pl.crect1.x&lt;=cage_crect.x then pl.x1-=1 end pl.x1+=1 end if btn(⬆️) then if intersect(pl.crect1,cage_crect) and pl.crect1.y&gt;=cage_crect.y+1 then pl.y1+=1 end pl.y1-=1 end if btn(⬇️) then if intersect(pl.crect1,cage_crect) and pl.crect1.y&lt;=cage_crect.y+cage_crect.h then pl.y1-=1 end pl.y1+=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 seems to work OK, but I am not sure how to adjust it so that the player can move along the object, e.g. bottom of player intersects top of object rect, and if player holds down+left the player should still move left. As it is, my code won't register anything other than the opposite direction after the initial direction that caused the collision. I had a quick search for collision examples but didn't find anything that met all my criteria (pixel based + uses collision rects, not tiles). Anyone have any pointers?</p> https://www.lexaloffle.com/bbs/?tid=39983 https://www.lexaloffle.com/bbs/?tid=39983 Tue, 20 Oct 2020 17:35:01 UTC Export Wav not exporting all of tune <p>As per title. I've made a piece of music that uses all 64 patterns, but when using the export wav option, only the first 54 patterns are dumped to wav.</p> https://www.lexaloffle.com/bbs/?tid=39971 https://www.lexaloffle.com/bbs/?tid=39971 Mon, 19 Oct 2020 17:04:23 UTC Starship v1.1 <p> <table><tr><td> <a href="/bbs/?pid=82807#p"> <img src="/bbs/thumbs/pico8_starship-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=82807#p"> Starship v1.1</a><br><br> by <a href="/bbs/?uid=44894"> timeandspace</a> <br><br><br> <a href="/bbs/?pid=82807#p"> [Click to Play]</a> </td></tr></table> </p> <img style="" border=0 src="/media/44894/stg9.gif" alt="" /> <h2>About</h2> <p>Starship is my third Pico-8 game, and is influenced by old single screen ZX Spectrum games like Manic Miner, Jet Set Willy, and Jetpac. Gather all the ship parts scattered about each of the 20 stages. Take them back to your starship for repairs to transcend into outer space!</p> <h2>Tips</h2> <ul> <li>Skillful play will spawn a cosmic flower. Kneel before the cosmic flower to attain the gift of the cosmos.</li> <li>Chasing score will make the game more difficult.</li> <li>Don't tread on the worms!</li> </ul> <h2>Downloads</h2> <p>Downloads for Windows, Linux, OSX, and Raspberry Pi can be found on my itch.io page:</p> <p><a href="https://exq-bytes.itch.io/">https://exq-bytes.itch.io/</a></p> <h2>Updates</h2> <p>v1.0 - Initial release<br /> v1.1 - Added stage select</p> <h2>Request</h2> <p>If anyone is able to complete the game, please reply in this thread. I'm interested to see if I maybe went too far with the difficulty on some of the later stages. During testing, I was able to complete each individual stage without losing a life, but doing all 20 in one session will be quite the challenge!</p> https://www.lexaloffle.com/bbs/?tid=39889 https://www.lexaloffle.com/bbs/?tid=39889 Sun, 11 Oct 2020 21:32:04 UTC Failed to save video error <p>As per title. After updating Win8.1 today I started getting this error when attempting to save a GIF. The only reference to this error on google says not to use special chars in your destkop path. There are only normal chars in my desktop path, so that can't be the issue. Anyone else seen this? It was working fine until I updated Windows. I also tried running as admin, but still no joy. This is the entry in config.txt:</p> <div> <div style="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>// Desktop for saving screenshots etc. Defaults to $HOME/Desktop desktop_path</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>edit: actually, I noticed something - when I replace desktop_path with a path that exists, save, then load pico-8, it gets overwritten with desktop_path. Maybe a bug?</p> https://www.lexaloffle.com/bbs/?tid=39480 https://www.lexaloffle.com/bbs/?tid=39480 Thu, 03 Sep 2020 20:37:56 UTC Having an issue with platform collision <p>I have an issue with collision detection when my character is falling, shown in the GIF below:</p> <img style="" border=0 src="/media/44894/starship_plat_bug.gif" alt="" /> <p>After a few jumping attempts, the player falls straight through the platform he is meant to land on. This is most likely because the fall rate accelerates, and the player/platform collision boxes aren't connecting. I'm setting the player collision box to a single line at the player's feet, like this:</p> <img style="" border=0 src="/media/44894/starship_player.png" alt="" /> <p>This is to make it easier to detect if the player jumps through the bottom of a platform and lands on top of it.</p> <p>Here's how I check for collision:</p> <div> <div style="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 plat_collision(o) for _,p in pairs(plats) do if intersect(p.crect,o.crect) then o.y=p.crect.y-8 --this is used to handle jumping through bottom of platforms return true end end return false end function intersect(rect1,rect2) if (rect1.x &lt; rect2.x + rect2.w and rect1.x + rect1.w &gt; rect2.x and rect1.y &lt; rect2.y + rect2.h and rect1.y + rect1.h &gt; rect2.y) then return true else return false 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>And here's the bit in my update function :</p> <div> <div style="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>if not pl.on_ground then --accumulate gravity pl.dy+=pl.grav --fall pl.y+=pl.dy end if pl.dy&gt;0 and not pl.on_ground then pl.is_falling=true else pl.is_falling=false end --if falling check if we have --hit a platform if pl.is_falling then if pl.y&gt;121 then --stop player falling through bottom-most platform pl.y=115 pl_landed() elseif plat_collision(pl) then pl_landed() end end --not falling, test if we are --stood on a platform if not pl.is_falling and not plat_collision(pl) then pl.on_ground=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>Anyone have any pointers?</p> https://www.lexaloffle.com/bbs/?tid=39468 https://www.lexaloffle.com/bbs/?tid=39468 Wed, 02 Sep 2020 17:37:34 UTC Any way to scale text without using sprites? <p>As per title. I don't have enough space in my sprite sheet to recreate the fonts, which I could just scale using something like sspr. Any other way to do it?</p> https://www.lexaloffle.com/bbs/?tid=39426 https://www.lexaloffle.com/bbs/?tid=39426 Sat, 29 Aug 2020 23:09:13 UTC Pico-Tron v1.1 <p> <table><tr><td> <a href="/bbs/?pid=81121#p"> <img src="/bbs/thumbs/pico8_picotron-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=81121#p"> Pico-Tron v1.1</a><br><br> by <a href="/bbs/?uid=44894"> timeandspace</a> <br><br><br> <a href="/bbs/?pid=81121#p"> [Click to Play]</a> </td></tr></table> </p> <img style="" border=0 src="/media/44894/stg8.gif" alt="" /> <h2>About</h2> <p>Pico-Tron is my second Pico-8 game, and is an homage to the arcade classic Robotron, with a few extra twists added. Battle your way through 21 stages of chaos and destroy the evil genius Eugene!</p> <h2>Controls</h2> <p>Press <img style="" border=0 src="/media/44894/button-up.png" alt="" /> <img style="" border=0 src="/media/44894/button-down.png" alt="" /> <img style="" border=0 src="/media/44894/button-left.png" alt="" /> <img style="" border=0 src="/media/44894/button-right.png" alt="" /> to move your super destruction robot around the screen. Tap <img style="" border=0 src="/media/44894/button-1.png" alt="" /> to rotate shot anti-clockwise, tap <img style="" border=0 src="/media/44894/button-2.png" alt="" /> to rotate shot clockwise.</p> <h2>Collect These Things</h2> <p><img style="" border=0 src="/media/44894/mon1.png" alt="" /> <img style="" border=0 src="/media/44894/mon2.png" alt="" /> <img style="" border=0 src="/media/44894/mon3.png" alt="" /> <img style="" border=0 src="/media/44894/mon4.png" alt="" /> <img style="" border=0 src="/media/44894/mon5.png" alt="" /> <img style="" border=0 src="/media/44894/mon6.png" alt="" /> <img style="" border=0 src="/media/44894/mon7.png" alt="" /> <img style="" border=0 src="/media/44894/mon8.png" alt="" /></p> <h2>Destroy These Things</h2> <p><img style="" border=0 src="/media/44894/dasher-1.png" alt="" /> <img style="" border=0 src="/media/44894/crawler-1.png" alt="" /> <img style="" border=0 src="/media/44894/seeker.png" alt="" /> <img style="" border=0 src="/media/44894/crawler-2.png" alt="" /> <img style="" border=0 src="/media/44894/border-1.png" alt="" /> <img style="" border=0 src="/media/44894/dasher-4.png" alt="" /> <img style="" border=0 src="/media/44894/dasher-2.png" alt="" /> <img style="" border=0 src="/media/44894/cross.png" alt="" /> <img style="" border=0 src="/media/44894/spawner.png" alt="" /> <img style="" border=0 src="/media/44894/dasher-5.png" alt="" /> <img style="" border=0 src="/media/44894/mon-zapper.png" alt="" /> <img style="" border=0 src="/media/44894/dasher-3.png" alt="" /></p> <h2>Tips</h2> <ul> <li>Keep moving! It's easier for enemy homing shots to hit you if you're not moving.</li> <li>Prioritise the most deadly enemy types on each stage.</li> <li>Keep your distance from fast enemies that move unpredictably.</li> <li>A bonus is awarded on each stage if you collect all innocents before destroying a single enemy.</li> <li>To score high, you need to quickly eliminate the enemy that destroys the innocents.</li> <li>If you focus only on score, the game will be much more difficult!</li> </ul> <h2>Downloads</h2> <p>Downloads for Windows, Linux, OSX, and Raspberry Pi can be found on my itch.io page:</p> <p><a href="https://exq-bytes.itch.io/">https://exq-bytes.itch.io/</a></p> <h2>All-Clear</h2> <p>Here's a video of the game being completed that might be useful for anyone needing gameplay tips:</p> <p><object width="640" height="400"><param name="movie" value="https://www.youtube.com/v/GgPc1vdEVb0&hl=en&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/GgPc1vdEVb0&hl=en&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="400"></embed></object></p> <h2>Updates</h2> <p>v1.0 - Initial release<br /> v1.1 - Fixed a bug where high score wasn't saved if player completes the game.</p> https://www.lexaloffle.com/bbs/?tid=39336 https://www.lexaloffle.com/bbs/?tid=39336 Mon, 24 Aug 2020 19:01:02 UTC Multiple assignment within a table <p>Is multiple assignment possible within a table, e.g.</p> <div> <div style="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>e={ x,y,health,timer=0,0,0,0, score_val=100, colour=7 }</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>When I do that, for some reason the timer value is returning nil.</p> <p>Or, is there a limit to the number of multiple assignments? I am currently setting 16 variables to zero.</p> https://www.lexaloffle.com/bbs/?tid=39207 https://www.lexaloffle.com/bbs/?tid=39207 Fri, 14 Aug 2020 00:57:20 UTC Advice needed on how to manipulate sprite pixels <p>Let's say I have an 8x8 sprite, like the one in my avatar. I want to manipulate that sprite as follows:</p> <ol> <li>Randomly position each non black sprite pixel outside the viewport.</li> <li>Move those pixels into the viewport to form the sprite.</li> </ol> <p>I know how to do this with a whole sprite, but how might I achieve this effect with the individual sprite pixels? Obviously I'll need the following:</p> <ol> <li>Destination position of sprite within the viewport.</li> <li>The index position within the 8x8 grid of each pixel, offset from sprite destination position - e.g. x,y of sprite, then index of pixel within the sprite 8x8 grid.</li> </ol> <p>Anyone have any ideas? I want this as a neat effect for spawning enemies at the start of each stage in a new game I an working on.</p> https://www.lexaloffle.com/bbs/?tid=39162 https://www.lexaloffle.com/bbs/?tid=39162 Sun, 09 Aug 2020 19:22:11 UTC Pico-Tron <p>Here's my follow-up to my first Pico-8 game (Pico-Bot). This one is called Pico-Tron and will be a Robotron-style shooter. There aren't many of these types of games on Pico-8 so thought I'd try my hand at one. It won't be a slavish recreation, instead it will have lots of new features of its own. It currently has 13 enemy types, with around 790 tokens remaining that I might use for a few more enemy types. I still have the sfx and music to do too. Should hopefully have it finished soon.</p> <img style="" border=0 src="/media/44894/Pico-Tron-001.gif" alt="" /> https://www.lexaloffle.com/bbs/?tid=39146 https://www.lexaloffle.com/bbs/?tid=39146 Sat, 08 Aug 2020 13:04:37 UTC Anyone have a compact line/rect intersection routine? <p>I'm using the code below, but it's quite a lot of tokens when converted to Lua. Does anyone have a more compact routine for use with Pico-8?</p> <p><a href="http://www.jeffreythompson.org/collision-detection/line-rect.php">http://www.jeffreythompson.org/collision-detection/line-rect.php</a></p> https://www.lexaloffle.com/bbs/?tid=39127 https://www.lexaloffle.com/bbs/?tid=39127 Thu, 06 Aug 2020 15:23:21 UTC Pico-Bot v1.2 <p> <table><tr><td> <a href="/bbs/?pid=79659#p"> <img src="/bbs/thumbs/pico8_picobot-3.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=79659#p"> Pico-Bot v1.2</a><br><br> by <a href="/bbs/?uid=44894"> timeandspace</a> <br><br><br> <a href="/bbs/?pid=79659#p"> [Click to Play]</a> </td></tr></table> </p> <h2><img style="" border=0 src="/media/44894/17_12b.png" alt="" /> Info</h2> <p>Here is my fist Pico-8 game: Pico-Bot. I made this over the last two months in my spare time. It's a sort of horizontal Space Invaders with platforms and more intricate scoring techniques.</p> <img style="" border=0 src="/media/44894/anim004.gif" alt="" /> <h2><img style="" border=0 src="/media/44894/7b.png" alt="" /> How to Play</h2> <ul> <li>Destroy enemies and collect the orbs they drop.</li> <li>The quicker you collect orbs, the higher your score.</li> <li>Collect three large orbs to activate the score multiplier.</li> <li>Tip: you're invincible while jumping between platforms.</li> </ul> <p>Here's a video showing the game being completed to show that it is possible!</p> <p><object width="640" height="400"><param name="movie" value="https://www.youtube.com/v/vKIYuh1Y0eg&hl=en&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/vKIYuh1Y0eg&hl=en&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="400"></embed></object></p> <h2><img style="" border=0 src="/media/44894/9b.png" alt="" /> Other Platforms</h2> <p>You can download Windows, Linux, OSX, and Raspberry Pi builds from my itch.io page:</p> <p><a href="https://exq-bytes.itch.io/pico-bot">https://exq-bytes.itch.io/pico-bot</a></p> <h2><img style="" border=0 src="/media/44894/19_3b.png" alt="" /> Update History</h2> <p>v1.0</p> <ul> <li>Initial release</li> </ul> <p>v1.1</p> <ul> <li>Added a more eye-catching cart label.</li> <li>Simplified drawing of logo by using sspr function to draw sprite sheet region.</li> <li>Fixed a text alignment issue on title screen.</li> </ul> <p>v1.2</p> <ul> <li>Changed mines to prevent them spawning slightly off-screen.</li> <li>Adjusted the difficulty slightly to make it fairer.</li> </ul> https://www.lexaloffle.com/bbs/?tid=38915 https://www.lexaloffle.com/bbs/?tid=38915 Mon, 20 Jul 2020 09:07:19 UTC Problem decoding strings to tables <p>I'm trying to free up some tokens in my game by converting some tables to strings. Here's how I am trying to convert a string back to a table (which contains tables):</p> <div> <div style="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>stgs=&quot;102,2\102,1&quot; for i=1,#stgs do if sub(stgs,i,i)==&quot;,&quot; then sprite=tonum(sub(stgs,i-3,i-1)) layout=tonum(sub(stgs,i+1,i+1)) add(stg_defs,{sprite,layout}) 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 would expect the output for the above code to be:</p> <div> <div style="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>{ {102,2}, {102,1} }</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>However, the actual output is:</p> <div> <div style="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>{ {102,2}, {nil,1} }</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Can anyone spot what I'm doing wrong?</p> https://www.lexaloffle.com/bbs/?tid=38623 https://www.lexaloffle.com/bbs/?tid=38623 Wed, 01 Jul 2020 05:32:37 UTC Does anyone use pico-8 on a Gameshell with DropBox? <p>On Win/Mac it's possible to point your carts and high scores folders (in the pico-8 config) to a shared dropbox folder so you can keep your games collection and saves synced across multiple devices. Does anyone know how to do this with a ClockworkPi Gameshell?</p> https://www.lexaloffle.com/bbs/?tid=38498 https://www.lexaloffle.com/bbs/?tid=38498 Sat, 20 Jun 2020 15:32:28 UTC 'Self' in class not being passed to global function <p>I have enemies in my game that have behaviours - 1 behaviour function per enemy. Instead of defining the behaviour within the enemy class definition (waste of memory as the function will be created for each enemy of the same type) I want to define each behaviour once (outside the enemy class) and have each enemy instance hold a reference to its single behaviour. The enemy object needs to be able to send a reference of itself to the single behaviour function. I tried this:</p> <div> <div style="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 setup() enemy_group1={} for i=1,max_group_enemies do enemy={ e.alive=false, behav=en_visit(self) } add(enemy_group1,enemy) end add(enemies,enemy_group1) end function en_visit(e) e.x+=1 end function spawn(x,y,etype,edir,vel) for _,e in pairs(enemies[etype]) do if not e.alive then e.alive=true return end end end function update() for _,egroup in pairs(enemies) do for _,e in pairs(egroup) do if e.alive then e:behav() end 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>The en_visit function is correctly being called, but it isn't receiving a value for its parameter (e). The error reported is: attempt to index local 'e' (a nil value). Can anyone spot where I'm going wrong?</p> https://www.lexaloffle.com/bbs/?tid=38351 https://www.lexaloffle.com/bbs/?tid=38351 Tue, 09 Jun 2020 22:42:43 UTC