Pset

From Pico-8 Wiki
Jump to navigation Jump to search
pset( x, y, [c] )
Sets a pixel in the graphics buffer.
x
The x coordinate.

y
The y coordinate.

c
The color value. If not specified, uses the current color of the draw state.

The pset() function sets a pixel in the graphics buffer.

This operation is affected by the draw state.

Examples

pset(10, 10, 7)                 -- sets (10, 10) to white
print(pget(10, 10), 0, 96, 7)   -- prints 7

pset(10, 10, 8)                 -- sets (10, 10) to red
print(pget(10, 10), 0, 104, 7)  -- prints 8

Repeatedly fill the screen with randomly colored pixels:

function _update()
  -- _update() is required for game loop 
end

function _draw()
  for x=0,127 do
    for y=0,127 do
      pset(x, y, rnd(16))
    end
  end
end

See also