Is there a way to limit the player's speed?

Description: Subforum dedicated to SMBX-38A - a fan-made remake of the original SMBX Engine, made by 5438A38A.
Forum rules: This is official Europan/American community for the SMBX-38A. Suggested to don't post stuff for this engine outside this subforum.
Moderators: Lx Xzit, Yoshi021, 5438A38A, Semi-moderatos, Moderators

Lx Xzit M
Topic author, Moderator
Moderator
Avatar
Lx Xzit M
Topic author, Moderator
Moderator
Reputation: 402
Posts: 757
Joined: 9 Nov 2015
Website

Post #1by Lx Xzit » 25 Aug 2016, 8:42

I need to limit player's horizontal maximum speed to a value like 4.5/5 (the max speed is 6). Is there a way to do this? I saw a level on KFCMario's episode where the snow push you to the right, I'd like to do something like this but pushing player to the left to limit his maximum speed. If anyone could help me I'd appreciate it a lot!

I'm not posting this at Tea-Script subforum because I don't know if there's a way to do this through liquids, so...
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image

Erwill M
Count
Count
Avatar
Erwill M
Count
Count
Age: 24
Reputation: 189
Posts: 295
Joined: 29 Nov 2015

Post #2by Erwill » 25 Aug 2016, 9:22

Char(1).x=Char(1).x+3 ?

Super Mario Player M
Duke
Duke
Avatar
Super Mario Player M
Duke
Duke
Age: 21
Reputation: 29
Posts: 141
Joined: 23 Jun 2016
Location: Planet Earth
Youtube channel URL Tencent QQ

Post #3by Super Mario Player » 25 Aug 2016, 11:52

You can use the following

Code: Select all

if Char(1).Xsp>4.5 then
Char(1).Xsp=4.5
end if
if Char(1).Xsp<-4.5 then
Char(1).Xsp=-4.5
end if
My current project:
Spoiler
The Tower of Challenges

Languages (for PMs):

Image

YouTube channel:
Image
Image

Lx Xzit M
Topic author, Moderator
Moderator
Avatar
Lx Xzit M
Topic author, Moderator
Moderator
Reputation: 402
Posts: 757
Joined: 9 Nov 2015
Website

Post #4by Lx Xzit » 27 Aug 2016, 3:34

Thank you guys for the replies! unfortunately none of them worked for me. :(
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image

Yoshi021 M
Moderator
Moderator
Avatar
Yoshi021 M
Moderator
Moderator
Age: 22
Reputation: 170
Posts: 693
Joined: 15 Feb 2016
Location: Yoshi's Island

Post #5by Yoshi021 » 27 Aug 2016, 3:36

Lx Xzit wrote:Thank you guys for the replies! unfortunately none of them worked for me. :(
Make sure that it loops. Since it need to get the Char(1).Xsp every frame.
Links
ImageImageImage
Image
Image
"Going to University is FUN!" :pardon:

Lx Xzit M
Topic author, Moderator
Moderator
Avatar
Lx Xzit M
Topic author, Moderator
Moderator
Reputation: 402
Posts: 757
Joined: 9 Nov 2015
Website

Post #6by Lx Xzit » 27 Aug 2016, 3:39

But if I do, it will cause deadly lags and will clash the game :/
I also tried putting "START" at the start of the code but it didn't work
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image

KFCMARIO
Good citizen
Good citizen
Avatar
KFCMARIO
Good citizen
Good citizen
Reputation: 21
Posts: 33
Joined: 25 Jan 2016

Post #7by KFCMARIO » 27 Aug 2016, 6:57

Lx Xzit wrote:But if I do, it will cause deadly lags and will clash the game :/
I also tried putting "START" at the start of the code but it didn't work

maybe you forget to put a "sleep" statement in the loop
Spoiler
do
if Char(1).Xsp>4.5 then
Char(1).Xsp=4.5
end if
if Char(1).Xsp<-4.5 then
Char(1).Xsp=-4.5
end if
call sleep(1)
loop

Lx Xzit M
Topic author, Moderator
Moderator
Avatar
Lx Xzit M
Topic author, Moderator
Moderator
Reputation: 402
Posts: 757
Joined: 9 Nov 2015
Website

Post #8by Lx Xzit » 27 Aug 2016, 7:09

Oh, thank you! I did put "call sleep" but in the wrong line, now it works perfectly!
VISIT MY YOUTUBE CHANNEL! LX XZIT
Join our 38A Discord server!

Image


Return to “Super Mario Bros. X by 38A (SMBX-38A)”

Who is online (over the past 5 minutes)

Users browsing this forum: 1 guest