Have I stumbled on a feature or a bug?
The following two statements are mathematically equivalent but result in different behavior in the Pulp Player:
fill "black" at x,y,w,h
Above: this is normal code with positive integers. it fills a box at the given coordinates which lasts for a single frame. if you want this to persist you darn well better run this code every single frame.
Below: this is unusual(?) code with negative width and height. it fills a box at the given coordinate which lasts until i draw something else over it. if you want this box to go away you darn well better draw something else on top of this box.
fill "black" at x,y,w,h
Is this a feature or a bug? I don't have hardware yet, but I stumbled onto this while scripting up something to draw lines and i wonder if this behavior would work on real hardware? If it's a bug in the Pulp Player then I suppose i'll file a bug report, but if it's a feature... this will save me a lot of compute cycles
Haha, this is definitely a bug. But it’s a bug in the Pulp runtime so it would work on the hardware too.
What’s happening is the logic that keeps track of dirty tiles (essentially any tile that is animating and just changed frames or is overdrawn by one of the drawing functions) isn’t accounting for negative dimensions.
On the one hand, clever hacks are always fun and saving cycles always a good thing. But on the other, it’s an unintuitive method to achieve an unsupported effect.
fill function is really intended for simple UI elements like a bar meter so I’m wary of encouraging complex drawing with it. Pulp is really built around the idea of tiles and PulpScript for adding simple interactions. The full SDK is much better suited to more ambitious rendering techniques.
That said, there are definitely tile-based justifications for persisting drawing across frames, eg. static hud labels, frames, and icons, even bar meters that change infrequently. So maybe PulpScript could use a state that disables updating dirty rects while active. Definitely something to think about!
Thanks for answering
It would be very interesting to enable some way to purposefully say "don't treat this fill as dirty". If you pursue that, it'd be useful to also provide a way to say "all those prior fills that weren't treated as dirty - fix that now".
It definitely makes sense that the SDK would be better suited to this. I'm really looking forward to getting my hands on that! Till then Pulp is a fun place to tinker, prototype, and iterate on game concepts.