Shirakumo/trial

Runnable Tilemap / Sprite examples?

Closed this issue · 10 comments

The wolf sprite example defined like so:

(define-example sprite
  :title "Animated Sprites"
  (enter (make-instance 'simple-sprite :sprite-data (assets:asset :wolf) :name :sprite) scene)
  (enter (make-instance 'sidescroll-camera :zoom 10.0 :target (node :sprite scene)) scene)
  (enter (make-instance 'render-pass) scene))

unfortunately doesn't compile, due to assets not existing. The cat.png asset exists in data/, and I was wondering if :wolf (and also the :tilemap from tilemap.lisp) used to also be included somewhere.

For now I'll follow the Sprites page directly.

Thanks again.

? it sure does compile, what are you talking about.

It doesn't seem to compile on my end, nor is there any filename with "wolf" in it in the repo. Is something perhaps unpushed?

I also tried (// 'trial 'wolf), but that didn't seem to work either. What am I overlooking here?

Ah seems like in general, sprites need to be called via asset, not //, or else a condition is raised in handle when attempting to render. Seems like sprites can't be "placeheld"?

I think you’re missing trial-assets: https://github.com/Shirakumo/trial-assets

That would be it, thanks!

And now I see that the examples are bundled and released separately here. My issue was that I had naively attempted to replicate the Wolf example in my own code, similar to the Quickstart.

I will add a note to the Examples page later about this.

The examples use their own package, which has its own nicknames and macros and everything. Why would you assume you can just copy-paste code willy-nilly into a different environment and have it work?

The assets used for the examples are also really unrelated to the actual code that they illustrate. The assets are separated into the trial-assets repo exactly so they don't get pulled in for every project.

Why would you assume you can just copy-paste code willy-nilly into a different environment and have it work?

To clarify, I was attempting:

(enter (make-instance 'simple-sprite :sprite-data (assets:asset :wolf) :name :sprite) scene)

in my own setup-scene. I had assumed it would work because using cat.png had worked in the Quickstart guide, and I thought the Examples would function in the same way. That was wrong, because I was unaware that the examples were bundled separately by you here.

Trial's own asset function takes two args and comes from the trial package. This is an asset function that takes one argument and comes from a different package altogether.

Thanks for the clarification, I understand the difference now.

While you're here, can you elaborate on why // isn't to be used for sprites, as in:

(make-instance 'animated-sprite :sprite-data (asset 'workbench 'sprite))

found on the Sprites page? Indeed // causes explosions (as did experimental attempts to call stage on sprites).

// returns a resource like a texture or a buffer. The sprite needs additional metadata to function, which is only present on the asset.