Discuss Scratch

thepterodactyl
Scratcher
77 posts

Platformer Problems.

I wanna try making a thomas was alone-like game but I wanna make the character move right away when holding the key, not move one step and then move forward. The thing is I'm trying to use the game brush by neutrinos (scratch.mit.edu/projects/23045620/) and tried copying the scripts used in the game for my game but

j-just

pls help
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Wait, also I want the player to keep moving while jumping. But I haven't figured that one out, either.
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Looks like no one will help me.

a@#$%^& Scratchers.
deck26
Scratcher
1000+ posts

Platformer Problems.

Can you share your project and provide a link. I don't know the games you refer to but will have a look anyway.
thepterodactyl
Scratcher
77 posts

Platformer Problems.

http://scratch.mit.edu/projects/47511252/

Y'know that game brush?

I don't know how that guy does it.
cauzality
Scratcher
100+ posts

Platformer Problems.

Usually something like this
whenright arrowkeypressedchangexby10
is good for single press things like opening your inventory or moving your selection in a grid of options. it does that thing where it fires onces, waits, then fires continuously. To get something better for being held like walking, do something like this
whenclickedforeverifkeyright arrowpressed?thenchangexby10
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Thanks for the help. It now works perfectly.

EDIT: Wait, one more thing, if the character is not on the platform, how do I make it fall?

Last edited by thepterodactyl (Feb. 12, 2015 05:54:22)

cauzality
Scratcher
100+ posts

Platformer Problems.

thepterodactyl wrote:

Wait, also I want the player to keep moving while jumping. But I haven't figured that one out, either.

You would have to start using variables I think. There's a few ways to do it, but a common way is to make an “x speed” variable and a “y speed” variable. That way, your sprite has a memory of what it was just doing. So when he jumps, he maintains his horizontal speed until he touches the ground again.

Instead of having the key presses move your character, you could have them set your speed. You character will also move by this speed so to get him to stop moving, you change the speeds to 0. Here's an example:
whenclickedforeverchangexbyxspeedchangeybyyspeediftouchingground?thensetx speedto0sety speedto0ifkeyright arrowpressed?thensetx speedto10ifkeyup arrowpressed?thensety speedto15elsechangey speedby-2
this makes you stop moving if you're on the ground unless you press a key. If you press right key, your x speed with go positive. I didn't do the left key one but it would work the same and set your x speed negative. if you press up key, you set your y speed positive. That makes you move up. If you're not touching the ground, it's assumed you're in the air, so your y speed is reduced by a small amount every frame. That's your gravity.

scripts like this usually start by resetting your speeds to 0 and going to the character's starting position with a go to block.
cauzality
Scratcher
100+ posts

Platformer Problems.

thepterodactyl wrote:

Thanks for the help. It now works perfectly.

EDIT: Wait, one more thing, if the character is not on the platform, how do I make it fall?

I didn't see this while I was typing the last one, but I think it gets at this question too…
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Sorry to burst your bubble, but I already had that covered. I just wanna know how to make the character fall when it's not on the platform. I've tried:

ifnottouchingplatform?thenchangeybyyeah.

But it didn't work.
cauzality
Scratcher
100+ posts

Platformer Problems.

it should… i will look at it
cauzality
Scratcher
100+ posts

Platformer Problems.

oh, you need a forever loop around that. with just the repeat until it stops after you touch the platform and never starts again.
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Oh, thanks.
cauzality
Scratcher
100+ posts

Platformer Problems.

np
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Glitch is happening. Whenever I jump now, the character goes inside the platform. Second jump, I go below the platform.
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Well, whenever it's in backdrop3.
thepterodactyl
Scratcher
77 posts

Platformer Problems.

I just fixed it by just clicking on the arrow

touchingplatform?

I feel like an idiot here.
thepterodactyl
Scratcher
77 posts

Platformer Problems.

Wait, it's broken again.

WHY DO YOU DO THIS TO ME SCRATCH
cauzality
Scratcher
100+ posts

Platformer Problems.

you're not an idiot lol, just gotta fix/build things one problem at a time.

maybe take out the last couple change y by -20 and -40 and the waits between them. remember the whole time he's not touching the ground he will be doing change y by -5 now. So he will probably go lower than he was going before. Or you could just lower the negative numbers a bit…

good luck with it btw… it's lookin pretty cool.

Last edited by cauzality (Feb. 12, 2015 08:28:43)

ShadowScizor
Scratcher
100+ posts

Platformer Problems.

You should use a variable for your jump: http://scratch.mit.edu/projects/18003346/

Powered by DjangoBB