yaky [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=65754 Rotate part of a map <p>While making a top-down map for my game, I needed to arrange some of its parts to fit better together, which required rotating some sections. Since PICO-8 does not provide a way to rotate a map selection, I wrote a simple utility function to do that.</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="/media/65754/untitled_4_1.gif" alt="" /> <p>This function rotates a square section of the map clockwise.<br /> MX and MY are the map X and Y coordinates of the upper left corner, and MS is the length of the square side - 1 (e.g. to rotate an 8x8 square, set MS=7)</p> <p>Notes:</p> <ul> <li>Make sure that you do not modify the map in any way before you call the rotate function, or the in-memory changes will be written to the cart</li> <li>Uncomment the second CSTORE (or edit the to edit the lower portion of the map</li> <li>This function is not optimized and is not intended for frequent use (unless you are making some gravity-based platformer, I suppose...) </li> </ul> <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>-- rotate a square section -- of a map clockwise function rotate_map(mx,my,ms) -- read tiles local tiles={} for x=0,ms do tiles[x]={} for y=0,ms do tiles[x][y]= mget(mx+x,my+y) end end -- write tiles for x=0,ms do for y=0,ms do local tx=y local ty=mx+ms-x mset(mx+x,my+y,tiles[tx][ty]) end end cstore(0x2000,0x2000,0x1000) -- to edit extended map, uncomment --cstore(0x1000,0x1000,0x1000) 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=143776 https://www.lexaloffle.com/bbs/?tid=143776 Fri, 23 Aug 2024 00:07:58 UTC Dark Streets Tech Demo 1 <p> <table><tr><td> <a href="/bbs/?pid=142236#p"> <img src="/bbs/thumbs/pico8_dark_streets_tech_demo_1-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=142236#p"> Dark Streets Tech Demo 1</a><br><br> by <a href="/bbs/?uid=65754"> yaky</a> <br><br><br> <a href="/bbs/?pid=142236#p"> [Click to Play]</a> </td></tr></table> </p> <h1>Dark Streets Tech Demo 1</h1> <p>Hi all! Dark Streets is a first-person shooter, mechanically most similar to Wolfenstein 3D or Blake Stone, but also inspired by Doom, Blood, and Ion Fury. I have been slowly developing this game in my free time over the last year and a half. I referenced LoDev and a paper by Amanatides and Woo for some of the raycasting steps, but the rest of the code and graphics are mine. Enjoy a small preview!</p> <h2>Raycasting renderer</h2> <p>Since the setting of the game is a city, I specifically wanted to write a renderer that could draw tall buildings, short objects, doors, and interiors. I think I am pretty close.</p> <ul> <li>Pretty performant: Everything below takes up only 50-60% of CPU, unless you go crazy with geometry and distances.</li> <li>Fixed camera height: This makes walls look better. Originally, I had variable camera height and headbob, but that made textures a bit too jagged.Might reconsider based on performance later.</li> <li>Variable brightness: Based on distance, using draw palettes.</li> <li>Floor textures: Pretty basic, using horizontal TLINE</li> <li>Multiple floors! Normally, I see raycasters render just one floor (Caped Feline Arena and Anarch are notable exceptions), so this is a bit unusual, and it allows more interesting designs.</li> <li>Ceilings. Although texture-less, ceilings are rendered separately from the sky, and allow for features such as archways, underpasses, and building interiors.</li> <li>Animated doors: They are also rendered halfway on the tile to stand out from the walls.</li> <li>Z-buffer and clipped sprites: This piece is not very efficient yet, but works pretty well.</li> </ul> <h2>Gameplay</h2> <p>You can walk around, open doors, pick up and fire weapons (but can't defeat the enemies yet).</p> <ul> <li>Variety of objects: Solid obstacles, ceiling decor (can be walked under), floor decor (cannot be walked through, but can be shot over)</li> <li>Five weapons: Infinite pistol, shotgun, Gatling gun, flamethrower, and a rocket launcher (unfinished). </li> <li>One large level, hoping to keep it like that for final game. Might not be possible with number of objects per level.</li> <li>Health and weapon pickups.</li> <li>Weapon switching: When picking up a new weapon and when running out of ammo.</li> <li>Enemies: Basic move-aim-fire behavior, in beginning stages.</li> </ul> <h2>Known issues</h2> <ul> <li>Looking through open doors is slow. This is due to calculations on which vertical slice must be rendered for the door on each ray.</li> <li>Adding many objects will slow the game down a lot, due to many visibility and collision calculations.</li> </ul> <h2>Thanks</h2> <p>Big thanks to other PICO-8 first-person games for motivation:</p> <ul> <li>Trial of the Sorcerer</li> <li>Caped Feline Arena</li> <li>Star Beast</li> <li>Whiplash Taxi Co</li> </ul> https://www.lexaloffle.com/bbs/?tid=140457 https://www.lexaloffle.com/bbs/?tid=140457 Fri, 01 Mar 2024 01:17:10 UTC