flipperino.lua - Gravity Flip 2.1 Surprise Summer Update

Share and discuss custom LunaLua code and content packs for SMBX2.

Moderator: Userbase Moderators

Zeus guy
Spiny
Spiny
Posts: 26
Joined: Fri Dec 20, 2013 12:46 pm

flipperino.lua - Gravity Flip 2.1 Surprise Summer Update

Postby Zeus guy » Fri Dec 31, 2021 2:36 pm

flipperino.lua

Gravity Flip 2.1 Surprise Summer Update

It's been sitting on my hard drive for 7 months

So you want to flip gravity. Cool. Here's what you can do with this technology.
Image
Image

That's amazing. Here's how you use it.
How to use: show
First things first, you need to download the lua file, place it wherever your level is and use something like this:

Code: Select all

local flipperino = require("flipperino")
Of course, you'll probably want to use it after downloading it. In order to flip the level, you just need to activate an event called "flip".
You may also activate events called "flipUpsideDown" or "flipNormal" if you want, for example, a switch that only turns the level upside-down, no matter how many times you activate it.

But maybe you don't want a switch, maybe you want a BGO that flips the screen when you touch it. That's possible too, but you'll need to write a few lines of code. On your level's onStart function, add something like this:

Code: Select all

flipperino.flipBgos[76] = true;
flipperino.unflipBgos[78] = true;
When a player collides with one of the BGOs defined in the flipBgos array, in this case BGO number 76, the screen will turn upside-down.
Same thing for the unflipBgos array, which will turn the screen back to normal.

When the screen is flipped, sound effect number 13 is played. In order to change that, you'll want to modify the value of flipperino.flipSound.

If for some reason you don't want the camera to flip with the level, you can set flipperino.showMirrored to false.

So far so good, right? Well, here's the fun part. You have to create a new folder inside of your level folder, where all the custom graphics are, called "flipped". In there, you must add a copy of most graphics used in the level, and flip them upside-down. For animated graphics, don't flip the whole image, flip each frame individually. Here's a list of the graphics that you'll have to flip:
  • Sizeable blocks
  • Background objects
  • Npcs
  • I think that's it, basically flip everything except for normal blocks and the background
And that's pretty much it, open the level and everything should work. However, if your level is taller than the screen, the background might not be aligned when you flip it. Don't worry, it's an easy fix. Hard to believe that this used to be the hard part.
Let's say you want to use the Crateria background, number 16. You'll have to create a txt file named "background2-16.txt", with the following contents:

Code: Select all

[BG]
img="background2-16.png"
name="BG"
parallaxX=1
parallaxY=1
alignY=CENTRE
alignX=CENTRE
repeatX = true
repeatY = true
Change whatever you need, but I'm pretty sure both parallaxY and alignY are needed for it to work properly.

One last thing, before we move on. You may have noticed in the GIFS section of this post that there are stretches (floor/ceiling boos, does anyone actually call them stretches?). As you may have guessed, the ceiling version and the floor version turn into each other when the screen is flipped. Surprisingly, they work flawlessly. So, if you need to turn an NPC into another NPC, here's the code you'll want to copy:

Code: Select all

flipperino.flipNpcs[323] = 324;
flipperino.flipNpcs[324] = 323;

So, where's the download? Right here, of course.
Download and credits: show
Downloads: Credits:
This section mainly exists because I used a few lines of code from MrDoubleA's One-Way Walls (great script btw) that I wanted to rewrite but, as you can see, I ran out of time. Oh well, I'll probably change them later.

That's all, here's the old post.
Old post, who cares: show
So, does anyone remember that time when I came back to update something after 5 years? Well I'm doing it again.

Backstory (Very sad, you will cry): show
Back in 2016, when I barely knew how to code, I released the very flawed Gravity Flip script. It changed the player's graphics and pushed them to the ceiling, and that's pretty much it.

Then, in 2019, MaGLX3 happened, and my level included a modified version of this gimmick, which simply flipped the screen when the player was teleported to a flipped section. How boring.

Finally, in April 2021 I decided to implement it properly. I made some decent progress, but then I had to stop working on it, as I had more important things to do, until late November.

And now, a few hours before the end of the year, here I am typing this. I had to post this today, as technically it's still five years later.

Now, here's what you want to see.
GIFs: show
Image
Image

"Cool", I hear you say, "but how do I use it?", you ask.
It's easier than you might expect, actually.
How to use: show
First things first, you need to download the lua file, place it wherever your level is and use something like this:

Code: Select all

local flipperino = require("flipperino")
Of course, you'll probably want to use it after downloading it. In order to flip the level, you just need to activate an event called "flip".
You may also activate events called "flipUpsideDown" or "flipNormal" if you want, for example, a switch that only turns the level upside-down, no matter how many times you activate it.

But maybe you don't want a switch, maybe you want a BGO that flips the screen when you touch it. That's possible too, but you'll need to write a few lines of code. On your level's onStart function, add something like this:

Code: Select all

flipperino.flipBgos[76] = true;
flipperino.unflipBgos[78] = true;
When a player collides with one of the BGOs defined in the flipBgos array, in this case BGO number 76, the screen will turn upside-down.
Same thing for the unflipBgos array, which will turn the screen back to normal.

When the screen is flipped, sound effect number 13 is played. In order to change that, you'll want to modify the value of flipperino.flipSound.

If for some reason you don't want the camera to flip with the level, you can set flipperino.showMirrored to false.

So far so good, right? Well, here's the fun part. You have to create a new folder inside of your level folder, where all the custom graphics are, called "flipped". In there, you must add a copy of every graphic used in the level, and flip it upside-down. For animated graphics, don't flip the whole image, flip each frame individually. If you didn't like that, wait until you hear what's coming next.

There is only one thing that I would consider hard, and that is setting up backgrounds.
Basically, you want to add two layers, both centered, with one of them called "FLIP", with an opacity of 0 and a priority of 99. Here's an example:

Code: Select all

[BG]
img="background2-8.png"
name="BG"
parallaxX=1
parallaxY=1
alignY=CENTRE
alignX=CENTRE
repeatX = true
repeatY = true

[FLIP]
img="flipped/background2-8.png"
name="FLIP"
parallaxX=1
parallaxY=1
alignY=CENTRE
alignX=CENTRE
repeatX = true
repeatY = true
priority = -99
opacity = 0
As you can see, the FLIP layer uses a flipped version of the background. Just flip the original background upside-down and it should work. I guess you could add more layers, or an animated background, but I'm certainly not going to try. Good luck with that.

One last thing, before we move on. You may have noticed in the GIFS section of this post that there are stretches (floor/ceiling boos, does anyone actually call them stretches?). As you may have guessed, the ceiling version and the floor version turn into each other when the screen is flipped. Surprisingly, they work flawlessly. So, if you need to turn an NPC into another NPC, here's the code you'll want to copy:

Code: Select all

flipperino.flipNpcs[323] = 324;
flipperino.flipNpcs[324] = 323;

Question: This is a complex script, are you sure everything still works as it should?
Answer: No.
Known issues: show
  • In vertical sections, dropped items move wildly while jumping. Not much I can do there, at least it still works.
  • When interacting with an NPC, the icon appears under the npc instead of above it. Again, not much I can do there.
  • Effects aren't flipped. I don't even know if there's a way to fix this.
  • ?-blocks work, and items will fall to the floor, but mushrooms will get stuck. You may want to change their speed to 0 so that they don't even try to move.
  • Some flying npcs will stop flying when you turn the level upside-down. This happens because their nogravity is set to false even though it shouldn't. This mostly affects vanilla NPCs, and it can probably be solved with a txt file.
  • Throwable objects mostly work, but things like shells get stuck on the floor.
  • Multiplayer works surprisingly well, so I'm saving a spot here for the gamebreaking issues that will surely appear.

So, where's the download? Right here, of course.
Download and credits: show
Downloads: Credits:
This section mainly exists because I used a few lines of code from MrDoubleA's One-Way Walls (great script btw) that I wanted to rewrite but, as you can see, I ran out of time. Oh well, I'll probably change them later.

Will I update this again? Probably, who knows. For now, here's what may or may not come in a future update:
Future features...?: show
  • Not having to manually flip every single graphic would be great. I tried to use shaders but I couldn't get them to work the way I wanted them to.
  • I'd like to make all npcs work the way you'd expect them to, but we all know that's not going to happen. At least I'd like to make shells and mushrooms move while touching the ground.
Last edited by Zeus guy on Tue Aug 16, 2022 8:52 am, edited 1 time in total.

Chilly14
Snifit
Snifit
Posts: 236
Joined: Thu Jul 18, 2019 10:28 pm
Flair: wash your hands and stay at home
Pronouns: he/him

Re: flipperino.lua - Gravity Flip 2.0 Surprise Christmas Update

Postby Chilly14 » Fri Dec 31, 2021 3:12 pm

Wow, this looks really cool! I'll have to try it out!

FutureNyanCat
Eerie
Eerie
Posts: 799
Joined: Fri Dec 20, 2013 8:39 pm
Flair: Species: Felis robotus
Pronouns: He/Him
Contact:

Re: flipperino.lua - Gravity Flip 2.0 Surprise Christmas Update

Postby FutureNyanCat » Fri Dec 31, 2021 10:51 pm

Wait holy shit it's you Zeus guy, nice to see you again. This script looks like fun to use, someone's probs gonna make a VVVVVV level out of this.

Murphmario
2025 Egg Hunter
2025 Egg Hunter
Posts: 2389
Joined: Fri Dec 20, 2013 7:07 pm
Pronouns: he/him

Re: flipperino.lua - Gravity Flip 2.0 Surprise Christmas Update

Postby Murphmario » Sun Jan 02, 2022 2:30 am

I was not expecting this to be updated. This is really great, though hopefully the issue with the flipped graphics is fixed at a later time. The process sounds sorta tedious.

Alagirez
Ludwig von Koopa
Ludwig von Koopa
Posts: 3617
Joined: Tue Dec 02, 2014 2:28 am
Flair: Legalize Awooo!
Pronouns: He/Him/That wolf
Contact:

Re: flipperino.lua - Gravity Flip 2.0 Surprise Christmas Update

Postby Alagirez » Sun Jul 24, 2022 8:53 am

Hello. I'm currently using this library and I need help with the background setting.
For some reason the BG didn't flip when I touch the "Flip" BG, as you demonstrate in your level test. (It's supposed to be a .gif file but ok)
I already put the flipped version of my background in the "flipped" folder, but still didn't work.
Image
I also put the extra settings on the background2.txt (I basically copied the example code of the main post. I only changed the filename into background2-32.png and remove the repeatY settings), but still didn't work. Any solutions?

Zeus guy
Spiny
Spiny
Posts: 26
Joined: Fri Dec 20, 2013 12:46 pm

Re: flipperino.lua - Gravity Flip 2.0 Surprise Christmas Update

Postby Zeus guy » Tue Aug 16, 2022 8:29 am

Sooo I may have forgotten to post an updated version back in January. Whoops.
Alagirez wrote: I also put the extra settings on the background2.txt (I basically copied the example code of the main post. I only changed the filename into background2-32.png and remove the repeatY settings), but still didn't work. Any solutions?
It's been a few weeks but hopefully it's not too late to fix this.
From your screenshot I can see that you don't have file extensions shown, so make sure the txt file is called "background2-32".
However, even if that doesn't work, it doesn't really matter, because I have an updated version where the background draws itself automatically. Same thing for all blocks except sizeables.

Basically, here's what you need to do:
  1. Download the updated version from this link
  2. Remove the background from the flipped folder, and remove the [FLIP] section from the txt (or just copy what's included in the lua file)
  3. Remove all blocks from the flipped folder, except for sizeables (couldn't get them to work)
And with that, everything should work the way it's supposed to.
Hope that was helpful!

Alagirez
Ludwig von Koopa
Ludwig von Koopa
Posts: 3617
Joined: Tue Dec 02, 2014 2:28 am
Flair: Legalize Awooo!
Pronouns: He/Him/That wolf
Contact:

Re: flipperino.lua - Gravity Flip 2.0 Surprise Christmas Update

Postby Alagirez » Tue Aug 16, 2022 9:00 am

Zeus guy wrote:
Tue Aug 16, 2022 8:29 am
Sooo I may have forgotten to post an updated version back in January. Whoops.
Alagirez wrote: I also put the extra settings on the background2.txt (I basically copied the example code of the main post. I only changed the filename into background2-32.png and remove the repeatY settings), but still didn't work. Any solutions?
It's been a few weeks but hopefully it's not too late to fix this.
From your screenshot I can see that you don't have file extensions shown, so make sure the txt file is called "background2-32".
However, even if that doesn't work, it doesn't really matter, because I have an updated version where the background draws itself automatically. Same thing for all blocks except sizeables.

Basically, here's what you need to do:
  1. Download the updated version from this link
  2. Remove the background from the flipped folder, and remove the [FLIP] section from the txt (or just copy what's included in the lua file)
  3. Remove all blocks from the flipped folder, except for sizeables (couldn't get them to work)
And with that, everything should work the way it's supposed to.
Hope that was helpful!
Glad to see a response from you c:
Just tried the steps that you just told me, and it's actually work! Thank you so much for that!

Zeus guy
Spiny
Spiny
Posts: 26
Joined: Fri Dec 20, 2013 12:46 pm

Re: flipperino.lua - Gravity Flip 2.0 Surprise Christmas Update

Postby Zeus guy » Tue Aug 16, 2022 10:26 am

Alagirez wrote:
Tue Aug 16, 2022 9:00 am
Just tried the steps that you just told me, and it's actually work! Thank you so much for that!
That's great, I'm glad it worked! If anything else happens, please let me know.

Halzk
Koopa
Koopa
Posts: 15
Joined: Tue Apr 16, 2019 10:20 am

Re: flipperino.lua - Gravity Flip 2.1 Surprise Summer Update

Postby Halzk » Fri Nov 11, 2022 11:34 am

Hi there. Sorry to bother you I have noticed a "glitch". First of all, I didn't think you coded flipping gravity for NPCs too (I thought only the gfx flipped) but when I flip the level all the NPCs freezes
Image
IDK where this comes from. If you could help me, that would be appreciated :).

zxcv
Volcano Lotus
Volcano Lotus
Posts: 511
Joined: Tue Aug 05, 2014 10:10 am
Pronouns: They/She

Re: flipperino.lua - Gravity Flip 2.1 Surprise Summer Update

Postby zxcv » Thu Dec 22, 2022 10:49 am

Also, keypads fall and clip through the ground ending in the backrooms.

Added in 9 minutes 15 seconds:
Also for some reason, the BGO arrows from SMW are flipped together with the gravity, except for the horizontal ones.

These arrows:
Image


Return to “LunaLua”

Who is online

Users browsing this forum: No registered users and 1 guest

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari