Log In  
Follow
gabintod
[ :: Read More :: ]

Hi, I was experimenting with a way of making a multiplayer game on Pico-8 (on different cartriges to have more screen space).
So I was looking for a way to communicate from the cart to the host OS, I know it's possible to inject and retreive data on the web exports with javascript but I'm trying to find a way to do it localy .

I have tried that code:

cls()
i_channel=0x804
o_channel=0x805
input=''
output=''

function _update()
    local nb=0
    repeat
        nb=serial(i_channel,0x8000,0x1000)
        for i=0,nb do
            input..=chr(peek(0x8000+i))
        end
    until nb==0

    if (btnp(⬅️)) output..='⬅️' stdout('left ')
    if (btnp(➡️)) output..='➡️' stdout('right ')
    if (btnp(⬆️)) output..='⬆️' stdout('up ')
    if (btnp(⬇️)) output..='⬇️' stdout('down ')
    if (btnp(🅾️)) output..='🅾️' stdout('𝘰 ')
    if (btnp(❎)) output..='❎'   stdout('𝘹 ')
end

function _draw()
    print('\^rf'..output,2,2,7)
    print('\^rw'..input,66,2,13)
end

function stdout(str)
    for i,c in pairs(split(str,'')) do
        poke(0x9000+i-1,ord(c))
    end
    serial(o_channel,0x9000,#str) 
end

it uses the stdin and stdout of the cart to read and write into files when called like this:
> pico8 < input_file.txt > output_file.txt -run mycart.p8
The problem I ran into is that I can't use the same file for the input and output.

My best attempt was to use a pipeline to redirect the stdout of a cart to the stdin of another one like this:
> pico8 -run mycart.p8 | pico8 -run mycart.p8
The problem here is that a strange thing is happening, the first cart boots and works fine but the second one freezes until the first one is shutdown. Then it works as intended, I get the output from the first cart. But I am not able to make the to instances of the cart run at the same time and communicate.

Any idea how to pull it of ?

P#144253 2024-03-23 23:56 ( Edited 2024-03-23 23:59)

[ :: Read More :: ]

Cart #picofier-3 | 2024-03-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
10

Controls

Use ◀️ and ▶️ to walk, 🅾️ to jump and ❎ to shoot. The longer you press on the jump button the higher you will jump. You are also able to walljump by pressing the jump button close to a wall. You can kill enemies by shooting at them. Hold 🔼 or 🔽 to move the camera and see your suroundings.

Goal

The goal is to reach the end of each level. To get a perfect score you will need to collect every coin of the level and never die.
Finishing a level will unlock access to the next one.

Story

You are making your way towards the source of EVIL that ravaged these now cursed lands. Fortunately you are not from this age and with you came the tools you will need to fight not only to survive but to save this world from the biggest threat it has ever faced. Unleash the fire power, make your skills talk and maybe you will be able to banish evil back to the dark realm where it belongs.

Secret

Somewhere in the lands there is a message from a greater power, this message will grant you access to each and every locations this world has to offer.

Making of

This is the first game I'm releasing on Pico-8 and the first time I give a try at level design. There is alot I would like to improve in the game but I have been working on it for a long time and it had to come out at some point.
Feel free to share feedbacks and I hope you'll enjoy the game !


Changelog

Version 3

  • Improved camera to look forward when moving and up and down using 🔼 and 🔽 keys
  • Added wall friction that slows your fall when close to a wall
  • Added post signs to give tips and help telling the story
  • Code has been factorised and every level uses most of the same code from #includes

TODOs

These are the things I intend to do in the future:

  • Add a boss fight at the end of level 5. It will summon enemies until he's killed.
  • Add musics to each levels and to to the title screen
  • Make the roar of the cerberus more distinguishable from other sfx
  • Make a special animation when collecting a weapon to make it look more important
  • Add the Survival mode to be unlocked when all levels are completed. The Survival mode would consist of surviving the most amont of enemy wave in maps inspired from the differents levels. There would be multiple weaponds, power-ups to boost damage or increase armor...
  • Make a cartrige illustration that represents more the game mood (with the hero killing a zombie)
  • Use bigger particles for muzzle flash of weapons
  • Maybe add a bloody medal for when you kill all enemies in a level
P#143851 2024-03-19 15:52 ( Edited 2024-03-22 17:33)