Hi! I just started using PICO-8 and I'm having a little trouble with my collision code.
It works fine when colliding against walls, but colliding against corners (the red tiles) breaks it.
Here is the collision part of the code:
function placeMeeting(x, y, f) local tilesize = 8 local tilex = flr(x/8) local tiley = flr(y/8) local s = mget(tilex, tiley) return (fget(s, f)) end |
And this is the movement part:
if (btn(0)) then if (not placeMeeting(p.x-1, p.y, solidtile)) then p.x -= p.speed end p.mirror = true elseif (btn(1)) then if (not placeMeeting(p.x+p.bbox_w+1, p.y, solidtile)) then p.x += p.speed end p.mirror = false end if (btn(2)) then if (not placeMeeting(p.x, p.y-1, solidtile)) then p.y -= p.speed end elseif (btn(3)) then if (not placeMeeting(p.x, p.y+p.bbox_h+1, solidtile)) then p.y += p.speed end end |


I have pico 8 on my home pc, my work pc, and my raspberry pi, but they each have their own favorites list. Is there a way to put this favorites list in the root path? I have all my carts and such in a dropbox share that all three machines use, but not the favourites.txt.
Also is there a way to sort favourites.txt (other than just editing the file and sorting by the column of the title of the game)?
Is there any way to make a pattern stop short of 32 notes? (like famitracker has a Bxx effect for jumping to another pattern/frame) I have some music with a repeating section but it won't fit in 32 notes. if I could make it stop at say note 24 (or whatever it ends up being) I could repeat this section in a pattern and not have to waste an extra sfx.




The mobile player on the forum is pretty nice, but it's missing one important feature : It doesn't disable the long-press context menu.
If you hold the d-pad or a button down (as you do) it pops up a context menu, making the games frustrating.
Until this is fixed, I recommend using this bookmarklet to fix it.
javascript:(function()%7Bwindow.oncontextmenu%20%3D%20function(event)%20%7Bevent.preventDefault()%3Bevent.stopPropagation()%3Breturn%20false%3B%7D%7D)() |
The forum strips out JavaScript links, so I can't link to the bookmarket, but make a new bookmark, and copy/paste that code into the URL field. Tapping on it will disable the context menu, making Pico8 a joy to play on mobile firefox.


I'm noob with PICO-8 and wanna play "Mary had a little lamb" using only beeps from code. Not using sfx editor, not using music.
however, i dont hear any beeps. Whats wrong?
print("Press arrow keys ",12,64,0) ID=0 if btnp(0) then sfx(id,"E-4") elseif btnp(1) then sfx(id,"E-6") elseif btnp(2) then sfx(id,"E-7") elseif btnp(3) then sfx(id,"E-5") end |

I was playing around with loops and learning exactly how iterators work and stumbled across this...
When we write the following:
for k,v in pairs(t) do ... end |
In regular lua it is identical in function to writing this:
for k,v in next,t do ... end |
Because that's what pairs(t) returns: the builtin next() function, which iterates over the hash table that underlies lua tables, and t.
In PICO-8, we don't have direct access to next(), but we can get it:
next=pairs(any table, doesn't matter) |
Once done, we've spent 5 tokens getting it. However, the "in next,t" form of the loop is one token shorter (and two characters). So if you convert more than 5 loops, you're saving.
I know it's minor, but I know some of you end up scrimping and saving for single tokens, so I thought I'd pass it on. Um. Enjoy? ;)
@zep: any chance we could just get next() available directly?
In Lua, long comments using --[[ / ]] cannot be nested: another opening --[[ in there will just be ignored. So the following code will print 2 in Lua, and 1 in PICO-8:
a=1 --[[ [[]] a=2 --]] print(a) |
This is actually a funny way to detect whether you’re running inside PICO-8 :-)
print("running in ".. --[[[[]] "lua!") --]] "pico-8!") |

This is the same as the player below, except it's illustrating a way to link multiple animations using cutaways. Normally you would need to account for each shape in a previous frame in the new frame as they are intended to 'animate'. That can be used for interesting effects, like the cat gif below that has words transition from Japanese to Meownese. But using this structure allows you to more traditionally link completely unrelated scenes so they will be played in a sequence, before returning to the main program state.




On Windows 10, if the mouse cursor is all the way on the left or right of the screen (so it's not visible), scrolling does nothing visually. However, the moment my mouse comes back on the screen, the editor jumps to where it would have visually scrolled to had my mouse been on the screen. Here's a gif of what's happening. (When the mouse goes off the screen, I'm scrolling up and down.)

Looking for thoughts, suggestions on tightening up the gameplay and feel.
Rules:
Match 3 or more tiles in any direction on the bottom game board
3: 50 points
4: 250 points
5: 1000 points
Score multiplier for quick matching.
You can hold 5 tiles at once.
Extra drop at 1000 points
Additional colors introduced every 1000 points
Controls:
Down arrow to speed up drops
X to drop a tile
if you lose you can reset the cart
Todo:
Need a better game over sound.
Need to fix some bugs with the matching algorithm
(Try this pattern:
__X _X_ XX_ |
)


NOTE: Not playable here due to cartridge swapping.
Only the menu is here due to level data on other carts.
10 carts in use with this alpha release.
A fully-playable HTML export is on my itch.io page here:
https://juanitogan.itch.io/landing-party-of-legend

Landing Party of Legend
"Dead people are going to die."
Are you an awesome enough starship captain to direct your landing parties through the perils of nine mysterious worlds?
Welcome to Landing Party of Legend, a strategy adventure game of campy, red-shirt-style attrition. You and several other famous and notorious people from history have escaped your captors and are trying to make it back to Earth (without too many casualties) so that the world may know your tale.



I've been using PICO-8 to prototype a potential game for the Commodore 64. It's mostly testing out the graphics and exporting the tiles, map and sprites to asm source code. In the end having the wrong palette made things too confusing for me.
So I bring you PICO-64:

It is just PICO-8 with the palette changed into that of the VIC-II, the graphics chip of the Commodore 64.
On OS X the palette that PICO-8 is using is in the binary PICO-8.app/Contents/MacOS/pico8.dat file. Just search and replace to change. I used macvim and the Tools/Convert to HEX and Convert Back.
These colors:
1d2b53 7e2553 008751 ab5236 5f574f c2c3c7 fff1e8 ff004d ffa300 ffec27 00e436 29adff 83769c ff77a8 ffccaa |
Needs to be changed into these (Pepto's VIC-II palette):
ffffff 68372b 70a4b2 6f3d86 588d43 352879 b8c76f 6f4f25 433900 9a6759 444444 6c6c6c 9ad284 6c5eb5 959595 |
To overcome the small screen I have been using PICO-8's mouse feature to scroll around a 320x200 pixel screen. Not optimal, but still usable.
If you try this out and start hacking binary files, don't blame me if something breaks!










Working on a game for LOWREZJAM 2017 and I'm running into some issues with getting the background to scroll up to simulate movement while still maintaining the player's position.
Here is the current issue I'm encountering:
My issue is arising from the camera moving up along the drawn map and snapping back to the bottom when it reaches a certain y value. That works fine for the background but I'm not sure how to get the player to maintain their y position when the map snaps back to the bottom.
The code I've written is as follows:
function _init() --renders game at 64x64 poke(0x5f2c,3) cls() --creates variable t to store timer info later in code t=0 --establishes boundaries of the level level={ w=64, h=250, cy=0 } cam_x=0 cam_y=0 player = { sp=1, x=28, y=50, h=100, t=0, imm=false } end function _update() --autoscrolling code --moves both the level/background and the player at the same speed, to simulate movement if level.cy<level.h-64 then level.cy-=2 player.y-=2 end --statement that will trigger invincibility frames --inactive atm if player.imm then player.t += 1 if player.t >30 then player.imm = false player.t = 0 end end --timer and statement that flickers back and forth between sprites to simulate movement t=t+1 if(t%8<3) then player.sp=1 else player.sp=2 end --basic movement code if btn(0) then player.x-=1 end if btn(1) then player.x+=1 end if btn(2) then player.y-=1 end if btn(3) then player.y+=1 end end function _draw() cls() --camera that follows level's movement --also keeps player on screen camera(0,level.cy) if level.cy<-80 then level.cy=0 player.y=50 end --draws map, extended to -100 to allow for longer stretch of road map(0,0,0,-100,12,63) --draws player car spr(player.sp,player.x,player.y,.75,2) end |


I thought people might be interested. https://itch.io/jam/lowrezjam2017
It started a few days ago but it's running until the 17th so you haven't lost too much time yet. Lowrezjam games are 64x64 but you can get this in Pico-8 by doing a poke(0x5f2c,3).
I'm working on a pirate sailing adventure. I've got sailing around working ok, working on disembarking so you can walk around islands to look for treasure. Here's my progress so far:

Anyone else want to share?





The += operator seems to be implemented using some sort of string search and replace preprocessing. But there is a bug in there that eats the character just after the statement. Here is an example:
a=0 a+=(1)ba=42 print(a)print(ba) |
I would expect this to print 1 and 42 but it actually prints 42 nil. I believe this is because the b from ba=42 is removed, thus replacing the next statement with a=42.
Edit: here are some more problems with the += operator.
This code will print 1 despite the syntax error (trailing comma):
a=0 a+=1, print(a) |
And if we add a space before the comma, this code will print 0 (the increment isn’t actually done):
a=0 a+=1 , print(a) |
This will print 1 and nil for incomprehensible reasons:
a=0 b=0 a, b+=1 print(a) print(b) |
Edit: yet another problem; syntax validation seems to be restricted to the first line, so this will not work:
-- This will not work a += b + c -- But this will work: a += b + c |
Edit: the above problem will silently create bugs, for instance:




