Basic frame randomization

///my sprite tile
on load do
  f = random 2
  frame f
  log "{f}, {frame};"

Room with 11 sprite instances
Expected: log = "0, 0; 2, 2; 2, 2; 1, 1; 0, 0;..." //one pair for each instance
Actual: log = "[random num 0,1,2], 0" //one time only

I have a tile with 3 frames (0,1,2) I am trying to tell all instances of the tile to randomize their frame on load. However, frame only returns 0. Why isn't this working?

I'm not sure but I'd say you can't do that on load event. I'm assuming the room hasn't been "created" yet. Try to use on enter event instead.

1 Like

Load is "called once on the game, each room, and each tile when all assets are first loaded" (Playdate PulpScript)

i.e. load is being called on a tile's prototype when the game is first launched, not on each instance of a tile in a room when a room is entered.