Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+2)

thanks for the quick reply,

i'll stay tuned for this update, it might help out!

for your solution, do you mean i would chop up the image into smaller chunks at runtime, at an increasing offset, and paste them over the 'viewport' canvas every couple frames? that would have me discard zazz, i take it.

i considered a system where i scroll a smaller texture and replace it when it reaches the end, but i couldn't think of a way to implement it with my knowledge of lil. it sounds like your idea is better, if you have an example of it at hand i'd love to try it!

going over my assets again i can see that around 4k i finally lost the warping, so that tracks.

(+2)

Let's say we have a wide canvas with graphics in it, "source", a smaller display canvas of the same height, "target", and a field for keeping track of how far we've scrolled, "offset". In this example "target" is marked as "volatile"- since we'll be redrawing it on each frame- and "animated"- so that it gets a view[] event for redrawing itself each frame:


We can nearly achieve a horizontal scroll effect by filling in target's view[] event handler to increment the number in "offset", wrap it based on the size of "source" using the modulus operator "%" (note that this operator takes its arguments in the opposite order of modulus/remainder in many non-Lil programming languages!) and pastes a chunk copied from "source" onto "target" based on this horizontal offset:

on view do
 offset.data:offset.data+2
 x:source.size[0]%offset.data
 target.paste[source.copy[x,0 target.size]]
end

It looks like this:


When our offset reaches the edge of "source", we're missing a screenful of graphics on the right edge. Here's one way to patch it up:

on view do
 offset.data:offset.data+2
 x:source.size[0]%offset.data
 target.paste[source.copy[x,0 target.size]]
 w:source.size[0]-target.size[0]
 if x>w
  x2:target.size[0]-x-w
  target.paste[source.copy[0,0 target.size] x2,0]
 end
end


Here's the whole card as an example you can copy and paste:

%%CRD0{"c":{"name":"home","widgets":{"source":{"type":"canvas","size":[460,100],"pos":[26,46],"image":"%%IMG3AcwAZAKEj6nL7Q+jnLTai7PevPsPhuJIluaJpurKtu4Lx/JM1/aN5/rO9/4PDAqHxKLxiEwql8ym8wmNSqfUqvWKzWq33K73Cw6Lx+Sy+YxOq9fstvsNj8vn9Lr9js/r4YG+/w8YuDdIGOVXiJi4FZAhqPgIicOIETgZeYnZYjnxl+n5ybIp0QdaamoiCpF6ytpKabHqKjvbEOtgS5ubi7vAq/vL6psgDFz8SXyAbLz8qAzgzBxN6AwtbX1Hfa2Nmb3tTVXd0f2td0hnHgpLXp48RxquUQ2/LiY6v2h5r75PL0eqoO9Kqn8p5PXzdyvgFFsKVb062IZgQjQSexVsBFFNRVUNlRDbGGKeso4j0GWsAI9kEZC3UG0w2YuljX8qpckc9eXmxJIeBh7SKcPeSZziavIAypFn0U7JjIqzOLQlCKQeO1KlcPWCUw4MozIwmnVIWE5KRWx9+eCsq7NjfbBVWVOtVmFyTdVtmwMvLKtmd4z0+kyT3hgwL37gq2NcxsEv6z4l3FChY04GV1KswdhApciYDzPdKyml5ck9Mk+9t+qz1humhzmSOlMf6Xjt6h0VnTBr69MnNquesXv26tpghGOtHOG3a7e7jTQPDERoTiFh5fkW+/xHds3aY3Yx3ggZ+NjjURSe6ha2wPLhk5s5j0Q5Cfbe09J3uQToffJHALnYj4B4AKLnxE0D8qcdfOmwBs12MCiYRFcRORgehcMBN5iFKhzIG1RuyLcChMBBFhmHyZkYEkAo+gViSCJ2FsqLlKyoIhev4VFJTzJKcppvdwWhIWDH7dhUkCVwFltpNHrlY45NiERkiLM1aaSQdeDGnJVapojSkk1tCSZXWPXnZZh2ERVfj1WaqYgvZe5UIZtD4fJmUqDJyWR9UOiGp5VOgkNXn4JWIdOagx4qmIeILrrnjYw+Cmmkkk5KaaWWXopppppuymmnnn4Kaqiijkpqqaaeimqqqq7KaquuvgprrLLOSmuttt6Ka6667sprr77+Cmywwg5LLDAFAA==","scale":1},"target":{"type":"canvas","size":[100,100],"pos":[26,196],"locked":1,"animated":1,"volatile":1,"script":"on view do\n offset.data:offset.data+2\n \n x:source.size[0]%offset.data\n target.paste[source.copy[x,0 target.size]]\n \n w:source.size[0]-target.size[0]\n if x>w\n  x2:target.size[0]-x-w\n  target.paste[source.copy[0,0 target.size] x2,0]\n end\nend","scale":1},"offset":{"type":"field","size":[100,20],"pos":[265,196]}}},"d":{}}

Alternatively, you could make the graphics in "source" include an extra duplicate screenful at the end, and adjust where you wrap the "x" coordinate. Then there's no need for the "fixup" part of the script, but preparing the graphics in the "source" canvas might be more annoying and it'll take up a bit more space in the file.

To be able to scroll both left and right, you'd need to similarly handle a fixup on the left edge of the display, and so on.

Does that make sense?

(+1)

yes! that makes sense.

i've gone ahead and implemented this, but sadly the poor performance persists. it's got to come down to the large textures then, not to mention scrolling three at once.

for the purposes of this prototype i have enough to move on to godot now (as was the plan regardless) and leave this test as is. thanks for your time and the breakdown, i'll definitely check out version 1.72 when it comes along!

cheers