freds72 [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=25532 Rotated Ellipse Fill <p> <table><tr><td> <a href="/bbs/?pid=66809#p"> <img src="/bbs/thumbs/pico8_ellipsefill-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=66809#p"> ellipsefill</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=66809#p"> [Click to Play]</a> </td></tr></table> </p> <p>A little experiment with filled ellipse, supporting any rotation angle (the tricky part!).<br /> The code is moderately fast as it finds the root of the ellipse equation to get the segment extent for each row.</p> <p>Car headlight example use:</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/ellipse_0.gif" alt="" /> https://www.lexaloffle.com/bbs/?tid=35124 https://www.lexaloffle.com/bbs/?tid=35124 Tue, 20 Aug 2019 20:47:24 UTC [feature] fast loading for multi-cart <p><a href="https://www.lexaloffle.com/bbs/?uid=1"> @zep</a><br /> A couple of devs are investing into multicart games (like 5 or more data carts).<br /> We are all put back by the artificial loading times (eg <em>minutes</em>)</p> <p>Would it be possible for the fat client to either ignore load time throttling, or only activat throttling for the published version?<br /> I want the multicart multiverse, not loading screens ;)</p> https://www.lexaloffle.com/bbs/?tid=34813 https://www.lexaloffle.com/bbs/?tid=34813 Tue, 23 Jul 2019 06:44:48 UTC stat(102) does not work for iframes <p>Using the <em>cough</em> undocumented <em>cough</em> stat(102) from a game hosted on itch.io, I got back:</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> v6p9d9t4.ssl.hwcdn.net </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 indeed the url of the iframe (which doesn't help).<br /> A more correct behavior would be to report the parent page url, with the benefits of:</p> <ul> <li>having a predictable outcome</li> <li>actually preventing rogue hosting (somehow...)</li> </ul> <p>Note: Looking at the HTML, I see that url is retrieved from:</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> var str = window.location.hostname; </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Using that alternate code would fix the bug:</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> var str = (parent !== window) ? document.referrer : document.location; </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=34800 https://www.lexaloffle.com/bbs/?tid=34800 Sun, 21 Jul 2019 08:37:57 UTC Licences PICO-8 &agrave; gagner! <p><em>Ce post est la version fran&ccedil;aise de:</em> <a href="https://www.lexaloffle.com/bbs/?tid=34615">PICO-8 Giveaway</a></p> <p>Initi&eacute; par <a href="https://www.lexaloffle.com/bbs/?uid=13822"> @Liquidream</a>, plusieurs developpeurs offrent des licences pico8 &agrave; des jeunes (et moins jeunes) qui n'auraient pas les moyens mais pleins d'id&eacute;es!</p> <h1>Participation</h1> <p>Pour avoir une chance de gagner, repondez &agrave; la <a href="https://www.lexaloffle.com/bbs/?tid=34615">discussion officielle</a> avec un petit message:</p> <ul> <li>pourquoi vous voulez une licence?</li> <li>quel jeu(x) comptez-vous cr&eacute;er?</li> </ul> <h1>Les R&egrave;gles</h1> <ul> <li>Ouvert &agrave; tous (sauf ceux qui peuvent se payer une licence ET un sandwich!)</li> <li>Une seule entr&eacute;e par personne</li> <li>Date de cloture (ouch!) Samedi 6 Juillet @ 11:00 (heure Paris)</li> <li>Les gagnants seront choisis <em>au hasard</em> </li> <li>Il y aura autant de gagnants que de licences offertes</li> <li>La licence sera attribu&eacute;es via un compte mail (message priv&eacute;)</li> </ul> <p>Bonne chance 😁🤞</p> https://www.lexaloffle.com/bbs/?tid=34630 https://www.lexaloffle.com/bbs/?tid=34630 Thu, 04 Jul 2019 19:16:58 UTC Ghost Rally <h1>Ghost Rally</h1> <p> <table><tr><td> <a href="/bbs/?pid=64950#p"> <img src="/bbs/thumbs/pico8_grally-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=64950#p"> grally</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=64950#p"> [Click to Play]</a> </td></tr></table> </p> <h2>Game</h2> <p>The game is a race-against-yourself rally game. It features accurate rigid body physics and car handling.<br /> Goal is to beat yourself every lap!</p> <p>Enjoy racing as in the 80's, whith over powered cars very close to the public!<br /> <em>tip</em> hitting any of the lil' dudes: <table><tr><td width=244> <img src="https://www.lexaloffle.com/bbs/gfxc/25532_4.png" width=244 height=64> </td> <td valign=bottom> <a style="cursor:pointer;font-size:8pt" onclick=' var el = document.getElementById("gfxcode_25532_4"); if (el.style.display == "none") el.style.display = ""; else el.style.display = "none"; microAjax("https://www.lexaloffle.com/bbs/gfxc/25532_4.txt", function (retdata){ var el = document.getElementById("gfxcode_25532_4"); el.innerHTML = retdata; el.focus(); el.select(); } ); '> [61x16]</a> </td></tr> <tr><td colspan=2> <textarea rows=3 class=lexinput id="gfxcode_25532_4" style="width:640px;background-color:#fed;display:none;overflow:hidden; font-size:6pt;"></textarea> </td> </tr> </table> incurs a +5s time penalty :]</p> <p><em>warning</em> the game is complete yet the car handling is <strong>really</strong> picky - I am releasing it as is, as I can't tweak the gameplay without breaking the physic engine :/</p> <h2>Controls</h2> <ul> <li>left/right: turn</li> <li>up/down: accelerate/brake</li> <li>c: re<strong>c</strong>over (when flipping over!)</li> </ul> <h1>Dev Log</h1> <p>Source code &amp; tools: <a href="https://github.com/freds72/ghost-rally">ghost-rally</a></p> <h2>Credits:</h2> <p>Sound effect code: taken from <a href="https://www.lexaloffle.com/bbs/?uid=10050"> @tiagosr</a> rally game<br /> Trifill: <a href="https://www.lexaloffle.com/bbs/?uid=28958"> <a href="https://www.lexaloffle.com/bbs/?uid=28958"> @p01</a></a></p> <h2>Physic Engine</h2> <p>Physic engine was started from scratch following <a href="http://www.cs.cmu.edu/~baraff/sigcourse/notesd1.pdf">Barraf's</a> 'classic' paper.<br /> I quickly dropped this version as it relied too much on numeric convergence !</p> <p>The current version uses part of <a href="https://github.com/RandyGaul/qu3e">Randy Gaul C++ physic library</a> and <a href="https://www.randygaul.net/2013/03/27/game-physics-engine-part-1-impulse-resolution">underlying principles</a>.<br /> The key aspect to get stable collision is to resolve impacts only for the incident face, e.g. the plane most facing the ground:</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/rally_9.gif" alt="" /> <p>This is obviously an heavily simplified version, limited to dynamic-to-static resolution.<br /> Randy's engine architecture relies on very few magic constants and is extremely stable (well, as long as pico numbers don't get in the way!!).</p> <p>The physic engine is designed as an extension a generic 3d actor class and can easily be taken out for other games.</p> <h2>Car Physic</h2> <p>The car is modeled using a front and rear tire. Each tire has lateral and longitudinal forces, as detailed in this article: <a href="http://theracingline.net/2018/race-car-tech/race-tech-explained/tyres-combined-tyre-forces/">The Racing Line - Combined Tyre Forces</a>.<br /> Other good readings:<br /> <a href="http://www.asawicki.info/Mirror/Car%20Physics%20for%20Games/Car%20Physics%20for%20Games.html">Car Physics for Games</a><br /> <a href="https://www.iforce2d.net/b2dtut/top-down-car">Box2d Top Down Racing Game</a></p> <p>The gif above shows forces applied to the car and their application point:</p> <ul> <li>G force (down)</li> <li>read tyre pushing car (with a lateral component to counter slide)</li> <li>front tyre and turning forces (again with a lateral component)</li> </ul> <p>Slip angle and slip ratio curves are defined using SFX 4 and 5 - tweak them to see effect in game!</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/rally_001.png" alt="" /> <h2>Terrain</h2> <p>The game started as a terrain renderer using marching squares.<br /> Terrain height map is 64x64, displayed as a 128x128 grid to display marching square &quot;diamond tiles&quot;:</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/rally_wireframe.gif" alt="" /> <h2>Textured Car</h2> <p>The car is textured mapped, using a custom version of <a href="https://www.lexaloffle.com/bbs/?uid=28958"> <a href="https://www.lexaloffle.com/bbs/?uid=28958"> @p01</a></a> trifill.<br /> The Blender model directly references an export of the cart spritesheet.</p> <h2>Toolchain</h2> <p>The game uses my usual Blender/Python export toolchain.<br /> A custom terrain editor is available as a pico-8 cart (contact me if needed)</p> https://www.lexaloffle.com/bbs/?tid=34424 https://www.lexaloffle.com/bbs/?tid=34424 Sun, 02 Jun 2019 14:33:39 UTC Help on __sfx__ section byte format <p>I am writing data to a p8 file from a Python program - format for 0x0-0x3200 ROM range is ok.<br /> Issue is sfx section - each sfx (68 bytes) is actually written as 84 bytes (??) with empty bits left and right.<br /> I have no clue what is the masking/bitshifting/... logic between my input value and the resulting p8 string.</p> <p>Example:</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> poke4(0x3200,0x1234.5678) cstore() </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>produces:</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> __sfx__ 000100003813534011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>wtf??</p> https://www.lexaloffle.com/bbs/?tid=34167 https://www.lexaloffle.com/bbs/?tid=34167 Thu, 09 May 2019 18:44:42 UTC [v0.1.12c] key stuck in html export <p><strong><em> Case solved: issue was triggered by one of my USB sticks constantly sending inputs </em></strong></p> <p>When exporting <a href="https://github.com/freds72/tiny_sim/blob/1.1/carts/tinysim_v11.p8">Tiny Sim</a>, some keys are stuck:</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/keyboard_stuck.PNG" alt="" /> https://www.lexaloffle.com/bbs/?tid=34130 https://www.lexaloffle.com/bbs/?tid=34130 Fri, 03 May 2019 14:25:18 UTC FPS Desert Demo <p> <table><tr><td> <a href="/bbs/?pid=63343#p"> <img src="/bbs/thumbs/pico8_numakunawa-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=63343#p"> numakunawa</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=63343#p"> [Click to Play]</a> </td></tr></table> </p> <p>FPS demo cart as an answer to <a href="https://www.lexaloffle.com/bbs/?uid=10198"> @MBoffin</a> April 1st Twitter joke.<br /> Stay tuned for technical details.</p> https://www.lexaloffle.com/bbs/?tid=33827 https://www.lexaloffle.com/bbs/?tid=33827 Mon, 08 Apr 2019 21:27:53 UTC Realtime 3d shadows <p> <table><tr><td> <a href="/bbs/?pid=60772#p"> <img src="/bbs/thumbs/pico8_doyusuyepo-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=60772#p"> doyusuyepo</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=60772#p"> [Click to Play]</a> </td></tr></table> </p> <p>Project started following a question on 3d clipping on this forum and quickly spiraled into a full blown 3d renderer with support for real-time shadows and camera space clipping :/</p> <p>Shadows are calculated in real-time by extruding a shadow volume from each lit face.<br /> Resulting polygons are added to the face and rendered/sorted with the face.</p> <p>The shadows are globals e.g. self-shadowing is supported, see torus scene.</p> <p>Performance-wise this is bordering what pico can support, as many clipping operations are required to generate shadow polygons. There is room for optimization (vertex cache, smart selection of clipping planes) left to the reader!</p> <h2>Sources</h2> <p>Project (including how to add custom 3d models) is available here: <a href="https://github.com/freds72/pico8-shadows">github</a></p> <h2>Acknowledgements:</h2> <ul> <li>3d papers from the 70s/80s are pure gold!</li> <li>trifill function from <a href="https://www.lexaloffle.com/bbs/?uid=28958"> @p01</a></li> </ul> <h2>Update 1.1</h2> <ul> <li>fixed polygon gaps (using correct middle screen position + ceil)</li> </ul> https://www.lexaloffle.com/bbs/?tid=32879 https://www.lexaloffle.com/bbs/?tid=32879 Sat, 12 Jan 2019 14:38:37 UTC Keyboard captured by game <p>How to reproduce:</p> <ul> <li>go to a game page</li> <li>launch game</li> <li>go to comment section</li> <li>type some text</li> </ul> <p>Bug: nothing appears (input is captured by pico)</p> <p>Workaround: refresh the page / don't launch game before posting comments.</p> https://www.lexaloffle.com/bbs/?tid=32536 https://www.lexaloffle.com/bbs/?tid=32536 Tue, 11 Dec 2018 21:38:30 UTC Unable to post/attach gifs <p>Since forum updates, new gif uploads are rendered as broken links.<br /> See: <a href="https://www.lexaloffle.com/bbs/?pid=59400#p">https://www.lexaloffle.com/bbs/?pid=59400#p</a></p> https://www.lexaloffle.com/bbs/?tid=32410 https://www.lexaloffle.com/bbs/?tid=32410 Sat, 01 Dec 2018 15:11:26 UTC X-Wing vs. Tie Figther: Attack on the Deathstar <p> <table><tr><td> <a href="/bbs/?pid=53727#p"> <img src="/bbs/thumbs/pico55974.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=53727#p"> X-Wing vs. Tie Figther: Attack on the Deathstar 1.2</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=53727#p"> [Click to Play]</a> </td></tr></table> </p> <h1>Be a X-Wing pilot!</h1> <p>Take a seat in the most advanced fighter of the galaxy. Fight against the evil empire!<br /> Use proton torpedo to quickly dismiss enemy forces or your 4 blasters (aiming skill required).<br /> Go through 4 epic missions, from space to Deathstar and back.</p> <h1>Flight Manual</h1> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/xvst_manual_0.gif" width=256 height=256 alt="" /> <h1>Copyright Notice</h1> <p>Starwars logo/music/... credits to their respective owners. Don't sue me :/</p> <h1>Dev Log</h1> <p>This is a demake of the X68000 Attack of the Deathstar game, (kind of) complete with space/ground/trench missions.<br /> This version departs from the original with a less arcade/grinding gameplay.</p> <p>The un-minified version can be found (as usual) on my <a href="https://github.com/freds72/pico8/blob/master/carts/xvst.p8">Github page</a> (includes all 3d assets).</p> <h2>Tie Fighters</h2> <p>All flying NPCs are following boids behavior (seek, avoid, follow) and are really a blast to watch in pack (imho)!<br /> Baddies will try to get on your six to fry good old r2d2 :/</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/xvst_0.gif" width=256 height=256 alt="" /> <h2>Proton Torpedo</h2> <p>Proton flight path is following <a href="https://en.wikipedia.org/wiki/Proportional_navigation">Proportional Navigation </a> rules. Gives a nice interception path (and the math is cool :)</p> <h2>3d Engine</h2> <p>Engine is a edge renderer (wireframe only as you certainly noticed!). It supports faces with an arbitrary number of edges to reduce visual cluter and achieve good performance.</p> <p>Face culling is using <a href="http://www.cubic.org/docs/backcull.htm"> object-space culling</a>, the normal.point constant is pre-calculated when model is loaded.</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/bench3d_0.gif" width=256 height=256 alt="" /> <p>Quaternions functions ported from <a href="https://github.com/rohitvarkey/three-js/blob/master/threejs/LICENSE">ThreeJS</a>.</p> <h2>3d Sound</h2> <p>(sort of...) Sound volume is changed at runtime according to sound emitter location, using the PICO-8 &quot;feature&quot; that sfx can be modified without impacting currently playing sound.<br /> Note: sfx 63 is reserved for that use.</p> <h2>Software Pipeline</h2> <p>3d assets are modeled in Blender, exported in sprite/map format using a <a href="https://github.com/freds72/pico8/blob/master/models/blender_export.py">Python exporter </a>.</p> <p>Models are unpacked from spritesheet/map memory at startup and made available in a global table.</p> <p>All game data are expressed as JSON strings, supporting references to global functions. Ex:</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> _g.update_player=function(self) self.x+=1 self.y+=0.5 end() local player=json_parse('{&quot;x&quot;:0,&quot;y&quot;:0,&quot;update&quot;:&quot;update_player&quot;}') -- works! player:update() </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Mini json parser from Tyler Neylon: <a href="https://gist.github.com/tylerneylon/59f4bcf316be525b30ab">lua JSON parser</a></p> <p>Code is minified using <a href="https://github.com/dansanderson/picotool">picotool</a>.<br /> Music lifted from &quot;public&quot; MIDI files, simplified and converted with <a href="https://github.com/gamax92/midi2pico">midi2pico</a>.</p> <h1>Changelog</h1> <p>1.0: </p> <ul> <li>Initial public version</li> <li>Bug: not able to restart after gameover (will be fixed soon)</li> </ul> <p>1.1:</p> <ul> <li>change: redone control scheme (flat turn, optional roll)</li> <li>change: removed boost</li> <li>change: laser auto lock</li> <li>change: difficulty curve</li> <li>fixed: NPC flight AI</li> <li>fixed: torpedo aiming</li> </ul> <p>1.2:</p> <ul> <li>added: menu to switch view</li> <li>changed: turret &amp; tie fire lead (+ random chance to miss)</li> <li>changed: tie fighter difficulty ramp up</li> <li>fixed: random hit on NPC (distance function overflow)</li> <li>fixed: reworked trench to keep 60 fps</li> <li>removed: in-game help</li> </ul> https://www.lexaloffle.com/bbs/?tid=31443 https://www.lexaloffle.com/bbs/?tid=31443 Sat, 23 Jun 2018 09:45:16 UTC How to correctly assert coroutines? <p>Hi,<br /> Coroutines are an essential part of my game engines.<br /> However, I don't get how I can do <strong>both</strong>:</p> <ul> <li>raise an error when something bad happens</li> <li>silently handle proper coroutine termination</li> </ul> <p>coresume returns a pair (is running,exception).<br /> Thing is exception is set even during normal termination!!<br /> note: costatus doesn't help as it immediately flips to &quot;dead&quot; when the coroutine crashes.</p> <p>Something like that doesn't work, e.g. I get an assert even after genuine termination:</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> local co function _init() co=cocreate(function() for i=1,10 do yield() end -- syntax error test -- i=k/10 end) end function _update() if co then local r,e=coresume(co) print(costatus(co)) if not r then if(e) assert(r,e) -- never reached co=nil 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> https://www.lexaloffle.com/bbs/?tid=31359 https://www.lexaloffle.com/bbs/?tid=31359 Sat, 02 Jun 2018 04:48:15 UTC ImpulseEngine Port <p> <table><tr><td> <a href="/bbs/?pid=52222#p"> <img src="/bbs/thumbs/pico52460.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=52222#p"> ImpulseEngine Port 1.3</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=52222#p"> [Click to Play]</a> </td></tr></table> </p> <p>As a temporary side project, I hastily ported <a href="https://github.com/RandyGaul/ImpulseEngine">Randy Gaul ImpulseEngine</a> to pico-8/LUA.</p> <p><img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/physics_done.gif" width=256 height=256 alt="" /> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/physics_menu.gif" width=256 height=256 alt="" /></p> <h1>Usage</h1> <p><em>Requires a mouse</em></p> <ul> <li>left mouse button: create a random shape at mouse cursor or drag shapes</li> <li>right mouse button: show/hide world or body options</li> <li>button c: show/hide debug information</li> </ul> <h1>Dev Log</h1> <p>The physic engine is a direct port from Randy Gaul's work, detailled in a series of articles:<br /> <a href="https://gamedevelopment.tutsplus.com/tutorials/how-to-create-a-custom-2d-physics-engine-the-basics-and-impulse-resolution--gamedev-6331">How to Create a Custom 2D Physics Engine</a></p> <p>My contribution is mostly on a clean 2d vector and 2x2 matrix object oriented library.<br /> It makes vector/matrix math very concise to work (and easy to port from C++ code!):</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> local v1,v2=vec(3,4),vec(5,6) local v3=v1+v2 -- rotation matrix local m=mat:make_r(0.4) local r=m*v3 </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Note: I don't plan to expand the library beyond this demo, feel free to make a game out of it!</p> <p>The cart now include a context menu that could be fairly easily reused for other carts.</p> <p><em>Missing Features:</em></p> <ul> <li>Optimisation pass (currently supports ~4/5 objects max)</li> </ul> <h1>Change Log</h1> <p>1.0:</p> <ul> <li>initial revision</li> </ul> <p>1.2:</p> <ul> <li>added: support for circles</li> </ul> <p>1.3:</p> <ul> <li>fixed: force reset</li> <li>changed: left click now creates a new body</li> <li>added: right click menu to control world or object settings</li> </ul> https://www.lexaloffle.com/bbs/?tid=31212 https://www.lexaloffle.com/bbs/?tid=31212 Tue, 01 May 2018 08:32:53 UTC AASteroids <p> <table><tr><td> <a href="/bbs/?pid=49676#p"> <img src="/bbs/thumbs/pico50248.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=49676#p"> AAsteroids 1.3</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=49676#p"> [Click to Play]</a> </td></tr></table> </p> <p><h1>Anti-Aliased Asteroids</h1></p> <p>Hastily crafted Asteroids clone complementary of the anti-aliased line thead:<br /> <a href="https://www.lexaloffle.com/bbs/?tid=30810">https://www.lexaloffle.com/bbs/?tid=30810</a></p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/aasteroids_vid2.gif" width=256 height=256 alt="" /> <p><h2>Changelog</h2><br /> 1.3:</p> <ul> <li>Added: Teleport ('c' button)! Up to 3 chances (sort of...) to get out of trouble</li> </ul> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/aasteroids_tp.gif" width=256 height=256 alt="" /> <ul> <li>Changed: inertia cranked up, use your thrusters!</li> <li>Changed: safe time is now 2s</li> <li>Changed: thrust is now 'up' only</li> <li>Fixed: Saucer Invasion!</li> </ul> <p>1.2:</p> <ul> <li>Fixed: incorrect font rendering</li> <li>Fixed: incorrect high score message on game over</li> <li>Changed: reduced number of rocks to 4</li> </ul> <p>1.1:</p> <ul> <li>Fixed: crash with dead player</li> <li>Changed: multiple rocks types</li> <li>Added: saucer!</li> <li>Added: highscore (saved in cart data)</li> <li>Added: multiple CRT effects (enjoy <a href="https://www.lexaloffle.com/bbs/?uid=12874"> <a href="https://www.lexaloffle.com/bbs/?uid=12874"> @Felice</a></a>!)</li> <li>Bug: couple of chars incorrectly rendered</li> </ul> <p>1.0f: temp. fix by <a href="https://www.lexaloffle.com/bbs/?uid=12874"> <a href="https://www.lexaloffle.com/bbs/?uid=12874"> @Felice</a></a> (tks!)</p> <p>1.0: initial release (did not work)</p> <p><h2>Tech. Details</h2></p> <p>Not much really - using bits of my Pico 8 &quot;game toolkit&quot;:</p> <ul> <li>anti-aliased circle fill (using mid-point error for the shading)</li> <li>multiple &quot;CRT&quot; shaders (find out how to switch between them!)</li> <li>a couple of future functions using yield</li> <li>vector font rendering</li> </ul> <p><h2>Credits</h2></p> <ul> <li>Felice: anti-aliased line optimisation genius!</li> <li>Trammell Hudson: Asteroids font (<a href="https://trmm.net/Asteroids_font">https://trmm.net/Asteroids_font</a>)</li> <li>Atari: for the art cover (my lawers are on the copyright case :)</li> </ul> https://www.lexaloffle.com/bbs/?tid=30837 https://www.lexaloffle.com/bbs/?tid=30837 Sun, 25 Feb 2018 17:01:04 UTC Anti-aliased lines &amp; circles <p> <table><tr><td> <a href="/bbs/?pid=49510#p"> <img src="/bbs/thumbs/pico49509.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=49510#p"> Anti-aliased lines 1.0</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=49510#p"> [Click to Play]</a> </td></tr></table> </p> <p>This cart is just to provoke <a href="https://www.lexaloffle.com/bbs/?uid=1"> @zep</a> (or any other true Pico-8 genius) into releasing a <strong>fast</strong> anti-aliasing demo cart!</p> <p>The code is a LUA port of that paper:<br /> <a href="http://jamesarich.weebly.com/uploads/1/4/0/3/14035069/480xprojectreport.pdf">http://jamesarich.weebly.com/uploads/1/4/0/3/14035069/480xprojectreport.pdf</a></p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/aaline_vid.gif" width=256 height=256 alt="" /> <p>Note: I don't get how an incremental line drawing routine (a la Bresenham) can be that slow (compared to the native version). 270% cpu usage for 16 lines <em>sigh...</em></p> https://www.lexaloffle.com/bbs/?tid=30810 https://www.lexaloffle.com/bbs/?tid=30810 Thu, 22 Feb 2018 15:16:22 UTC Nuklear Klone <p> <table><tr><td> <a href="/bbs/?pid=48516#p"> <img src="/bbs/thumbs/pico50452.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=48516#p"> Nuklear Klone 1.2</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=48516#p"> [Click to Play]</a> </td></tr></table> </p> <p>Suzie and Bob are trapped in a merciless world. Can you fight your way out?</p> <p><img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_input_select.gif" width=256 height=256 alt="" /> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_gameplay.gif" width=256 height=256 alt="" /></p> <p><h2>Gameplay Elements</h2></p> <ul> <li>Random maps</li> <li> <p>Multiple biomes<br /> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_desert.png" width=96 height=96 alt="" /> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_sewers.png" width=96 height=96 alt="" /> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_snowplains.png" width=96 height=96 alt="" /> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_lab.png" width=96 height=96 alt="" /> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_palace.png" width=96 height=96 alt="" /></p> </li> <li>Multiple enemies</li> <li>Multiple weapons (but one at a time!)</li> <li>Loop-based difficulty</li> <li>Supports keyboard/mouse</li> </ul> <p><h2>Controls</h2><br /> Keyboard:</p> <ul> <li>arrow keys: move &amp; gun direction</li> <li>bttn 1: fire &amp; lock direction</li> <li>bttn 2: pick up weapon</li> </ul> <p>Mouse (<em>selected in option menu</em>):</p> <ul> <li>arrow keys: move</li> <li>mouse: gun direction</li> <li>left click: fire</li> <li>right click: pick up weapon</li> </ul> <p><em>Note: any resemblance with a famous Vlambeer game must be purely accidental...</em></p> <p><h2>Changelog</h2><br /> 1.2:</p> <ul> <li>fixed: woobly sprites</li> <li>fixed: actors stuck on corners</li> <li>fixed: warp in/out effect</li> <li>changed: impact feedback</li> <li>changed: health upgrade on loop</li> </ul> <p>1.1:</p> <ul> <li>fixed: unexpected god mode</li> <li>fixed: boss hp</li> <li>fixed: boss attack</li> <li>changed: tweaked game speed</li> <li>change:balanced high level gameplay (loop)</li> </ul> <p>1.0: </p> <ul> <li>preview version</li> </ul> <p><h2>Dev Log</h2><br /> 2nd finished game (last was Thunderblade). Took 4 months to complete &amp; refine.<br /> Un-minified source available on Github:<br /> <a href="https://github.com/freds72/pico8/blob/master/carts/nuke.p8">freds72/pico8/carts/nuke.p8</a></p> <p><strong>Tech Highlights</strong><br /> <span style="text-decoration: underline;">JSon Rules!</span><br /> All entities (actors, weapons, particles, levels) defined using json (worth <strong>3500</strong> tokens!). A lightweight parser (450 tokens) converts strings into lua tables.</p> <p>Entities are created using a parent template with support for: </p> <ul> <li>lua references</li> <li>random values</li> <li>method &amp; attributes override</li> </ul> <p><span style="text-decoration: underline;">Rotating Sprites</span><br /> Player weapon (and couple of other sprites) are rotated in real-time using an optimized sprite routine. It is fast enough to allow ~10+ sprites on screen (before tanking FPS!)</p> <p><span style="text-decoration: underline;">Performance</span><br /> An actor map is maintained each frame. It allows immediate bullet/actors lookup.<br /> Only player/npc collisions are checked to ensure player cannot zip through enemies.</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/nuke_cmap.gif" width=256 height=256 alt="" /> <p>A-* path is refreshed for a single npc per frame. It ensures a large number of npc�s can be created without too much cpu stress.</p> <p>Sprites are added to buckets matching their y pixel coordinate.<br /> Saves both cpu and tokens as no global sort is required :]</p> <p><span style="text-decoration: underline;">Toolchain</span><br /> Cart is minified using picotool (19k compressed). All json attributes are replaced by their short equivalent using output from minification script:<br /> cat nuke.p8 | minify | replace &gt; nuke_mini.p8</p> <p><strong>Missing In Action</strong>:</p> <ul> <li>RPG aspects (upgrades/xp/abilities...)</li> <li>Good music (for total lack of musical skills!!)</li> <li>Scoreboard</li> </ul> <p><strong>Credits</strong></p> <ul> <li>Tyler Neylon: <a href="https://gist.github.com/tylerneylon/59f4bcf316be525b30ab">lua JSON parser</a></li> <li>James Coonradt (<a href="https://www.lexaloffle.com/bbs/?uid=11513"> @gamax92</a>): <a href="https://github.com/gamax92/midi2pico">midi2pico</a></li> <li>Jakub Wasilewski (<a href="https://www.lexaloffle.com/bbs/?uid=12861"> @krajzeg</a>): <a href="https://hackernoon.com/pico-8-lighting-part-1-thin-dark-line-8ea15d21fed7">Lighting by hand: the thin dark line</a> serie</li> <li>Dan Sanderson: <a href="https://github.com/dansanderson/picotool">picotool minify</a></li> <li>collide sample by <a href="https://www.lexaloffle.com/bbs/?uid=1"> @zep</a></li> <li>Vlambeer</li> </ul> https://www.lexaloffle.com/bbs/?tid=30652 https://www.lexaloffle.com/bbs/?tid=30652 Wed, 24 Jan 2018 15:49:40 UTC [rant] readability:0/compressed size:1 <p>While playing with the very handy picotool utility, I discovered that simply removing tabs on my well formatted code I was able to save <strong>813 compressed bytes</strong>!!!</p> <p>Seriously???</p> <p>I've spent days trying to remove code, reshuffle stuff to save 50-100 bytes and simply making my code unreadable beats any of these optimizations?? </p> <p>:_[</p> https://www.lexaloffle.com/bbs/?tid=30223 https://www.lexaloffle.com/bbs/?tid=30223 Thu, 09 Nov 2017 16:07:09 UTC Where is 0.1.11c PocketCHIP version? <p>I can get Windows, Linux and Raspberry updates but what about PocketCHIP?<br /> My mobile development platform can no longer run a lot of the newly published games :[</p> https://www.lexaloffle.com/bbs/?tid=30215 https://www.lexaloffle.com/bbs/?tid=30215 Wed, 08 Nov 2017 16:50:25 UTC Thunder Blade (well, level 1 at least...) <p> <table><tr><td> <a href="/bbs/?pid=44889#p"> <img src="/bbs/thumbs/pico44887.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=44889#p"> Thunder Blade (well, level 1 at least...) 1.0</a><br><br> by <a href="/bbs/?uid=25532"> freds72</a> <br><br><br> <a href="/bbs/?pid=44889#p"> [Click to Play]</a> </td></tr></table> </p> <p>Back 30 years ago, After Burner and Thunderblade ruled the arcades.<br /> As a kid, I only had an Amiga and near zero coding skills to produce very (<span style="text-decoration: underline;">very</span>) weak clones.<br /> Now a seasoned programmer with the mighty power of PICO-8, I can beat a Sega X board!<br /> Well, err...:</p> <img style="" border=0 src="https://www.lexaloffle.com/bbs/files/25532/Thunderblade Teaser.gif" width=256 height=256 alt="" /> <p><strong>Credits</strong><br /> � Chris Butler (player + tank sprites lifted from the C64 1989 version)<br /> � gamax92 for midi to pico-8 program<br /> � dw817 (david w) for image decompression code (<a href="http://writerscafe.org/dw817">http://writerscafe.org/dw817</a>)<br /> � pico-8 community</p> <p><strong>What's Missing</strong><br /> � gameplay tweaking...<br /> � levels 2,3,4,5<br /> � gazillions of buildings on screen!</p> <p><strong>Tech Details</strong></p> <p>Map:<br /> Drawn using sprite sheet (2), you can tweak the level using colors:<br /> 4: tank<br /> 6,7,13: building<br /> 8: enemy helicopter<br /> 9: Battleship boss<br /> 10: swtich to chase mode<br /> 11: switch to top-down mode<br /> 15: end_game (use carrefully!)</p> <p>Title screen:<br /> Title image is loaded from a stringified image, decompression done 'asynchronously' with yield.</p> <p>Main screen:</p> <p>Buildings are mostly drawn with many rectfill using a big checkerboard pattern to simulate windows/floors.</p> <p>Everything is z-sorted (w actually ;) before being drawn. This 'zbuffer' is in charge of drawing every asset.</p> <p>Game screen manager:<br /> A light version of what I've extensively used during my XNA period. Allows nice decoupling between game loop and other loops (title, game over).</p> <p>Coroutines:<br /> Used only for rare events (like player dying) to easily control animation and state changes.</p> <p><strong>Lessons Learned</strong><br /> � PICO-8 is a fantastic platform. Forces you to keep things simple (say that to my dozen or so failed Unity attempts...)<br /> � token count is everything<br /> � Coroutines are unfortunately too slow to be used in the core game loop<br /> � Throw OOP techniques out. The nice class:method() construct eats up too many tokens - had to rewrite half of the code to stays within the limits :[<br /> � bnot-cheating the platform is way too easy (but resisted against!)<br /> � Did I say token count is everything?</p> https://www.lexaloffle.com/bbs/?tid=30030 https://www.lexaloffle.com/bbs/?tid=30030 Tue, 03 Oct 2017 16:02:57 UTC