Log In  

@mhughson

Follow
Follow

Cart [#gfx_import_example-0#] | Code | 2019-03-31 | License: CC4-BY-NC-SA | Embed
5

For my game, Witch n Wiz (https://www.lexaloffle.com/bbs/?pid=38117#p), I implemented as simple technique for loading a secondary spritesheet at runtime. This allowed me to have a fullscreen title graphic, but not use up any of the sprite sheet memory (needed for game sprites and map data).

The cart at the top of this post is an ultra simple example of it in use. As you can see, you are able to switch between 2 sprite sheets that would each normally take up the entire sprite memory.

Credit for the num2hex function goes to felice (https://www.lexaloffle.com/bbs/?tid=30910)

Limitations:

You can still only have 128x128 worth of sprites in memory at a time. So this is really best for things like the title screen, or major switches in gameplay (say switching worlds where you don't need any of the original sprites anymore).

The runtime code for this is very light in tokens (~100) but the additional sprite sheet is stored as a large (although compressed) string, so that is going to each into your character count and compressed size (around 8000 chars in a typical case, and 25% of the compressed cart limit).

Tutorial:

1) Export

The first thing you need to do, is export your second sprite sheet into a compressed string format the runtime code expects. To do this, you simply load up this cart in Pico-8:

Cart [#gfx_export-0#] | Code | 2019-03-31 | License: CC4-BY-NC-SA | Embed
5

Fill the sprite sheet with the content you want to dynamically load at run-time, and hit "run".

This will copy the compressed data to your computers clipboard as a string. Paste that somewhere, like notepad.

2) Copy Runtime Code

Next, open up the import example (or view the code here in the broswer):

Cart [#gfx_import_example-0#] | Code | 2019-03-31 | License: CC4-BY-NC-SA | Embed
5

There is a small section of code you will need to add to your cart. Everything between "gfx import runtime begin" and "gfx import runtime end".

This is the code here for reference, if you don't want to load up the cart:

--
--gfx import runtime begin.
--
--copy and paste this into your
--game cart.
--example usage after "end".
--

-- converts hex string
-- to actual number
function hex2num(str)
    return ("0x"..str)+0
end

--call this when you want to
--load your fullscreen 
--graphics.
--this assumes a compressed
--format of <count>..<color>..
function load_stored_gfx(gfx)
    index=0
    for i=1,#gfx,2 do
        count=hex2num(sub(gfx,i,i))
        col=hex2num(sub(gfx,i+1,i+1))
        for j=1,count do
        sset((index)%128,flr((index)/128),col)
        index+=1
        end
    end
end

--call this to go back to 
--the original graphics stored
--on the cart.
--eg.after displaying title
--screen.
function restore_gfx()
    reload(0x0,0x0,0x2000)
end

--
--gfx import runtime end.
--

3) Paste Export Data

Go an get that string that got exported in step 1, and paste it into your game cart as a variable somewhere.

--something like this.
--it will be very large, so I just truncated the string in my example here.
local my_gfx="f51d151d151d151d151"

4) Load/Unload As Needed

There are only 2 functions you need to call for the entire library.

First, when you want to use the stored graphics, call load_stored_gfx() and pass it your compressed graphics string (eg. my_gfx) in this example.

When you are done with it, simply call restore_gfx() to return the sprite sheet to its original form.

P#63133 2019-03-31 04:18 ( Edited 2019-03-31 04:22)

Cart [#biyakigaha-0#] | Code | 2018-12-01 | License: CC4-BY-NC-SA | Embed
19

Day 1 of the 2018 Pico-8 Advent Calendar!


Thanks for checking out my entry for our community "Pico-8 Advent Calendar"!

It's a simple "race the clock" arcade game, with the goal of delivering as many presents as possible before sunrise. The entire game only lasts about a minute, with the idea that you will play many times, and try to beat your previous high score.

Credits:

Design and Code: https://twitter.com/matthughson
Art: https://twitter.com/hoybhoyb
Sound and Music: https://twitter.com/gruber_music
3D FX and Intro: https://twitter.com/2DArray

About Pico-8 Advent Calender:

During December, each day will be filled with new and exciting PICO-8 games! We have gathered 25 great developers from the PICO-8 community and we have worked hard to make some new games. Each day leading up to Christmas, there will be a new surprise for you!

Find out more at: https://pico8-advent.tumblr.com/

And check out the Pico-8 Advent Calendar each day for a new suprise: https://www.lexaloffle.com/bbs/?tid=32388

P#59372 2018-11-26 23:38 ( Edited 2018-12-01 18:12)

Cart [#56470#] | Code | 2018-09-10 | License: CC4-BY-NC-SA | Embed
6

Uncompressed Source Code: https://paste.ee/p/5KOG5 (warning: it's pretty gross)

Late last year (2017) I started work on a port of Super Mario Bros [NES] to Pico-8. The goal was to be authentic as possible to the original game, while working within the Pico-8 limitations. Something like Super Mario Bros Deluxe [GBC] (https://www.mariowiki.com/Super_Mario_Bros._Deluxe).

In the end I was able to get 1-1 and 1-2 mostly complete before starting to hit serious memory limits which make it seem near impossible to ship the full game.

With that in mind, I'm releasing it as-is for now so that people can check it out and see where it was headed.

If you are curious, the biggest factor for memory is the level data which is quite huge. At some point I'd like to document how my level authoring process worked, but for now you can check out this twitter thread of me slowly wittling down the level data size:

https://twitter.com/matthughson/status/929194247202340864

Update: I have managed to squeeze in all for World 1 now!

Music by: https://twitter.com/gruber_music

P#55697 2018-08-26 01:28 ( Edited 2018-10-22 00:03)

Cart [#48640#] | Code | 2018-01-28 | License: CC4-BY-NC-SA | Embed
1

P#48641 2018-01-28 12:12 ( Edited 2018-01-28 17:12)

Cart [#47932#] | Code | 2018-01-07 | License: CC4-BY-NC-SA | Embed

P#47930 2018-01-07 01:22 ( Edited 2018-01-07 06:25)

Cart [#47931#] | Code | 2018-01-07 | License: CC4-BY-NC-SA | Embed

P#47926 2018-01-07 01:01 ( Edited 2018-01-07 06:24)

Hi,

I am trying to store some binary data as a string in lua, like so:

local data="ã.ç.G W.§.Ó.×..."

but after saving, all common ascii characters in this string get moved to lowercase:

local data="ã.ç.g w.§.Ó.×..." --(note: G and W are now g and w)

Is there anyway to prevent this?

Thanks!

P#47004 2017-12-04 02:08 ( Edited 2018-01-18 22:00)

Is it possible to get the current Camera position stored in the DrawState?

I'm writing my own map() function, and want to hook into the built in camera functionality.

Thanks!

P#45945 2017-11-06 20:09 ( Edited 2017-11-07 06:52)

Cart [#39836#] | Code | 2017-04-23 | License: CC4-BY-NC-SA | Embed

Use arrow keys to move. Eliminate all the enemies.

P#39837 2017-04-23 00:54 ( Edited 2017-04-23 04:54)

Cart [#38530#] | Code | 2017-03-22 | No License | Embed
5

Cart [#38357#] | Code | 2017-03-18 | No License | Embed
5

P#38358 2017-03-18 02:23 ( Edited 2017-03-23 05:00)

Cart [#39947#] | Code | 2017-04-26 | No License | Embed
77

Art by: 9tk (https://www.lexaloffle.com/bbs/?uid=23566)
Code by: mhughson (https://www.lexaloffle.com/bbs/?uid=15406)
Sound by: gruber music (https://twitter.com/gruber_music)

Previous Versions:

Cart [#39706#] | Code | 2017-04-15 | No License | Embed
77

Cart [#39098#] | Code | 2017-04-05 | No License | Embed
77

Cart [#39021#] | Code | 2017-04-03 | No License | Embed
77

Cart [#38834#] | Code | 2017-03-29 | No License | Embed
77

Cart [#38770#] | Code | 2017-03-27 | No License | Embed
77

Cart [#38741#] | Code | 2017-03-26 | No License | Embed
77

Cart [#38605#] | Code | 2017-03-23 | No License | Embed
77

Cart [#38496#] | Code | 2017-03-21 | No License | Embed
77

Cart [#38398#] | Code | 2017-03-19 | No License | Embed
77

Cart [#38300#] | Code | 2017-03-17 | No License | Embed
77

Cart [#38204#] | Code | 2017-03-12 | No License | Embed
77

Cart [#38172#] | Code | 2017-03-12 | No License | Embed
77

Cart [#38148#] | Code | 2017-03-11 | No License | Embed
77

Cart [#38129#] | Code | 2017-03-10 | No License | Embed
77

Cart [#38116#] | Code | 2017-03-09 | No License | Embed
77

P#38117 2017-03-09 02:34 ( Edited 2018-09-10 05:00)

Cart [#37989#] | Code | 2017-03-02 | License: CC4-BY-NC-SA | Embed
7

P#37990 2017-03-02 02:19 ( Edited 2017-03-02 07:19)

Cart [#37404#] | Code | 2017-02-13 | License: CC4-BY-NC-SA | Embed
6

Testing out my Advanced Micro Platformer Starter Kit's ability to handle 16x16 sprites (vs more common 8x8 used in a lot of pico-8 games).

P#37405 2017-02-12 20:10 ( Edited 2017-02-13 02:45)

Cart [#37402#] | Code | 2017-02-13 | License: CC4-BY-NC-SA | Embed
116

I have taken my most recent Pico-8 game Kid Bludd, stripped it down to the essentials, and I am releasing it as a kind of Platforming Game Starter Kit.

I removed all logic that isn't game agnostic, so it is hopefully a good starting point for pretty much any platformer.

It's not super complicated, but does a lot of stuff I see many games not doing, which I consider table stakes for a platformer that feel good.

Features the basics:

  • Animation System
  • Collision Routines
  • Camera (w/Shake)
  • But also...

Forgiving Jumps

This one is very subtle but one of the most important pieces of a platformer. In general the player can only jump if they are on the ground, but this can make the game feel unresponsive when trying to make precision jumps. To give the player some leeway, the game allows jumps for a few frames after the player leaves a platform, and also registers jump presses if they came a few frames before landing.

Mario Sliding

When you change direction while moving, there is a bit of a slide before moving in the new direction.

Air and Ground Friction

Tunable values for both how much the player slows down while in the air and when touching the ground. This is critical for allowing the player to land on small platforms, while maintaining a good feeling in the air.

Variable Jump Height

Tap to jump a small amount, and hold to jump higher. Again very critical for precision jumps.

Pass Through Floors

Some floors allow the player to jump up through them, but not down. Really important for any levels with verticality, but also fun for horizontal scrollers.

Camera Scrolling Threshold

This cart uses the same camera style as metroid, where the player must leave a small area in the center of the screen before it starts scrolling. This give the player the freedom to make minor movements without causing nauseating camera movements.

This is a follow up to my original cart: "Micro Platformer - Simple Platforming Engine in 100 Lines of Code". If you are new to programming, I strongly suggest starting with that cart, as it is much simpler to follow!

Cart [#28248#] | Code | 2016-09-10 | License: CC4-BY-NC-SA | Embed
55


Old Versions:


Cart [#37157#] | Code | 2017-02-04 | License: CC4-BY-NC-SA | Embed
116

P#37158 2017-02-04 19:18 ( Edited 2018-10-17 00:05)

Cart [#36840#] | Code | 2017-01-29 | License: CC4-BY-NC-SA | Embed
11

Short demo showing how to do animations with nothing but palette cycling.

On the right is the actual sprite used, with not palette cycling.

On the left is the resulting animation, when cycling through the palette.

A very primitive example of the amazing techniques seen here: http://www.effectgames.com/demos/canvascycle/?sound=0

Disclaimer: I'm not an artist, so it would be great to see an actual pixel artist do something with this. :)

P#36841 2017-01-29 01:48 ( Edited 2017-01-29 06:52)

Cart [#36437#] | Code | 2017-01-23 | License: CC4-BY-NC-SA | Embed
56

My 12th one-game-a-month project, and my 4th Pico-8 game.

Loosely inspire by Bubble Bobble, but with a darker, more action-packed twist.




P#36438 2017-01-22 21:34 ( Edited 2018-11-25 18:02)

Is it possible to pause or mute music in Pico-8 from script?

I want to halt the music for a short period when the player dies, and resume it when they respawn. Pause or Mute would both work in this case; I just don't want to restart the whole song every time they die.

Thanks!

This is what I currently do:

-- Player Spawns...
music(0)

--Player dies
music(-1)

-- Player Spawns...
music(0)
P#35493 2017-01-11 20:59 ( Edited 2017-01-12 01:59)

Cart [#34523#] | Code | 2016-12-30 | License: CC4-BY-NC-SA | Embed
46

My 11th one-game-a-month project, and my 3rd Pico-8 game. Mostly procedurally generated, with a few sprites for decoration. Main character by Adam Atomic.

Post high-scores below!



Version 1.2

  • New music and sound by @gruber_music

Version 1.1

  • Improve rendering to remove glitches (thanks ultrabrite).
  • Commented code and removed unused logic.
P#32863 2016-12-01 01:13 ( Edited 2017-07-13 21:31)

The game I am currently working runs smooth in Pico-8 EXE but when I run in Chrome it has significant perf issues; often dropping frames causing hitches.

Is this a know thing? Is there a way to help with this, or diagnos it better?

A couple things:

1) I am running at 60 fps.
2) I do a LOT of dynamic allocations and discarding (its an endless, procedural game).
3) Stat(1) returns about .3 in best case, and .6 in worst case. Does stat(1) account for FPS target or is .6 on 60fps .1 over budget?
4) It runs totally smooth in Edge Browser, but buttons don't work properly (missing release events i think) and image is blurry (not using point filter).

Thanks!

Here's the game:

https://www.lexaloffle.com/bbs/?tid=28132

P#32861 2016-12-01 00:54 ( Edited 2016-12-02 05:24)

Cart [#32741#] | Code | 2016-11-25 | License: CC4-BY-NC-SA | Embed
5

FINAL GAME IS HERE: https://www.lexaloffle.com/bbs/?tid=28132

In the game above, the character is gliding in zero-g. They can move left and right using little air jets on the side of the space suit (left and right arrow keys).

I am struggling to make a good sound for this that isn't too grating (you will hear the sound A LOT). I was hoping for a high-pitch hiss; like air escaping a ballon, but having nailed it yet (see above).

"TSSSsss.. TSSSssss..."

Any audio designers know how to achieve this sound?

P#32743 2016-11-25 01:02 ( Edited 2016-12-05 22:38)

View Older Posts
About | Contact | Updates | Terms of Use
Follow Lexaloffle:        
Generated 2019-10-14 15:25 | 0.177s | 4194k | Q:338