flipperino.lua - Gravity Flip 2.1 Surprise Summer Update
Posted: Fri Dec 31, 2021 2:36 pm
by Zeus guy
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.

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:
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:
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:
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:
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
local flipperino = require("flipperino")
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;
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
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
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:
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.
- flipperino.lua
- Old test level (includes things that work and things that don't, I might update this at some point)
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.
Now, here's what you want to see.
"Cool", I hear you say, "but how do I use it?", you ask.
It's easier than you might expect, actually.
Question: This is a complex script, are you sure everything still works as it should?
Answer: No.
So, where's the download? Right here, of course.
Will I update this again? Probably, who knows. For now, here's what may or may not come in a future update:
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.
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


"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:
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:
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:
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
local flipperino = require("flipperino")
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;
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
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.
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.