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

Cart #man-0 | 2024-03-18 | Embed ▽ | No License
13

Documentation at your fingertips!

This cart installs the man terminal utility for reading documentation within picotron itself.

Something not documented? man will intelligently search the Fandom Wiki! 😱

Installation

  1. Setup yotta:

    • In the terminal
    • load #yotta
    • Press Ctrl-r
    • Press x to install
  2. Install this package:
    • In the terminal
    • yotta util install #man

This will install the following files for you:

appdata
└── system
    ├── lib
    │   └── man.lua  # The `man()` function for library usage
    ├── man/         # Man files live here
    └── util
        └── man.lua  # The `man` terminal utility

Usage

In the Picotron terminal, run man.

NAME
    man -- format and display the manual pages

SYNOPSIS
    man [section] name

DESCRIPTION
    man formats and displays the manual pages. If you specify section, man only looks in that section of the manual. name is normally the name of the manual page, which is typically the name of a command, function, or file.

    See below for a description of where man looks for the manual page files.

MANUAL SECTIONS
    The standard sections of the manual include:

    1        User Commands from /appdata/system/util

    2        System Calls such as fetch

    3        Picotron Lua Library Functions

    wiki    Wiki pages from https://pico-8.fandom.com

P8SCII FORMATTING
    man understands most of p8scii formatting. The \a command to play audio is not supported.

SEARCH PATH FOR MANUAL PAGES
    man searches /appdata/system/man for local manual pages in the format <name>.<section>.

WIKI PAGES
    When section is 'wiki', or local manual pages are not found, man will return the first search result from the unofficial PICO-8 wiki: https://pico-8.fandom.com

AUTHOR
    Created by Jess Telford <[email protected]>

Contributing

The code is on GitHub, and I'd love help documenting more of the picotron system so everyone can benefit!

Please open PRs and issues with suggestions ❤️

P#143718 2024-03-18 17:08 ( Edited 2024-03-18 17:20)

[ :: Read More :: ]

Introducing PECS (PICO-8 Entity Component System)

✅ Small API
🏃‍♀️ Efficient even with lots of Entities
😀 Fun to say
🎈 Has a "lite" version for the token-conscious

Based on the fantastic Tiny ECS Framework by @KatrinaKitten 🙏

Full code & docs on GitHub: github.com/jesstelford/pecs

Here's a demo cart showing off some Particle Emitters using PECS v2.0.0:

Cart #pecs-1 | 2022-04-19 | Code ▽ | Embed ▽ | No License
10

Update 20210316: I have added a Camera Follow/Window example also:

Cart #pecs_camera-1 | 2022-04-19 | Code ▽ | Embed ▽ | No License
10

Update 20220419: Released version 2.0.0 with renamed API methods.

P#88957 2021-03-14 11:38 ( Edited 2022-04-19 01:50)

[ :: Read More :: ]

Cart #fgetty-1 | 2020-08-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
5

Pseudo motion blur using the extended palette + dithering with fillp.

The crux of making this happen is:

local defaultFills = {
  0b0000000000000000,   -- solid
  0b0000000000000001.1, -- single pixel missing
  0b0000010100000101.1, -- 4 pixels missing
  0b0101101001011010.1, -- half pixels missing
  0b1111101011111010.1, -- 4 pixels rendered
  0b1111111111111110.1, -- 1 pixel rendered
}

-- Derived from https://stackoverflow.com/a/10086034/473961
function resizeAndFill(input, outputLength)
  assert(outputLength >= 2, "behaviour not defined for n<2")
  local step = (#input-1)/(outputLength-1)
  local result = {}
  for x=1,outputLength do
    result[x] = input[ceil(0.5 + (x-1)*step)]
  end
  return result
end

function createTrailSystem(shapes)
  local longestTrail = 0
  foreach(shapes, function(shape)
    shape.trailPositions = shape.trailPositions or {}
    shape.trails = shape.trails or 1
    shape.framesPerTrail = shape.framesPerTrail or 1
    -- Normalise the length of .fills to match number of trails
    shape.fills = resizeAndFill(shape.fills or defaultFills, shape.trails + 1)
    -- Normalise the length of .colors to match number of trails
    shape.colors = resizeAndFill(shape.colors or { shape.color }, shape.trails + 1)
    longestTrail = max(longestTrail, shape.trails)
  end)

  return {
    update=function()
      foreach(shapes, function(shape)
        if (#shape.trailPositions > (shape.trails * shape.framesPerTrail)) then
          -- Remove the oldest / now stale trail
          deli(shape.trailPositions, 1)
        end
        -- Add a new trail at the last position
        add(shape.trailPositions, { x=shape.x, y=shape.y })
      end)
    end,

    draw=function()
      -- Draw all the trail layers at the same time to avoid weird overlay
      -- artefacts
      for trail=longestTrail,1,-1 do
        foreach(shapes, function(shape)
          if (shape.trails < trail) then return end
          local frame = ((shape.trails - trail) * shape.framesPerTrail) + 1
          if (not shape.trailPositions[frame]) then return end
          -- +1 for 1-index in lua
          -- +1 for the actual shape itself
          local color = shape.colors[shape.trails - trail + 2]
          local fill = shape.fills[trail + 1]
          pal(shape.colors[1], color)
          shape.draw(
            shape.trailPositions[frame].x,
            shape.trailPositions[frame].y,
            shape.colors[1],
            fill
          )
        end)
      end
      foreach(shapes, function(shape)
        pal(shape.colors[1], shape.colors[1])
        shape.draw(shape.x, shape.y, shape.colors[1], shape.fills[1])
      end)
    end
  }
end

And it's used like so:

local trails

local shape = {
  colors={1,2,3,4},
  -- Force no dithering
  fills={0b0000000000000000},
  x=64,
  y=64,
  trails=4,
  framesPerTrail=7,
  draw=function(x, y, color, fill)
    fillp(fill)
    circfill(x, y, 8, color)
  end
}

function _init()
  -- Setup the palettes in use
  -- Colors figured out thanks to http://kometbomb.net/pico8/fadegen.html
  pal(1, 12, 1)
  pal(2, 129, 1)
  pal(3, 131, 1)
  pal(4, 140, 1)

  -- Initialise the shapes ready for motion trail
  trails = createTrailSystem({ shape })
end

function _update60()
  if (btn(0)) then shape.x -= 2 end -- Left
  if (btn(1)) then shape.x += 2 end -- Right
  if (btn(2)) then shape.y -= 2 end --Up
  if (btn(3)) then shape.y += 2 end --Down

  trails.update()
end

function _draw()
  cls(0)
  trails.draw()
end
P#80976 2020-08-20 16:35 ( Edited 2020-08-20 16:45)