Discuss Scratch

8BlTPENGUIN
Scratcher
29 posts

How to add Anti-Gravity to a Platformer Game?

I'm creating a platformer game and I want a Jetpack Joyride-like thing that activates when you press the space bar.(Where you go to the ceiling or floor when you press Space) I also want to make it where you can't go through platforms and stuff without adding a ton of sprites and scripts. Sorry if this sounds kind of confusing. Click here to see the project.

Last edited by 8BlTPENGUIN (Feb. 3, 2016 01:52:01)

Ataxaos
Scratcher
500+ posts

How to add Anti-Gravity to a Platformer Game?

whenclickedforeverifgravity=anti-gravitythenchangeY-velocityby0.1elsechangeY-velocityby-0.1changeybyY-velocitywhenclickedforeverifkeyspacepressed?thenifgravity=anti-gravitythensetgravitytonormalelsesetgravitytoanti-gravitywaituntilnotkeyspacepressed?

Last edited by Ataxaos (Feb. 3, 2016 03:49:10)

zp100
Scratcher
100+ posts

How to add Anti-Gravity to a Platformer Game?

Ataxaos
Scratcher
500+ posts

How to add Anti-Gravity to a Platformer Game?

zp100 wrote:

Check it out:

https://scratch.mit.edu/projects/89351420/
This doesn't answer the user's question.
Please don't advertise your own projects that are only loosely relevant to the topic.

Feel free to advertise as much as you want on “Show and Tell”, though.
zp100
Scratcher
100+ posts

How to add Anti-Gravity to a Platformer Game?

Ataxaos wrote:

zp100 wrote:

Check it out:

https://scratch.mit.edu/projects/89351420/
This doesn't answer the user's question.
Please don't advertise your own projects that are only loosely relevant to the topic.

Feel free to advertise as much as you want on “Show and Tell”, though.

I was showing my project that has anti-gravity scripts.
Ataxaos
Scratcher
500+ posts

How to add Anti-Gravity to a Platformer Game?

zp100 wrote:

I was showing my project that has anti-gravity scripts.
It doesn't. I did check before posting - your project only has regular gravity scripts.
By anti-gravity, the topic owner meant the ability to switch between gravity pulling up or pulling down.

Besides, even if your project did contain anti-gravity scripts, the project does not explain how to do it.
For example, posting a platformer game does not answer the question “How do I make solid platforms?”

Anyway, just trying to tell you there are way more better places to advertise, like in your signature.
zp100
Scratcher
100+ posts

How to add Anti-Gravity to a Platformer Game?

Ataxaos wrote:

zp100 wrote:

I was showing my project that has anti-gravity scripts.
It doesn't. I did check before posting - your project only has regular gravity scripts.
By anti-gravity, the topic owner meant the ability to switch between gravity pulling up or pulling down.

Besides, even if your project did contain anti-gravity scripts, the project does not explain how to do it.
For example, posting a platformer game does not answer the question “How do I make solid platforms?”

Anyway, just trying to tell you there are way more better places to advertise, like in your signature.

Okay, thanks. In the Player sprite, there are scripts that include “change y by ((2) * (gravity)”. When you press space, the gravity switches. It's exactly what 8BlTPENGUIN was asking for.
Ataxaos
Scratcher
500+ posts

How to add Anti-Gravity to a Platformer Game?

zp100 wrote:

Okay, thanks. In the Player sprite, there are scripts that include “change y by ((2) * (gravity)”. When you press space, the gravity switches. It's exactly what 8BlTPENGUIN was asking for.
Ah, I didn't know you had to press space in mid-air to change the gravity; my bad, I apologize!
Maybe put that in the project notes or add explanations next to your scripts?

Last edited by Ataxaos (Feb. 4, 2016 03:27:27)

zp100
Scratcher
100+ posts

How to add Anti-Gravity to a Platformer Game?

@Ataxaos

Good point. I wasn't done with it yet, so I didn't make a full description.
ey83985
Scratcher
10 posts

How to add Anti-Gravity to a Platformer Game?

when clickedforeverif gravity = anti-gravity thenchange Y-velocity by 0.1elsechange Y-velocity by -0.1change y by Y-velocity
when clickedforeverif key space pressed? thenif gravity = anti-gravity thenset gravity to normalelseset gravity to anti-gravitywait until not key space pressed?

Powered by DjangoBB