arashi256 [Lexaloffle Blog Feed] Why doesn't this work like I expect? <p>Hi, </p> <p>I've got this grid of &quot;slots&quot; for enemies which I initially created using a start_x and start_y position and a couple of nested for loops to create the rows/cols with the start_x / start_y being the top left for the starting position of the grid. </p> <p>But now I wanted to create the same grid but relative to an origin point at the centre - my thinking was I could increment this single point and move the grid around and maybe use sin/cos to have the slots rotate around the origin for some fun enemy patterns.<br /> I didn't really know how to do this, so I just modified my x/y starting positions until I could get two short lines of code for the initial X/Y positions that worked. This looks fine until you move the origin point which then lags behind or in front of the actual grid. </p> <p>My math is awful, so I don't really know what I'm doing wrong. I figured if the initial grid looked okay relative to the origin, I could just change the origin values and everything would fall into place at the new position in update(). But not so.<br /> I assume it's the way I'm creating the initial X/Y positions, but I don't know how to fix it neatly.</p> <p>Can somebody more math-inclined help me out?</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>inv_slots={} grid_origin={x=127/2,y=40} speed=0.25 function _init() init_inv_slots() end function init_inv_slots() local i_num=1 local width=8 local height=7 for r=1,4 do for c=1,8 do local i={ col=c, row=r, x=grid_origin.x-(c*10)+(grid_origin.x/2)+13, -- Problem here y=grid_origin.y-(r*10)+(grid_origin.y/2)+5, -- Problem here w=width, h=height, num=i_num } add(inv_slots,i) i_num+=1 end end end function _update60() update_inv_slots() end function update_inv_slots() if btn(0) then grid_origin.x-=speed end if btn(1) then grid_origin.x+=speed end if btn(2) then grid_origin.y-=speed end if btn(3) then grid_origin.y+=speed end --grid_origin.x+=speed for i in all(inv_slots) do i.x=grid_origin.x-(i.col*10)+(grid_origin.x/2)+13 -- So will be problem here too. i.y=grid_origin.y-(i.row*10)+(grid_origin.y/2)+5 -- and here. --if ((i.x+speed)+(i.w/2)&gt;127 or (i.x+speed)-(i.w/2)&lt;0) then -- speed=-speed --end end end function _draw() cls() draw_inv_slots() end function draw_inv_slots() for i in all(inv_slots) do rect(i.x-(i.w/2),i.y-(i.h/2),i.x+(i.w/2),i.y+(i.h/2),7) end pset(grid_origin.x,grid_origin.y,8) end</pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> Fri, 31 May 2019 11:50:18 UTC My steering code occasionally goes crazy <p>Can somebody explain why my steering code (well, <a href=""> @2darray</a>'s mostly) sometimes goes bananas and sine's itself off-screen rather than heading to the next waypoint? It only happens occasionally and I can't see why and always to the left.</p> <p> <table><tr><td> <a href="/bbs/?pid=64258#p"> <img src="/bbs/thumbs/pico8_nokikfiyu-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=64258#p"> Waypoint2</a><br><br> by <a href="/bbs/?uid=22217"> arashi256</a> <br><br><br> <a href="/bbs/?pid=64258#p"> [Click to Play]</a> </td></tr></table> </p> <p>Sometimes it'll do this...</p> <img style="" border=0 src="" alt="" /> <p>Would greatly appreciate any help and a math explanation. It seems to happen more often if I decrease the turning speed from say </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> turnspeed=2*(pi/180) </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>to </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> turnspeed=0.5*(pi/180) </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>but that doesn't explain the example gif because the distance between node 5 and 6 is quite far.</p> <p>Edit: I've uploaded a version with a simpler sprite and a vector to show the current target node. </p> Thu, 09 May 2019 13:58:47 UTC Android Chrome audio stutter <p>Apologies if this is common knowledge and I asked on Twitter as well, but...</p> <p>Is it just me or does anybody else get extreme audio stuttering on Android with Chrome on the web export? This has happened across three diffferent phones and three Pico8 versions. Audio is fine on Samsung's browser and Edge mobile. Was there ever a fix for this that I missed?</p> Fri, 03 May 2019 11:11:48 UTC Road Storm <p> <table><tr><td> <a href="/bbs/?pid=53292#p"> <img src="/bbs/thumbs/pico53607.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=53292#p"> Road Storm 1.1</a><br><br> by <a href="/bbs/?uid=22217"> arashi256</a> <br><br><br> <a href="/bbs/?pid=53292#p"> [Click to Play]</a> </td></tr></table> </p> <p>1.1 update: </p> <ul> <li>Code optimisation</li> <li>Muted alert sound for low fuel/ammo</li> <li>Reinstated original title screen (much better!)</li> <li>Added btn(5) X as alternative acceleration button for those using joypads/sticks.</li> </ul> <p>My third little game - an arcade racer / shooter a bit like RoadBlasters, which was a favourite of mine as a kid.</p> <p>Up = Accelerate<br /> Down = Brake<br /> Left/Right = Turn left / right<br /> Z = Shoot<br /> X = Alternative accelerate</p> <p>Hope you enjoy it. Don't bother asking for improvements, I'm at the token limit :D On to the next thing!</p> Tue, 05 Jun 2018 11:57:28 UTC Weapons help <p> <table><tr><td> <a href="/bbs/?pid=52773#p"> <img src="/bbs/thumbs/pico52771.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=52773#p"> Weapons help</a><br><br> by <a href="/bbs/?uid=22217"> arashi256</a> <br><br><br> <a href="/bbs/?pid=52773#p"> [Click to Play]</a> </td></tr></table> </p> <p>Hi,</p> <p>I am reduced to asking for help with the above. Pressing Z fires projectiles to a target XYZ that is Z+10 units &quot;into&quot; the screen (denoted as white targets). This is fine when the target X matches the source X (the player, basically) but when firing to the sides (+/- 150 units) the speed is very slow and I'm somehow able to fire much faster than I should be able to. </p> <p>The relevant stuff is in update_bullets(). </p> <p>I'm using a fairly standard algo for moving towards a target that I'm pretty sure I used before for 2D stuff but I can't make it work in &quot;3D&quot;. I assumed you just swapped out the Y for the Z. </p> <p>Can somebody help me out? </p> <p>Z = Fire<br /> Left,Right = Shift the targets 150 units to the left or right.</p> Tue, 15 May 2018 07:56:37 UTC The stat() function - memory and CPU (and a few other Q's) <p>Hi guys,</p> <p>So I'm developing my third game and actually reading the docs this time around and I'm now using the stat() function to see what's going on as I code. </p> <p>I've got about 284 lines of code and a spritesheet of 785 bytes. No music or sound effects. Yet my mem usage is 43MB according to stat(0). Isn't...that a lot? Seems like a lot. What's going on here? Is it measuring the entire PICO-8 development environment usage or just my code?</p> <p>Also, stat(1) for CPU usage from the docs states that a value of 1.0 is the program executing 100% of the time between frames, whereas anything over 1.0 is basically frame-skipping due to excessive load. I've of a value of 0.19. I'm guessing anything under 1.0 is &quot;this is way easy, what else you got?&quot; from the CPU, correct?</p> <p>I've also been looking at the PICO-8 cheat-sheet and noticed the memory layout. And I know people use peek/poke/memcpy/memset to do....stuff. Why would I need to know the memory layout for PICO-8 and why is manually fiddling with the memory desirable? Procedurally generated graphics? Anything else?</p> <p>Thanks!</p> Wed, 24 Jan 2018 14:40:26 UTC Dawn of Nuke <p> <table><tr><td> <a href="/bbs/?pid=42132#p"> <img src="/bbs/thumbs/pico42131.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=42132#p"> Dawn of Nuke 1.0</a><br><br> by <a href="/bbs/?uid=22217"> arashi256</a> <br><br><br> <a href="/bbs/?pid=42132#p"> [Click to Play]</a> </td></tr></table> </p> <p>My second game - my version of Missile Command. I learned a fair bit doing this one so I hope you like it :D<br /> Much like nuclear war, there is no win state, you just survive as long as you can whilst things get progressively more difficult. </p> <p>The aim is to keep your cities safe from ICBM attack. You have a limited number of ABM missiles. As long as one city survives each wave, you can continue. Destruction of ABM launch silos means you cannot use it although they are more hardened than cities against a direct impact. Bonuses are awarded for each surviving city. </p> <p>Controls: </p> <p>Z to start game<br /> X to fire ABM missiles</p> <p>This is so much fun, on to the next project! </p> Sat, 01 Jul 2017 18:50:37 UTC Self-hosted games not the same as BBS on mobile <p>Hi, sorry if this is a stupid question because I'm not really a web developer but I've hosted my game on my own site and it doesn't behave the same as the same game hosted here. Desktop is fine but on mobile, the on-screen touch controls are missing and I have to pinch to zoom to get the game to fill the window while on here it fits neatly even without using full-screen mode.<br /> Can someone point me in the right direction? I'd like my Pico8 games pages to be mobile-aware.</p> <p>I don't know if this is something I need to change with the export or what. I'm game to learn &quot;proper&quot; web development....I know some basic HTML and that's it but I'm up for getting my hands dirty if someone can point me in the right direction.</p> <p>Also as an aside, I couldn't figure out how to post here without switching mobile Chrome to the desktop version. You can't seem to post otherwise.</p> Thu, 30 Mar 2017 13:45:23 UTC Standard 2D gamedev resources? <p>I know this isn't strictly speaking Pico-8 related but I'm not much of a programmer and I get the feeling that a lot of the clever techniques that I see used here standard things in terms of doing 2D graphics and movements and things like that and can probably be used in any 2D game programming language/library.<br /> Does anyone know of any 2D gamedev resources to learn more that explain the math/algorithms involved in simple 2D games and effects? I've done exactly one game in Pico8 and it took a very long time because I don't know how to implement things that appear to be standard 2D videogamey things. Absolutely everything I know about game programming is in that game and it's basically just Pong (again).</p> <p>Sorry for the off-topicness and potentially vague question.</p> Tue, 28 Mar 2017 15:12:27 UTC Space Picanoid <p> <table><tr><td> <a href="/bbs/?pid=38727#p"> <img src="/bbs/thumbs/pico38726.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=38727#p"> Space Picanoid 1.0</a><br><br> by <a href="/bbs/?uid=22217"> arashi256</a> <br><br><br> <a href="/bbs/?pid=38727#p"> [Click to Play]</a> </td></tr></table> </p> <p>First Pico-8 game. Sorry it's Pong/Arkanoid again :) This is pretty much done simply because I can't think of anything else to add. I had to learn Lua at the same time so the code is probably pretty horrible. I'll update it for bug fixes and that but I'm probably going to move onto something else after this.</p> <ul> <li>16 levels. </li> <li>7 power ups.</li> <li>Persistent high-score. </li> <li>Whizzy particles. </li> </ul> <p>Yeah, I guess that's it. Many thanks to the Pico-Hero guy for getting me started.</p> Sat, 25 Mar 2017 14:52:03 UTC Recording animated GIF in Linux <p>Hi, </p> <p>I'm trying to record an animated GIF under Linux in PICO-8. It records it fine according to PICO-8, but I have no idea where the file is located. I've done a file search for GIFs under my user directory and nothing turns up. Nothing under $HOME/Desktop where I'd expect it to be.</p> <p>Little help?</p> Sat, 25 Mar 2017 09:30:22 UTC