Log In  

Here comes another newbie question:

If I've got a map of 32*48 tiles (taller than wide), how should I handle the map data in order to print it directly with map() function?

I saw that map can be extended to 64 tiles (height) if you use 0x1000 - 0x2000 memory, but I don't know how to tell the map function to use this extra space.

Searching some post I've read that implementing some kind of map data streaming with peek and poke is a good a idea. Is there some resources, carts or tutorial that can helps me?

P#86571 2021-01-19 08:24

I'm struggling with a function that randomly picks up an element from a table with ponderated probability. For now this is my current code:

items = {
} -- total probability = 1

function rnd_item()
 local rnd_number = rnd() -- between [0,0.99999)
 local i = 1
 local sum = items[i].probability
 while sum < rnd_number do
  i += 1
  sum += items[i].probability
 return items[i]

What is the problem with the implementation? Right, In some cases it crashes because 'i' goes out of bounds. It seems that the problem occurs when rnd_number is near 1 (i.e. 0.99997) but I can't figure out how I fix it.

Is there a better implementation to solve the problem?

P#84674 2020-11-25 17:51 ( Edited 2020-11-25 17:51)

Hi mates,

I'm having some issues with an unexpected (for me) behaviour of rnd() and tostr() functions.

Why this fragment of code prints value 1 if it's supposed that calling rnd() with no arguments produces values from 0 to 0.99999? Does tostr() perform some kind of ceil()?

local rnd_number = rnd()



I need to avoid that '1' value.

P#84671 2020-11-25 12:07 ( Edited 2020-11-25 12:09)

Cart #animator8x8v03-0 | 2020-11-11 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Hi folks!

Last month I was trying out some Pico-8 features and finally brought them all together in my first cart.

It's a simple 8x8 pixels animation editor. It features:

  • Pixel editor with "Pencil" and "Fill color" tools.
  • Animations allow up to 12 frames.
  • Add/remove frames to the current animation.
  • Editable frame delay.
  • Play/pause animation controls.
  • Keyboard device for text input.
  • Export to PNG (only sprites, not metadata).

For now I have an alpha version because is not finished yet but I wanted to share with you some kind of build that allows me put my mind in another subject.

I've planned to add new features like multiple animations, export metadata capabilities, and much more, but for now this is the v0.1 release.


New 0.2 version including:

  • Fill tool fixed
  • Start/stop animation with toogle button
  • Export frames to clipboard

New 0.3 version including:

  • Rotate sprite clockwise and anti-clockwise tool
  • Undo tool with 12 actions memory per frame
P#83384 2020-10-26 22:46 ( Edited 2020-11-11 08:33)

Follow Lexaloffle:        
Generated 2021-04-18 08:03 | 0.086s | 2097k | Q:33