I shoehorned in a way to have larger sprites in GB Studio games. With the immense power granted by eject engine, I hacked together a function that checks a certain set of variables to determine if a sprite should be parented to another sprite, and if so, forces its position to be adjacent to it at all times. The parent sprite is free to move as a normal sprite, and all of its children will happily follow.

It's kludgy and hacky, probably really inefficient, and presumably prone to failure. But it's also really cool, so check it out!

If you wish to use it in your own game, and let me make it abundantly clear you are doing so at your own risk, these are the steps you should take:

  1. Eject the engine in your project, if you haven't already.
  2. Copy assets/engine/src/core/ParentedActors.c to the equivalent folder in your project directory
  3.  Do the same with assets/engine/include/ParentedActors.h
  4. Open assets/engine/src/core/Core_Main.c in a text editor
  5. Insert the line #include "ParentedActors.h" immediately after the line that says #include "main.h"
  6. Insert the line PositionParentedActors(); before the first line that says UpdateActors();
  7. Save the file

Now, when you run your game, it will take a little while to build the first time, but if the emulator opens, then you did everything right.

To actually make use of it, you will need to make an On Init script with two events. It will look something like this:Actor Configuration

Variable: Set To Value has two fields, and both are important:

  • The variable field on top tells the game which actor should be the child. The variable ID should be the actor's number + 90. In this instance, I want Actor 3 to be the child, so I set it to $93$
  • The value field below tells the game which actor should be the parent. Here, it is set to 2, standing for actor 2. If you want the player to be the parent, set it to 10.

Variable: Add Flags has 8 checkboxes. Flags 5-8 tell the game where the child should be positioned relative to the parent. Flags 1-4 should be left unchecked.

  • Flag 5 sets the child to be left of the parent
  • Flag 6 sets the child to be up from the parent
  • Flag 7 sets the child to be down from the parent
  • Flag 8 sets the child to be right of the parent

They are in the same order as the Direction buttons for easy reference. 

If you did everything right, when you run the game, everything should just magically work. The child actor will follow the parent actor wherever it goes.

Note: I realized as I was typing this up that I didn't take into account the fact that GBS2.0 supports more than 9 actors. As a result, future updates to this patch will be incompatible with the current variable configuration.

StatusPrototype
PlatformsHTML5
Rating
Rated 5.0 out of 5 stars
(2)
Authorum3k

Download

Download
C Hax_project01.zip 118 kB

Comments

Log in with itch.io to leave a comment.

Very Nice Job !

(1 edit)

there's a glitch that allows me to throw sprites around using the flags, it's very funny to watch what happens. Helps when you need sprites to dissapear. Thanks a lot, despite it not working for bigger sprites. I think it adds to the experience.

(1 edit)

How can you make a 6 tile actor like your rover change facing direction by swaping the 2 left tile with the 2 right tile and mirror the 2 middle tile

I have the same issue!

(+3)

It works fine in GBS 2.0 - the author is just saying it's not written for more than 9 actors.  I was able to bump it up to 14 by starting the variable count at 80 and modifying the "ParentedActors.c" file with this code:

void PositionParentedActors() {
  UBYTE j;
  // Linked sprite magic
  for (UBYTE i = 1; i < 15; ++i) // loop through the control variables
  {
  UBYTE parent = script_variables[i+80] & 0x0F;
  UBYTE L = script_variables[i+80] & 0x10;
  UBYTE U = script_variables[i+80] & 0x20;
  UBYTE D = script_variables[i+80] & 0x40;
  UBYTE R = script_variables[i+80] & 0x80;
  // set position relative to player
  if (parent == 15) {

Thanks a lot

Is this ready for GB Studio 2.0?

when might it be fully ready?

(-1)

This is so cool! Am I understanding this correctly that it’s not compatible with GBstudio 2 yet?

 future updates to this patch will be incompatible with the current variable configuration.

Can't wait to try this! Thank you!

Love the astro-style sprites. Great stuff.

This is super legit...

(+7)

Hah, awesome! Super hacky but looks great! :D

Nice work!

super! Love your work so far