Moving Layer Calculations

Need help with any SMBX game-related issues? Ask your questions here.
Forum rules
Before you make a topic/post, consider the following:
-Is there a topic for this already?
-Is your post on-topic/appropriate?
-Are you posting in the right forum/following the forum rules?
User avatar
Natsu
Ludwig von Koopa
Ludwig von Koopa
Posts: 2893
Joined: Sat Dec 21, 2013 2:40 pm
Current Project: It's a secret to everybody ...
Chat Username: NaviGator

Moving Layer Calculations

Postby Natsu » Sun Aug 17, 2014 2:35 pm

Ok, so same as I some people are starting to use this calculation for their own levels, and honestly, who wouldn't want some accurate moving layers? So I'm taking part of my time to explain two calculations that I'm using for my project.

If you want to calculate the speed you want for a moving layer to reach a certain position in a certain time of your choice, use the calculation below:
32 * (NºBlocks) / (Desired time) / 65 = (Desired Speed)

Though, if you want to calculate the desire time based upon a certain speed, use this calculation instead:
32 * (NºBlocks) / (Desired Speed) / 65 = (Desired time)
PixelPest wrote:Btw if you want to use more exact numbers if syncing issues are a problem use 2500/39 instead of 65 or in LunaLua code just use lunatime.toSeconds()
Note that the desired time can be deduced by replacing them like in any polynomial operation. Hope this helped.
Last edited by Natsu on Fri Nov 03, 2017 9:42 am, edited 2 times in total.
Discord quotes
Trace: You're a capable boi

User avatar
Natsu
Ludwig von Koopa
Ludwig von Koopa
Posts: 2893
Joined: Sat Dec 21, 2013 2:40 pm
Current Project: It's a secret to everybody ...
Chat Username: NaviGator

Re: Moving Layer Calculations

Postby Natsu » Sun Sep 14, 2014 8:30 pm

Sorry for the bump but I would like someone to stick this thread, just like I requested once I posted this.
Discord quotes
Trace: You're a capable boi

User avatar
HeroLinik
Cyan Yoshi Egg
Cyan Yoshi Egg
Posts: 3433
Joined: Fri Dec 20, 2013 1:28 pm
Current Project: Stupid university assignments :/
Location: I do not want you Stalkers.
Chat Username: Look below my avatar
Contact:

Re: Moving Layer Calculations

Postby HeroLinik » Tue Sep 16, 2014 10:48 am

Natsu wrote:Sorry for the bump but I would like someone to stick this thread, just like I requested once I posted this.
I agree. This is a helpful guide for any SMBX user, whether they are newbies or veterans, and it will save them time when trying to exact the speed/time of the moving layer. You should put the distance on there as well.
Image
I support: show
Lol, you got trolled. Move along, if you please.
Check out my content on YouTube! // Don't forget to check out my project as well!

User avatar
Natsu
Ludwig von Koopa
Ludwig von Koopa
Posts: 2893
Joined: Sat Dec 21, 2013 2:40 pm
Current Project: It's a secret to everybody ...
Chat Username: NaviGator

Re: Moving Layer Calculations

Postby Natsu » Tue Sep 16, 2014 10:54 am

@castlewars: The distance is the NºBlocks.
Discord quotes
Trace: You're a capable boi

User avatar
lighthouse64
Mouser
Mouser
Posts: 1817
Joined: Sat Apr 26, 2014 6:28 am
Current Project: Soundtrack stuff
Location: A house full of stuff with smbx things
Contact:

Re: Moving Layer Calculations

Postby lighthouse64 » Sun Sep 28, 2014 11:28 pm

Natsu wrote:Sorry for the bump but I would like someone to stick this thread, just like I requested once I posted this.
Well, It happened. :)
I love cheep cheep's Image :)
Creator of 100+ 8bit emojis
Smiley tongue fan ImageImage Image :P
I support:
Spoiler: show
Image
Image
My 1337 rank was quill Image
Squishy rex has been frozen! Image

Some quotes:
Spoiler: show
[19:59] <Lykie> jacob i swear to god
[19:59] <Lykie> I YELLED AT MY MOM
[19:59] <Jacob> Im sorry
[19:59] <lighthouse64> swearing is bad tho
[19:59] <Lykie> FOR MESSING UP THE PATTERN IN THE EGG CARTEN
[19:59] <Lykie> *CARTON
[20:00] <lighthouse64> lol ocd confirmed

User avatar
DatDude
Lakitu
Lakitu
Posts: 497
Joined: Wed Sep 03, 2014 5:58 am
Current Project: Super Mario: Battle For The Stars
Location: Singapore

Re: Moving Layer Calculations

Postby DatDude » Sat Oct 04, 2014 6:24 am

Wait, what does the "*" stand for?
My Project:
Spoiler: show
On Mafia i like lying, deceiving and trains. Wait, how did you get this information?!
I support these peeps.
Well, except MNIE, because he's drunk though but yeah.
Image

This is a block of text that can be added to posts you make. There is a 999 character limit.

User avatar
bossedit8
Toad
Toad
Posts: 6833
Joined: Fri Dec 20, 2013 12:35 pm
Current Project: Airship Attack 2
Location: Germany (Deutschland)
Chat Username: <3 bossedit8 <3
Contact:

Re: Moving Layer Calculations

Postby bossedit8 » Sat Oct 04, 2014 6:28 am

DatDude wrote:Wait, what does the "*" stand for?
That stands for Multiply. Like 2 * 10 = 20

User avatar
PROX
Boom Boom
Boom Boom
Posts: 1606
Joined: Sun Jul 06, 2014 8:50 pm
Current Project: Mushroom Kingdom Apocalypse

Re: Moving Layer Calculations

Postby PROX » Fri Nov 21, 2014 2:58 pm

I usually just do it in my head through trial and error and it works just fine lol
I believe and I accept Jesus Christ as my Lord and Savior. If you do, put this in your signature.

If it makes sense then it must make dollars

Youtube Channel: ProxyHax O.O

My Project (No logo yet): viewtopic.php?f=90&t=18321&start=20

My Graphics Pack:
Image

World Map Pack: viewtopic.php?f=31&t=20173

User avatar
Mista Epic
Banned
Posts: 315
Joined: Sat Aug 02, 2014 11:56 am
Current Project: Volcano Trouble

Re: Moving Layer Calculations

Postby Mista Epic » Sat Jan 31, 2015 2:52 pm

I've created a quick VBS file to help with this so you don't have to go through a calculator and do this. Excuse me for not making it a .EXE but I don't know how to code in VBScript or how to wrap VBScript or convert it to VBScript.

Download

I should also mention that because it is a Windows-based code, it should only work on Windows. But maybe it works on Mac or Linux or whatever. I don't know.
<Peach> Bowsers cock is the real reason I get captured
<Peach> It's pretty nice
<Panda> i see i didnt miss a lot then

Image

I support:
Spoiler: show
Image

Image

Image

Image

User avatar
[]Yaroslav269[]
Spiny
Spiny
Posts: 40
Joined: Wed Feb 25, 2015 11:10 am
Current Project: Luigi is Missing!
Location: Russia, Karelia, Nadvoitsy
Chat Username: Yaroslav269

Re: Moving Layer Calculations

Postby []Yaroslav269[] » Wed Apr 08, 2015 12:36 pm

Desired time in seconds?
This is a block of text that can be added to posts you make. There is a 999 character limit.
Image

User avatar
crusher169
Ripper II
Ripper II
Posts: 353
Joined: Tue Apr 22, 2014 9:09 am
Current Project: Getting my life together.
Location: Australia
Contact:

Re: Moving Layer Calculations

Postby crusher169 » Thu Apr 09, 2015 3:54 am

this just doesn't work for me for some reason, I keep trying it but it isn't accurate
I'm not good at making signatures.

User avatar
Trace
Lakitu
Lakitu
Posts: 434
Joined: Thu Jun 19, 2014 7:45 am
Location: up your ass
Chat Username: figure it out

Re: Moving Layer Calculations

Postby Trace » Mon May 25, 2015 10:44 am

wait, i dont get it. HOW am i supposed to calculate it?
I believe in Waluigi as my Lord and Saviour. If you do too, put this in your signature!

OwO

User avatar
RudeGuy
Luigi
Luigi
Posts: 4901
Joined: Fri Dec 27, 2013 7:36 am
Flair: help
Current Project: a random smw hack
Location: italy
Chat Username: rudeguy

Re: Moving Layer Calculations

Postby RudeGuy » Mon May 25, 2015 10:53 am

Trace42 wrote:wait, i dont get it. HOW am i supposed to calculate it?
Use the calculator and write the formula in the OP replacing what needs to be replaced. Is it really that hard?
im bored

User avatar
Trace
Lakitu
Lakitu
Posts: 434
Joined: Thu Jun 19, 2014 7:45 am
Location: up your ass
Chat Username: figure it out

Re: Moving Layer Calculations

Postby Trace » Mon May 25, 2015 11:09 am

what i get when i try that is what i always get: invalid Input
I believe in Waluigi as my Lord and Saviour. If you do too, put this in your signature!

OwO

User avatar
RudeGuy
Luigi
Luigi
Posts: 4901
Joined: Fri Dec 27, 2013 7:36 am
Flair: help
Current Project: a random smw hack
Location: italy
Chat Username: rudeguy

Re: Moving Layer Calculations

Postby RudeGuy » Mon May 25, 2015 11:11 am

Trace42 wrote:what i get when i try that is what i always get: invalid Input
Then what about using one of the milion of calculators in the internet?
im bored

User avatar
Drachenbauer
Hoopster
Hoopster
Posts: 166
Joined: Sun Sep 13, 2015 3:24 pm

Re: Moving Layer Calculations

Postby Drachenbauer » Thu Oct 01, 2015 5:27 pm

someone asked, if the time in secconds.
but got no answer...
i need this answer too.
i want to make an item move 1 block (32pix) up and needs 1 sec for this distance.
i calculated this and got a vaule with a long tail of didits after the comma...
speed: 0,4923076 (endless: the sequence 923076 will repeat forever after the comma)
is that right

User avatar
RudeGuy
Luigi
Luigi
Posts: 4901
Joined: Fri Dec 27, 2013 7:36 am
Flair: help
Current Project: a random smw hack
Location: italy
Chat Username: rudeguy

Re: Moving Layer Calculations

Postby RudeGuy » Fri Oct 02, 2015 1:53 am

Drachenbauer wrote:someone asked, if the time in secconds.
but got no answer...
i need this answer too.
But it's so obvious, even the delay (the time) says that it's in seconds.
Drachenbauer wrote: is that right
Use just the first 4 numbers after the comma.
im bored

User avatar
Natsu
Ludwig von Koopa
Ludwig von Koopa
Posts: 2893
Joined: Sat Dec 21, 2013 2:40 pm
Current Project: It's a secret to everybody ...
Chat Username: NaviGator

Re: Moving Layer Calculations

Postby Natsu » Sat Dec 19, 2015 4:00 pm

I apologize to those that asked on this thread, but around a year and a half I left the forums because of studies. So now I'll try to answer as many questions as possible. If you have trouble with the calculation just let me know and I'll answer as soon as possible.
Discord quotes
Trace: You're a capable boi

User avatar
Quantumenace
Pokey
Pokey
Posts: 236
Joined: Mon Dec 28, 2015 2:17 am

Re: Moving Layer Calculations

Postby Quantumenace » Sun May 22, 2016 3:15 am

If I had realized this thread was a sticky I'd have posted my findings here to begin with. It's actually a little more complicated than this. The game is run in "ticks" (equivalent to frames), the speed is measured in pixels per tick, and you can't have a fraction of a tick; the layer will move a distance equal to the speed*ticks. 1 block length is equal to 32 pixels.

What makes it dicey is that the number of ticks are a bit off from what is expected.
Spoiler: show
0.1 second = 7 ticks
0.2 = 14 ticks
0.3 = 21 ticks
0.4 = 27 ticks
0.5 = 33 ticks
0.6 = 40 ticks
0.7 = 47 ticks
0.8 = 53 ticks
0.9 = 59 ticks
1.0 = 66 ticks
1.1 = 73 ticks
1.2 = 79 ticks
1.3 = 85 ticks
1.4 = 92 ticks
1.5 = 99 ticks
1.6 = 105 ticks
1.7 = 111 ticks
1.8 = 118 ticks
1.9 = 125 ticks
2.0 = 131 ticks

8.0 = 521 ticks
No wonder it's so hard to prevent cycling layers from getting farther and farther off if you don't use the same speed and delay both ways. A 2 second delay isn't even the same as two 1-second delays!

The number of ticks for a given number of seconds appears to be:

(seconds*65)+1, rounded to the nearest ODD number if it ends in .5

Normally .5 is rounded to the nearest even number, but presumably it's rounded before the 1 is added, resulting in it rounding towards odd numbers instead.

In that case the distance moved (in pixels) is:

((seconds*65)+1, rounded to the nearest ODD number if it ends in .5)*speed

The extra 1 is what tends to throw off the timing of layers. For example, a speed of -1 for 2 seconds and a speed of 2 for 1 second moves the layer -131 and then +132, causing it to go further off by 1 each cycle.

However, moving it by -1 for 1 second and +2 for 0.5 seconds does work because the number of ticks for 1 second is twice the number for 0.5 seconds. Another solution is to split up the first delay, so you have the layer moving -1 for 1 second, then -1 for 1 second again, then +2 for 1 second.

User avatar
HVMetal
Pokey
Pokey
Posts: 234
Joined: Tue Dec 29, 2015 9:44 am
Current Project: SMBX: The Mushroom Island

Re: Moving Layer Calculations

Postby HVMetal » Sun May 22, 2016 5:31 am

This is probably the same but simplified with less math:

|Speed| * Delay * 2 ~ Nr. of Blocks => Speed ~ Nr. of Blocks / Delay * 2 => Delay ~ Nr. of Blocks / |Speed| * 2

The results wont be so accurate but people wont turn off "Auto Align" just to place the block 2.123 blocks away.
Speed= -2
Delay= 1
Then approx. the Nr. of Blocks will be 4 since |-2| * 1 * 2 = 4
Last edited by HVMetal on Tue May 24, 2016 10:07 am, edited 2 times in total.


Return to “Help and Support”

Who is online

Users browsing this forum: No registered users and 2 guests