I am definitely seeing a way to store more than 256-bytes at a time.
cartdata("mister_1") for i=0,63 do dset(0,i) end cartdata("mister_2") for i=0,63 do dset(0,i) end |
And then I'm greeted with this message:
CARTDATA() CAN ONLY BE CALLED ONCE |
Really ... really ? I mean if you could have multiple Cartdata() commands you could save, well, gee, I don't know, 8192 bytes perhaps ??
Good grief. There's one things in setting limitations in a programming language for nostalgic purposes and then there's just outright imprisoning your data ... 😨


Novice coder, so sorry if I'm making a dumb mistake lol.
Wanted to make a platformer where the player can shoot and detonate bullets to create platforms that the player can then jump on. However, when that platform is created, using map, the player doesn't collide with it.
I'm using the Advanced Micro Platformer template from mhughson (https://www.lexaloffle.com/bbs/?tid=28793), so I don't really understand where to even start to try to figure this out.
-- config -------------------------------- --sfx snd= { } --music tracks mus= { } --math -------------------------------- --point to box intersection. function intersects_point_box(px,py,x,y,w,h) if flr(px)>=flr(x) and flr(px)<flr(x+w) and flr(py)>=flr(y) and flr(py)<flr(y+h) then return true else return false end end --box to box intersection function intersects_box_box( x1,y1, w1,h1, x2,y2, w2,h2) local xd=x1-x2 local xs=w1*0.5+w2*0.5 if abs(xd)>=xs then return false end local yd=y1-y2 local ys=h1*0.5+h2*0.5 if abs(yd)>=ys then return false end return true end --check if pushing into side tile and resolve. --requires self.dx,self.x,self.y, and --assumes tile flag 0 == solid --assumes sprite size of 8x8 function collide_side(self) local offset=self.w/3 for i=-(self.w/3),(self.w/3),2 do --if self.dx>0 then if fget(mget((self.x+(offset))/8,(self.y+i)/8),0) then self.dx=0 self.x=(flr(((self.x+(offset))/8))*8)-(offset) return true end --elseif self.dx<0 then if fget(mget((self.x-(offset))/8,(self.y+i)/8),0) then self.dx=0 self.x=(flr((self.x-(offset))/8)*8)+8+(offset) return true end -- end end --didn't hit a solid tile. return false end --check if pushing into floor tile and resolve. --requires self.dx,self.x,self.y,self.grounded,self.airtime and --assumes tile flag 0 or 1 == solid function collide_floor(self) --only check for ground when falling. if self.dy<0 then return false end local landed=false --check for collision at multiple points along the bottom --of the sprite: left, center, and right. for i=-(self.w/3),(self.w/3),2 do local tile=mget((self.x+i)/8,(self.y+(self.h/2))/8) if fget(tile,0) or (fget(tile,1) and self.dy>=0) then self.dy=0 self.y=(flr((self.y+(self.h/2))/8)*8)-(self.h/2) self.grounded=true self.airtime=0 landed=true end end return landed end --check if pushing into roof tile and resolve. --requires self.dy,self.x,self.y, and --assumes tile flag 0 == solid function collide_roof(self) --check for collision at multiple points along the top --of the sprite: left, center, and right. for i=-(self.w/3),(self.w/3),2 do if fget(mget((self.x+i)/8,(self.y-(self.h/2))/8),0) then self.dy=0 self.y=flr((self.y-(self.h/2))/8)*8+8+(self.h/2) self.jump_hold_time=0 end end end --make 2d vector function m_vec(x,y) local v= { x=x, y=y, --get the length of the vector get_length=function(self) return sqrt(self.x^2+self.y^2) end, --get the normal of the vector get_norm=function(self) local l = self:get_length() return m_vec(self.x / l, self.y / l),l; end, } return v end --square root. function sqr(a) return a*a end --round to the nearest whole number. function round(a) return flr(a+0.5) end --utils -------------------------------- --print string with outline. function printo(str,startx, starty,col, col_bg) print(str,startx+1,starty,col_bg) print(str,startx-1,starty,col_bg) print(str,startx,starty+1,col_bg) print(str,startx,starty-1,col_bg) print(str,startx+1,starty-1,col_bg) print(str,startx-1,starty-1,col_bg) print(str,startx-1,starty+1,col_bg) print(str,startx+1,starty+1,col_bg) print(str,startx,starty,col) end --print string centered with --outline. function printc( str,x,y, col,col_bg, special_chars) local len=(#str*4)+(special_chars*3) local startx=x-(len/2) local starty=y-2 printo(str,startx,starty,col,col_bg) end --objects -------------------------------- --make the player function m_player(x,y) --todo: refactor with m_vec. local p= { x=x, y=y, dx=0, dy=0, w=8, h=8, max_dx=1,--max x speed max_dy=2,--max y speed jump_speed=-1.75,--jump veloclity acc=0.05,--acceleration dcc=0.8,--decceleration air_dcc=1,--air decceleration grav=0.15, --helper for more complex --button press tracking. --todo: generalize button index. jump_button= { update=function(self) --start with assumption --that not a new press. self.is_pressed=false if btn(2) then if not self.is_down then self.is_pressed=true end self.is_down=true self.ticks_down+=1 else self.is_down=false self.is_pressed=false self.ticks_down=0 end end, --state is_pressed=false,--pressed this frame is_down=false,--currently down ticks_down=0,--how long down }, jump_hold_time=0,--how long jump is held min_jump_press=5,--min time jump can be held max_jump_press=15,--max time jump can be held jump_btn_released=true,--can we jump again? grounded=false,--on ground airtime=0,--time since grounded --animation definitions. --use with set_anim() anims= { ["stand"]= { ticks=1,--how long is each frame shown. frames={1},--what frames are shown. }, ["walk"]= { ticks=5, frames={1,2,3,4,5}, }, ["jump"]= { ticks=1, frames={1}, }, ["slide"]= { ticks=1, frames={6}, }, }, curanim="walk",--currently playing animation curframe=1,--curent frame of animation. animtick=0,--ticks until next frame should show. flipx=false,--show sprite be flipped. --request new animation to play. set_anim=function(self,anim) if(anim==self.curanim)return--early out. local a=self.anims[anim] self.animtick=a.ticks--ticks count down. self.curanim=anim self.curframe=1 end, --call once per tick. update=function(self) --todo: kill enemies. --track button presses local bl=btn(0) --left local br=btn(1) --right --move left/right if bl==true then self.dx-=self.acc br=false--handle double press elseif br==true then self.dx+=self.acc else if self.grounded then self.dx*=self.dcc else self.dx*=self.air_dcc end end --limit walk speed self.dx=mid(-self.max_dx,self.dx,self.max_dx) --move in x self.x+=self.dx --hit walls collide_side(self) --jump buttons self.jump_button:update() --jump is complex. --we allow jump if: -- on ground -- recently on ground -- pressed btn right before landing --also, jump velocity is --not instant. it applies over --multiple frames. if self.jump_button.is_down then --is player on ground recently. --allow for jump right after --walking off ledge. local on_ground=(self.grounded or self.airtime<5) --was btn presses recently? --allow for pressing right before --hitting ground. local new_jump_btn=self.jump_button.ticks_down<10 --is player continuing a jump --or starting a new one? if self.jump_hold_time>0 or (on_ground and new_jump_btn) then if(self.jump_hold_time==0)sfx(snd.jump)--new jump snd self.jump_hold_time+=1 --keep applying jump velocity --until max jump time. if self.jump_hold_time<self.max_jump_press then self.dy=self.jump_speed--keep going up while held end end else self.jump_hold_time=0 end --move in y self.dy+=self.grav self.dy=mid(-self.max_dy,self.dy,self.max_dy) self.y+=self.dy --floor if not collide_floor(self) then self:set_anim("jump") self.grounded=false self.airtime+=1 end --roof collide_roof(self) --handle playing correct animation when --on the ground. if self.grounded then if br then if self.dx<0 then --pressing right but still moving left. self:set_anim("slide") else self:set_anim("walk") end elseif bl then if self.dx>0 then --pressing left but still moving right. self:set_anim("slide") else self:set_anim("walk") end else self:set_anim("stand") end end --flip if br then self.flipx=false elseif bl then self.flipx=true end --anim tick self.animtick-=1 if self.animtick<=0 then self.curframe+=1 local a=self.anims[self.curanim] self.animtick=a.ticks--reset timer if self.curframe>#a.frames then self.curframe=1--loop end end end, --draw the player draw=function(self) local a=self.anims[self.curanim] local frame=a.frames[self.curframe] spr(frame, self.x-(self.w/2), self.y-(self.h/2), self.w/8,self.h/8, self.flipx, false) end, } return p end --make the camera. function m_cam(target) local c= { tar=target,--target to follow. pos=m_vec(target.x,target.y), --how far from center of screen target must --be before camera starts following. --allows for movement in center without camera --constantly moving. pull_threshold=16, --min and max positions of camera --the edges of the level. pos_min=m_vec(64,64), pos_max=m_vec(320,64), shake_remaining=0, shake_force=0, update=function(self) self.shake_remaining=max(0,self.shake_remaining-1) --follow target outside of --pull range. if self:pull_max_x()<self.tar.x then self.pos.x+=min(self.tar.x-self:pull_max_x(),4) end if self:pull_min_x()>self.tar.x then self.pos.x+=min((self.tar.x-self:pull_min_x()),4) end if self:pull_max_y()<self.tar.y then self.pos.y+=min(self.tar.y-self:pull_max_y(),4) end if self:pull_min_y()>self.tar.y then self.pos.y+=min((self.tar.y-self:pull_min_y()),4) end --lock to edge if(self.pos.x<self.pos_min.x)self.pos.x=self.pos_min.x if(self.pos.x>self.pos_max.x)self.pos.x=self.pos_max.x if(self.pos.y<self.pos_min.y)self.pos.y=self.pos_min.y if(self.pos.y>self.pos_max.y)self.pos.y=self.pos_max.y end, cam_pos=function(self) --calculate camera shake. local shk=m_vec(0,0) if self.shake_remaining>0 then shk.x=rnd(self.shake_force)-(self.shake_force/2) shk.y=rnd(self.shake_force)-(self.shake_force/2) end return self.pos.x-64+shk.x,self.pos.y-64+shk.y end, pull_max_x=function(self) return self.pos.x+self.pull_threshold end, pull_min_x=function(self) return self.pos.x-self.pull_threshold end, pull_max_y=function(self) return self.pos.y+self.pull_threshold end, pull_min_y=function(self) return self.pos.y-self.pull_threshold end, shake=function(self,ticks,force) self.shake_remaining=ticks self.shake_force=force end } return c end function fire(direc) local b = { sp=16, x = p1.x - 4, y = p1.y - 16, dx = direc, dy = 0 } add (bullets, b) isdetonate = false end function detonate(x,y) local d = { x = x + 4, y = y + 4, t = 0, timer = 0, } add(det, d) detx = d.x dety = d.y for b in all (bullets) do del(bullets, b) end isdetonate = true; end function draw_bullets() if(p1.flipx == false) then direction = 1 end if(p1.flipx == true) then direction = -1 end for b in all (bullets) do spr(b.sp, b.x, b.y) end for d in all (det) do circ(d.x, d.y, d.timer/2, d.t) circ(d.x, d.y, d.timer/2 - 4, d.t) end end function draw_clouds() map(0,62,detx - 8,dety - 4,2,2) end function update_bullets() for b in all (bullets) do b.x += b.dx b.y += b.dy end if(btnp(4) and isdetonate) then fire(direction) end if(btnp(5) and isdetonate == false) then for b in all (bullets) do detonate(b.x, b.y) end end for d in all (det) do randcol = flr(rnd(2)) if(randcol == 0) then d.t = 14 end if(randcol == 1) then d.t = 7 end d.timer += 1 if (d.timer == 20) then del(det, d) end end end function delete_bullets() for b in all (bullets) do if(b.x > cam.pos.x + 64 or b.x < cam.pos.x - 64) then del(bullets, b) isdetonate = true; end end end --game flow -------------------------------- --reset the game to its initial --state. use this instead of --_init() function reset() ticks=0 p1=m_player(64,40) p1:set_anim("walk") cam=m_cam(p1) bullets = {} isdetonate = true det = {} randcol = 0 playerx = 0 playery = 0 direction = 1 detx = 500 dety = 500 end --p8 functions -------------------------------- function _init() reset() end function _update60() ticks+=1 p1:update() cam:update() --demo camera shake update_bullets() delete_bullets() end function _draw() cls(0) camera(cam:cam_pos()) map(0,0,0,0,128,128) p1:draw() draw_bullets() draw_clouds() -- debug -- camera(0,0) -- circ(cam.pos.x, cam.pos.y, 2,7) -- printc("adv. micro platformer",64,4,7,0,0) -- print(cam.pos.x) end |

Description
Death is not the end of this knight's quest. This is a short demo of a game I've been working on for a bit now.
Instructions
Directional Keys move your character.
Hold the O Key to charge up, release the O Key to attack.
Hold the X Key to use your shield. The shield recharges when not in use.
Version
The current version is 1.0 and features the following changes:
+release
Thank you for playing my game!


--[[ a pressing problem. many of you have played various games in pico and have come across that one game with the dreaded btnp() function used instead of btn(). for action games like platformers or shooters, you should =never= use btnp() and i can think of a few shooters i've played that use btnp() making it difficult to maintain auto-fire and movement at the same time. what's the difference ? btn() reads a raw keystroke, it does not wait for key repeat and is perfect for action games. btnp() reads like a standard keyboard. it will allow one press, then nothing, then slowly repeat the stroke. so btn() is good for action games, and btnp() is better for thinking puzzle games. hope this helps ! ]]-- m=0 x=60 y=60 repeat cls() t="off" if (m==1) t="on" print("raw key="..t) print("press ❎ to swap") circfill(x,y,8) if ((btn(⬆️) and m==1) or btnp(⬆️)) y-=1 if ((btn(⬇️) and m==1) or btnp(⬇️)) y+=1 if ((btn(⬅️) and m==1) or btnp(⬅️)) x-=1 if ((btn(➡️) and m==1) or btnp(➡️)) x+=1 if (btnp(❎)) m=1-m flip() until forever |
Despite being the third PICO-8 game I've made and obviously the first I'm posting here, this began as my first project. It's also the first project I've ever completed outside of a jam setting. I enjoyed discovering and becoming acquainted with PICO-8's limitations, and I accomplished a lot more than I expected I would when I first started on Cake Quest back in December. If you're interested, you can read about its inception here and about its development here.
I learned a lot, and I hope others can learn from it as well.
EDIT: Modified vertical camera tracking
EDIT 2: Made further adjustments to vertical camera tracking




As many of you may be aware, you can indeed load and save 256-bytes of data broken down to a storage of 64-numbers using conventional method commands of CARTDATA(), DSET(), and DGET().
However, if you want more than this, you will have to use unconventional method commands of CSTORE and RELOAD.
What follows is a sample program I wrote to demonstrate writing 8-bytes to an external file and reading it back again. You can actually load and save up to 🔺8192-bytes of storage this way so it is not to be overlooked !
Definition and instructions are below:
this fairly complex program will load data from an external binary file and display the results. after this, with the mode set to zero (0), it will save the select text to the select external file so the next time you run, you will be able to confirm it is loaded correctly. note ! this will not work as a true compiled exe or if you are attempting to run it directly from splore. you must save this .p8 to your local hard-drive and execute it -or- run it from an internet online page. if you have any questions or comments, please let me know! |




(08/23/18) CHANGED THE TOPIC TO "PICO-8: SUPPORT"
Was just trying out my Haunted House game as a Windows EXE. Although making high-score, it did not appear in the scoreboard. This is odd because score is kept when it's played either in HERE or as a raw HTML.
Here is the code:
if debug==0 then reload(8192,8192,180,"_hauntedhouse_dw817") end if peek(8192)+peek(8193)==0 or peek(17152)==254 then str2mem(defhs,8192) cstore(8192,8192,180,"_hauntedhouse_dw817") end |
Can someone confirm this on their own games that save data ?




It certainly is convenient to be able to compile a PICO program into a Windows and Macintosh & Linux executable with the command:
export program.bin |
To create an HTML you can use:
export program.html |
I was wondering if someone who was HTML savvy could post the absolute minimal code for an HTML to play and display JUST the .JS at a level of 100% screen height and ability to modify the default width of 100% with anything like 125% for a slightly longer across screen.
No code desired for external buttons just in this simple window.
Also, are there input values to that HTML which let you keep sharp pixels, dithered, or to reproduce like an old television with scan-lines ?
To create the screen, apparently you need more than just this:
<script type="text/javascript" src="program.js"></script> |

With the small size that PICO is, it should be possible to load and save state, much like you can do in a NES or SNES emulator.
In NESTOPIA you can even hold the backspace to run the game backwards, useful for getting out of a pit say in Super Mario Bros. But I think rewind may be just a bit more complex than save state.
If you're not familiar with what this is, by pressing F2 or F4 (you configure the keys) in the game, you can SAVE STATE.
By doing so, your game progress right up to there is saved to the pixel ! No need to save your game using a save-spot or even accessing menu options as part of the game.
Loading State is just as easy. You could shut down the game for instance, bring something else up, finally bring back up the original game and before the opening credits have even finished, you can press F4 or Load State and your game is returned exactly back where you left it.
Saving State in Pico means saving all variables, all memory, program line number being run, everything, to a binary file.
Loading State injects all that raw data right back in place again. As mentioned, this is very common in game emulators such as for Nintendo, Super Nintendo, Gameboy, and even Sony Pocket Playstation.
Naturally this would make platformers and other action games easier to play as you could SAVE STATE right at a part of the game where you knew you were safe.
What do you think - or do you think REWIND is possible as well ?


A few quick questions, mostly for sound.
[1] Can you play a SFX and have the ability to change the pitch of it before it plays ?
[2] Is there a way to COPY and PASTE SFX data from one PICO-8 app or Notepad to another ?
[3] When defining values for local variables, if you need to define more than one, it either requires 2-lines of code:
local a=1 local b=2 |
Or this unusual way:
local a,b=1,2 |
Is it possible someway to do it like this ?
local a=1,b=2 |
If you try this, you get an error.
If you try it this way:
local a=1 b=2 |
Then "b" value is set, but it is global.


