Extension Idea!

Hello! So I was thinking about something! What if you made an extension that can “glue” Sprites together! So it works like this! there is a block with a grid with 10*10 Images! Those images are 8 pixels big! Then you can make them so they fuse together! So basically Buildable modules! For e.g a Game where you can upgrade and switch parts and weapons! they work I guess by moving the sprites up and left until thy hit another sprite and stop!So you can make Images and put them together!
Thanks!

4 Likes

I had this same idea a while ago but never got around to doing anything with it. Would be pretty useful for things like fighting games, where characters normally have multiple sprites each with their own hitboxes. And also just for simple stuff like picking things up.

I think it would work something like this:

  1. You create a “group sprite” that you can attach other sprites to
  2. The group sprite has all the normal sprite properties, but the ones that are attached ignore changes to position/velocity/acceleration. Things like height, width, left, right, bottom, and top on the “group sprite” will be based on all sprites that are attached to the “group sprite”
  3. Each sprite can only be attached to one “group sprite”, and there will be a block like:
get group sprite that [sprite] is attached to
  1. There will also be a block that lets you control the position of the attached sprite:
set group offset for [sprite] to [x] [y]
  1. And there will be a “destroy all sprites attached to group sprite” block

@jwunderl what do you think of that? As an extension, not an included package.

6 Likes

Yup, that sounds good! And we shouldn’t forget the other one we were talking about, something that effectively wraps sprites.allOfKind and propagates the methods / etc to each sprite of the kind – just something to test in an extension (though likely does require a bit of work, have to subclass image as well if we want to get it fully working I think?).

The destroy all sprites attached to group sprite might be fine as just as the implementation for GroupSprite.destroy? Unless we think there is a common case for leaving around parts of a sprite after the main portion is destroyed.

Before we do that should probably fix (or alongside it) https://github.com/microsoft/pxt-arcade/issues/2989 though, because that makes it a huge pain to deal with subclasses in blocks.

(this does remind me a lot of one of the first extensions I started to write and then got distracted / wouldn’t have worked great at the time! it’s bad but it’s here, feels like so long ago / arcade was so different: https://github.com/jwunderl/pxt-procedural-sprites – it was supposed to be ‘give a base image and a bunch of arrays of images to act as stamps, and it will combine them into one for you randomly’)

2 Likes

Agreed, need to fix that bug for sure

So I came up with this! @jwunderl


that could work in an array I guess