Saccharine [Lexaloffle Blog Feed]https://www.lexaloffle.com/bbs/?uid=12981 fireworks in less 200 tokens <p> <table><tr><td> <a href="/bbs/?pid=23400#p"> <img src="/bbs/thumbs/pico23399.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=23400#p"> fireworks 1.0</a><br><br> by <a href="/bbs/?uid=12981"> Saccharine</a> <br><br><br> <a href="/bbs/?pid=23400#p"> [Click to Play]</a> </td></tr></table> </p> <p>Fireworks simulation in less 200 tokens !</p> https://www.lexaloffle.com/bbs/?tid=3668 https://www.lexaloffle.com/bbs/?tid=3668 Tue, 21 Jun 2016 15:18:34 UTC breakout <p> <table><tr><td> <a href="/bbs/?pid=23015#p"> <img src="/bbs/thumbs/pico23013.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=23015#p"> breakout 0.9</a><br><br> by <a href="/bbs/?uid=12981"> Saccharine</a> <br><br><br> <a href="/bbs/?pid=23015#p"> [Click to Play]</a> </td></tr></table> </p> <p>x starts a new game </p> <p>There are some known issues :</p> <ul> <li>the ball is a 2x2 square but only the upper left pixel is used to detect collisions with the bricks</li> <li>hitting x the next seconds after losing a ball resets the game </li> <li>bounces on bricks doesn't work as expected in rare cases</li> <li>in the original game, hitting particular colors speeds up the ball - not here</li> </ul> <p>Enjoy</p> https://www.lexaloffle.com/bbs/?tid=3620 https://www.lexaloffle.com/bbs/?tid=3620 Thu, 16 Jun 2016 16:18:05 UTC enlarge your text ... <p>I initially just wanted to display a large text for a title screen... and I ended with this.</p> <p> <table><tr><td> <a href="/bbs/?pid=22891#p"> <img src="/bbs/thumbs/pico22890.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=22891#p"> Text Effects 1.0</a><br><br> by <a href="/bbs/?uid=12981"> Saccharine</a> <br><br><br> <a href="/bbs/?pid=22891#p"> [Click to Play]</a> </td></tr></table> </p> <p>use:<br /> left and right to control the scrolling speed (two ways)<br /> up and down to control the wave frequency</p> <p>call <strong>scan_text()</strong> at the beginning of your program : it clears the screen twice<br /> you can add your own effects very easily into <strong>put_sintext()</strong> - the existing five ones should help </p> https://www.lexaloffle.com/bbs/?tid=3606 https://www.lexaloffle.com/bbs/?tid=3606 Tue, 14 Jun 2016 18:59:41 UTC Managing scores &gt; 32768 and prepending it with zeros <p>For your games, you could have to manage a score greater than 32768 (I like games were I can score millions), and often, you want the score displayed in a fixed length, prepended with zeros (00072635).<br /> But managing this can consume lot of tokens.</p> <p>I came accros a solution I'm quite proud (I'm still learning Lua...) and wanted to share.</p> <p>In Lua, if you do : <strong> &quot;the score is &quot;..score </strong>, score is converted into a string and then concatenated to the first one.<br /> So to convert a number into a string, you just have to write : <strong>''&quot;..score</strong> </p> <p>I wrote a recursive function that takes a string and a number (the length) and returns a string padded with zeros at its beginning to reach the desired length :</p> <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> function pad(string,length) if (#string==length) return string return &quot;0&quot;..pad(string, length-1) end score=723 print(pad(&quot;&quot;..score,7)) -- will display 0000723 </pre></div></td> <td background=/gfx/code_bg1.png width=16><div style="width:16px;display:block"></div></td> </tr></table></div></div> <p>Elegant and thrifty, isn't it ?</p> <p>Then, you can use two variables, score2 will store the 10 thousands, score1 anything under 10000<br /> each time your player scores something, you add it to score1 and you test if it's above 9999 :</p> <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> if score1&gt;9999 then score1-=9999 score2+=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>Be sure the max score won't never be above 327689999 ... or manage it with a score3 variable</p> <p>Here is the concept in action - score2 is displayed in orange, score1 in red:</p> <p> <table><tr><td> <a href="/bbs/?pid=22780#p"> <img src="/bbs/thumbs/pico22779.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=22780#p"> padding large numbers 1.0</a><br><br> by <a href="/bbs/?uid=12981"> Saccharine</a> <br><br><br> <a href="/bbs/?pid=22780#p"> [Click to Play]</a> </td></tr></table> </p> https://www.lexaloffle.com/bbs/?tid=3595 https://www.lexaloffle.com/bbs/?tid=3595 Sun, 12 Jun 2016 18:49:33 UTC roland garros <p> <table><tr><td> <a href="/bbs/?pid=21421#p"> <img src="/bbs/thumbs/pico21415.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=21421#p"> roland garros 1.0</a><br><br> by <a href="/bbs/?uid=12981"> Saccharine</a> <br><br><br> <a href="/bbs/?pid=21421#p"> [Click to Play]</a> </td></tr></table> </p> <p>Today I was watching Roland Garros on the TV when I figured I would waste less my time playing with PICO-8 and so I did ... another pong.</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/12981/roland garros.gif" width=256 height=256 alt="" /> <p>The code is quite simple and should help beginners starting with PICO-8 programming </p> <p>It supports different bouncing angles - I store them in a table for each pixel of the paddle (8 pixels high) :</p> <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> angles={-1.2,-0.8,-0.5,-0.2,0.2,0.5,0.8,1.2} ... b.dy=angles[flr(b.y-p1y)+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>At first, player2 (p2) was always following the ball and was unbeatable... so I modified it to only follow the ball when it is in the right half of the screen - I found this solution giving a good difficulty level - you can raise it if you increase the area where it &quot;sees&quot; the ball :</p> <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> -- p2 follows the ball, only if the ball is on the right side of the screen if (b.x&gt;64 and p2y+4&gt;b.y ) p2y-=1 if (b.x&gt;64 and p2y+4&lt;b.y ) p2y+=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>Enjoy !</p> https://www.lexaloffle.com/bbs/?tid=3459 https://www.lexaloffle.com/bbs/?tid=3459 Thu, 26 May 2016 18:47:12 UTC until death <p> <table><tr><td> <a href="/bbs/?pid=21243#p"> <img src="/bbs/thumbs/pico21242.png" style="height:256px"></a> </td><td width=10></td><td valign=top> <a href="/bbs/?pid=21243#p"> Until Death 1.0</a><br><br> by <a href="/bbs/?uid=12981"> Saccharine</a> <br><br><br> <a href="/bbs/?pid=21243#p"> [Click to Play]</a> </td></tr></table> </p> <p>I was playing with the sprite editor, and found my creatures nice enough to make a game.<br /> I'm still focused on my lode runner project, so I wanted to keep it short and simple.<br /> this won't be the game of the year, and to give it a use, I did my best to document the code so eventually it can help beginners.</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/12981/until death.gif" width=256 height=256 alt="" /> <p>the game is simple (boring ?) - fire and hit a max. of alien before you die<br /> but there's room to improve it :</p> <ul> <li>increase the difficulty by adding new aliens every 10 points </li> <li>move the aliens in direction of the player when it is at a certain range<br /> ...</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> function new_alien() a={} -- a new alien is allocated a.x=rnd(120) -- aliens appear on the top 1/3 of the screen a.y=rnd(40) a.spr=flr(rnd(6))+2 -- and can be of any of the 6 alien sprites a.dx=rnd(4)-2 -- direction and speed is random a.dy=rnd(5)-2 -- but more often going down than up add(aliens,a) -- the new alien is added to our list of aliens end function _init() -- called once at the start of the programm x=60 -- player's fighter initial position y=100 hold_fire=0 -- used prevent continuous fire score=0 best=0 -- the high score bullets={} -- list of active bullets aliens={} -- the list of aliens for i=1,20 do new_alien() end -- creates 20 aliens cls() -- clear the screen print(&quot;saccharine&quot;,44,38,7) -- and displays a title screen print(&quot;PRESENTS&quot;,48,48,6) print(&quot;until death&quot;,43,58,8) print(&quot;x start&quot;,50,98,6) while not btn(5) do end -- waits for x key to be pressed end function _draw() cls() -- clear the screen spr(1,x,y) -- displays player's fighter sprite for a in all(aliens) do -- for each alien, a.x+=a.dx -- calculate its new position a.y+=a.dy if a.x&gt;0 and a.y&gt;0 and a.x&lt;127 and a.y&lt;127 then -- if alien is still inside the screen spr(a.spr,a.x,a.y) -- displays it if a.x+2&gt;=x and a.x+2&lt;=x+7 and a.y+2&gt;=y and a.y+2&lt;=y+8 then -- alien collision with fighter del(aliens,a) -- remove the alien from the list of aliens (we won't display it anymore) new_alien() -- and replace it by a new one so that the number of aliens is always the same sfx(2) -- louder crash sound than for the aliens x=60 -- respwan y=100 bullets={} -- clears all active bullets score=0 -- start over end else del(aliens,a) -- alien leaved the screen, delete it new_alien() -- and replace it by a new one end end for b in all(bullets) do -- parsing each active bullet b.y-=3 -- move it up if b.y&lt;0 then -- the bullet exits the top of the screen del(bullets,b) -- we remove it from the list of active bullets else if pget(b.x,b.y)!=0 then -- if it hits something del(bullets,b) -- we delete it sfx(1) -- alien explosion score+=1 for a in all(aliens) do -- search which alien we killed if a.x&lt;=b.x and a.x+5&gt;=b.x and a.y&lt;=b.y and a.y+4&gt;=b.y then del(aliens,a) -- delete it new_alien() -- and replace it by a new one end end else pset(b.x,b.y,7) -- displays the bullet pset(b.x,b.y+1,8) -- and a red dot behind it end end end if (score&gt;best) best=score -- displays updated high score, and current score print(best,0,0,6) print(score,0,8,6) end function _update() if (btn(0) and x&gt;0 ) x-=2 -- going left if (btn(1) and x&lt;120) x+=2 -- right if (btn(2) and y&gt;50 ) y-=2 -- up if (btn(3) and y&lt;120) y+=2 -- down hold_fire+=1 -- increases the timer 30 times per second if (btn(4) or btn(5)) and hold_fire&gt;8 then -- allowed to fire again sfx(0) add(bullets,{x=x+1,y=y}) -- left gun add(bullets,{x=x+5,y=y}) -- right gun hold_fire=0 -- the timer is reset to zero, so we have end -- to wait it reaches 9 to fire again 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>read the code, make it yours, improve the game, show off your changes and explain how you did<br /> ... or beat the score</p> https://www.lexaloffle.com/bbs/?tid=3437 https://www.lexaloffle.com/bbs/?tid=3437 Tue, 24 May 2016 08:58:20 UTC Let's remake a Lode Runner <p>I discovered PICO-8 four days ago after reading a news in The Verge about the upcoming PocketCHIP. I purchased a license (the voxatron bundle) to see what it was about and since I can't stop playing with and the numerous games / demos.</p> <p>I looked at some code, read some posts on the forum and thought it could be even more funny to code.</p> <p>So I decided to start with a Lode Runner remake as my first program.<br /> It might be a bit ambitious as it's been almost 15 years I haven't coded anything serious but I have some time and I'm decided to learn. </p> <p>It's still at the very early stages, I managed to fit the first level into to 128x128 and draw the sprites set :</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/12981/sprites.PNG" width=396 height=397 alt="" /> <p>and I can display them together :</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/12981/running.PNG" width=396 height=395 alt="" /> <p>But that's it for now... </p> <p><strong>Part 2</strong></p> <p>Today, after a long weekend, I'm back to PICO-8 devellopement.<br /> Lode Runner runs !</p> <img loading="lazy" style="margin-bottom:16px" border=0 src="https://www.lexaloffle.com/bbs/files/12981/running.gif" width=256 height=256 alt="" /> <p>I had some trouble with transparency - looks like sprite 0 has to be blank (?) - not sure how flip() really works ... there must be a better way to refresh the screen than :</p> <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> function _draw() rectfill (0,0,127,119,0) map(0,0,0,0,16,16) spr(runner.sprite,runner.x,runner.y) 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>Moving my main sprite has been a source of satisfaction. I still need to sync the speed but it already looks nice to me.</p> <p>The most difficult has been with the colision detection. It works but I'm not happy with my code.<br /> the actor's states are far more complex than I initially thought<br /> I should have think a bit more before diving into the code and now I think it would be better to restart from scracth before going too far.</p> <p>That's the way you learn ;-)</p> https://www.lexaloffle.com/bbs/?tid=3340 https://www.lexaloffle.com/bbs/?tid=3340 Thu, 12 May 2016 18:31:54 UTC