Tw1zTeD616 [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=101688 Enemy movement help <p>I'm working on my 2nd official project, watching tutorials and self-teaching (not the best idea, I know.) I'm trying to do a very simple adventure style game for my wife to play, and I'd like any enemies that I place on the map to only move when the player is onscreen with them. I'm obviously not thinking this through thoroughly. Any help would be appreciated. I apologize for the code snippets I included, I'm still learning the formatting for the message board</p> <p> <table><tr><td> <a href="/bbs/?pid=154278#p"> <img src="/bbs/thumbs/pico8_jirjawra-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=154278#p"> jirjawra</a><br><br> by <a href="/bbs/?uid=101688"> Tw1zTeD616</a> <br><br><br> <a href="/bbs/?pid=154278#p"> [Click to Play]</a> </td></tr></table> </p> <p>function draw_map()</p> <p>--map screen x,y in tiles<br /> --follows player<br /> mapx=flr(p.x_tile/16)<em>16<br /> mapy=flr(p.y_tile/16)</em>16</p> <p>--camera and hud x,y<br /> cx=mapx<em>8<br /> cy=mapy</em>8</p> <p>--bound camera within game area<br /> if (cx&lt;=0) cx=0<br /> if (cy&lt;=0) cy=0<br /> if (cx&gt;=1024) cx=1024<br /> if (cy&gt;=512) cy=512<br /> map()<br /> camera(cx,cy)</p> <p> draw_hud()<br /> end</p> <p>function move_enemies()</p> <p> for e in all(enemies) do<br /> --priorty one <br /> --restrict offscreen enemy<br /> --movement...debug needed <br /> if mapx!=flr(e.x_tile/16)<em>16 or mapy!=flr(e.y_tile/16)</em>16 then<br /> return<br /> else<br /> --x,y for movement <br /> e.e_newx=e.x_tile<br /> e.e_newy=e.y_tile</p> <p> interact(e.e_newx,e.e_newy)</p> <p> if e.etype==&quot;beetle&quot; then<br /> --random move variable<br /> local r=flr(rnd(4)+1)<br /> --checks for bamboo and<br /> --&quot;eats&quot; it<br /> if check_tile(bamboo,e.x_tile-1,e.y_tile) then<br /> move_left(e)<br /> swap_tile(e.e_newx,e.e_newy)<br /> elseif check_tile(bamboo,e.x_tile+1,e.y_tile) then<br /> move_right(e)<br /> swap_tile(e.e_newx,e.e_newy)<br /> elseif check_tile(bamboo,e.x_tile,e.y_tile-1) then<br /> move_up(e)<br /> swap_tile(e.e_newx,e.e_newy)<br /> elseif check_tile(bamboo,e.x_tile,e.y_tile+1) then<br /> move_down(e)<br /> swap_tile(e.e_newx,e.e_newy)<br /> else<br /> --if no bamboo then moves in<br /> --a random direction<br /> if r==1 then<br /> move_left(e)<br /> elseif r==2 then<br /> move_right(e)<br /> elseif r==3 then<br /> move_up(e)<br /> elseif r==4 then<br /> move_down(e)<br /> end <br /> end <br /> end</p> <p>--bind enemies on map and set<br /> --offset for wall collision<br /> if can_move(e.e_newx,e.e_newy) then<br /> e.x_tile=mid(mapx,e.e_newx,mapx+15)<br /> e.y_tile=mid(mapy,e.e_newy,mapy+15)<br /> else<br /> e.off_x=e.off_x/4<br /> e.off_y=e.off_y/4<br /> sfx(0)<br /> end<br /> end <br /> end <br /> end</p> https://www.lexaloffle.com/bbs/?tid=144253 https://www.lexaloffle.com/bbs/?tid=144253 Sun, 15 Sep 2024 17:06:48 UTC Defender of Coryx VII <p>I found Pico-8 a few months ago (I've been living under a rock), and I've been having a blast learning it's particular brand of Lua. After nights and weekends of watching <a href="https://www.lexaloffle.com/bbs/?uid=16423"> @Krystman</a>'s Beginner Shmup Tutorial, this is the result. The code is clunky and not optimized at all, but I feel it's a &quot;minimum viable product&quot;. Let me know what you think. Any advice is greatly appreciated.</p> <h2>Changelog:</h2> <pre><code> -Updated Sidewinder enemy behavior -Fixed Fly enemy spawning locations so they no longer overlap -Added text indicators for random enemy spawns (investigating less intrusive replacement) -Minor bug fixes </code></pre> <h2>Defender of Coryx VII</h2> <p>The Va'nals Empire is sweeping through the galaxy, conquering system after system with their fleet of vat-grown bio-mechanical spacecraft. The peaceful people of Coryx VII have never known conflict or war, and are woefully unprepared to face the Va'nals' threat. In a last ditch effort, the greatest minds of Coryx VII gathered together and created the prototype starship X2-SLP &quot;Slipstream&quot;, to be piloted by a brave volunteer. Drawing its power from the dreaded bio-mech ships themselves, the Slipstream may be the people of Coryx VII's only hope. Take the controls of the Slipstream, and defend your people!</p> <p> <table><tr><td> <a href="/bbs/?pid=153631#p"> <img src="/bbs/thumbs/pico8_coryxvii-3.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=153631#p"> coryxvii</a><br><br> by <a href="/bbs/?uid=101688"> Tw1zTeD616</a> <br><br><br> <a href="/bbs/?pid=153631#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=144001 https://www.lexaloffle.com/bbs/?tid=144001 Mon, 02 Sep 2024 00:02:26 UTC Lazy Devs Shmup Tutorial <p>I've been following the basic shmup tutorial from <a href="https://www.lexaloffle.com/bbs/?uid=16423"> @Krystman</a> and Lazy Devs (with some adjustments) to try and learn some more of the basics in Pico 8 and Lua and game development in general after pretty much failing miserably at my first game attempt (still working on it tho.) Before finalizing enemy behavior and the spawning (my difficulty is still wildly inconsistent), I wanted to work on the boss explosion, but I've run into a bug I can't seem to figure out. I can't get the timer to delete the boss after the cool explosions to actually count down. I've set the boss HP low and the wave to the final one for testing if anyone can help me out understanding what I've done wrong here. I'd also appreciate any advice anyone has regarding creating a proper scaling difficulty.</p> <p> <table><tr><td> <a href="/bbs/?pid=153072#p"> <img src="/bbs/thumbs/pico8_coryxvii-1.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=153072#p"> coryxvii</a><br><br> by <a href="/bbs/?uid=101688"> Tw1zTeD616</a> <br><br><br> <a href="/bbs/?pid=153072#p"> [Click to Play]</a> </td></tr></table> </p> <p>I've uploaded the current version for playtesting. I'd appreciate any feedback on how to improve difficulty scaling while still somewhat maintaining the RNG feel.</p> https://www.lexaloffle.com/bbs/?tid=143802 https://www.lexaloffle.com/bbs/?tid=143802 Thu, 22 Aug 2024 04:42:33 UTC Help with player movement after updating the map <p> <table><tr><td> <a href="/bbs/?pid=151824#p"> <img src="/bbs/thumbs/pico8_tadizihoma-0.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=151824#p"> balloon_game</a><br><br> by <a href="/bbs/?uid=101688"> Tw1zTeD616</a> <br><br><br> <a href="/bbs/?pid=151824#p"> [Click to Play]</a> </td></tr></table> I'm having trouble with my player movement after my map updates. My map seems psuedo-randomize after the 1st screen like I want (I can tinker and fix this later). The trouble I'm having is that my player won't continue moving upwards after the map redraws and resets your position. Essentially every screen seems to treat the lower half as if it's the first screen ie running the collision detection on sprites that don't seem to be there. I'm stumped. Any help would be much appreciated.</p> https://www.lexaloffle.com/bbs/?tid=143329 https://www.lexaloffle.com/bbs/?tid=143329 Sat, 27 Jul 2024 00:55:38 UTC Collision detection is working on only three sides <p>Like the title says, I have rudimentary collision detection on the top and sides of my sprite but not on the bottom.<br /> I'm very new to game dev, but I have some experience in python. I can't see if I have a typo, or I've made a mistake in following the tutorial I watched. </p> <p>--player--<br /> function create_player()<br /> player={<br /> state=&quot;normal&quot;,<br /> sprite=1,<br /> health=4, <br /> x=64,<br /> y=82,<br /> h=8,<br /> w=8,<br /> gravity=0.30,<br /> friction=0.15,<br /> inertia=0,<br /> thrust=0.80<br /> } <br /> end</p> <p>function collide(o)</p> <p> local x1=o.x/8<br /> local y1=o.y/8<br /> local x2=(o.x+7)/8<br /> local y2=(o.y+7)/8</p> <p> local a=fget(mget(x1,y1),0)<br /> local b=fget(mget(x1,y2),0)<br /> local c=fget(mget(x2,y2),0)<br /> local d=fget(mget(x2,y1),0)</p> <p> if a or b or c or d then<br /> return true<br /> else<br /> return false<br /> end<br /> end</p> <p>function move_player(o)<br /> o.y+=o.gravity --applies player gravity</p> <p> local lx=o.x --last x pos<br /> local ly=o.y --last y pos</p> <p> if (btn(❎)) o.y-=o.thrust --player move<br /> if (btn(⬅️)) o.x-=0.5<br /> if (btn(➡️)) o.x+=0.5 </p> <p>--if the player collides, moves back </p> <p> if collide(o) then<br /> o.x=lx<br /> o.y=ly<br /> end<br /> end</p> <p>function ani_player(o) <br /> if btn(⬅️) then --player animation<br /> o.sprite=2<br /> elseif btn(➡️) then<br /> o.sprite=3<br /> else<br /> o.sprite=1<br /> end<br /> end </p> <p>function draw_sprite(o)<br /> spr(o.sprite,o.x,o.y)<br /> end</p> https://www.lexaloffle.com/bbs/?tid=143293 https://www.lexaloffle.com/bbs/?tid=143293 Wed, 24 Jul 2024 04:54:02 UTC Pico 8 Noob question re: level design <p>Sorry if this is a completely dumb question. I'm new to Pico 8 and game dev in general. I'm stuck in my first project attempting to randomize map layouts. My game is a simple vertical scrolling game where the player moves from side to side to avoid obstacles. I'd like to begin on one screen, and then end on a final screen with the ones in between being a random selection from the 12 or so other screens I've drawn. I know the easiest way to do this is probably with nested tables, but I'm having trouble understanding how I could accomplish this. Any help would be awesome.</p> https://www.lexaloffle.com/bbs/?tid=143255 https://www.lexaloffle.com/bbs/?tid=143255 Mon, 22 Jul 2024 00:06:31 UTC