How to put gravity (Page 1) ● SmileBASIC Source Forums

Register
This website has been moved, please see this post

# How to put gravity

• #1 ✎ 1 Z2BCodes Can someone say me how to put gravity in a game pls? Posted
• #2 ✎ 34 Chatter You said "pls" because it's shorter than "please", so I'm going to say "No" because it's shorter than "Yes". If you want an answer that is actually useful, you'll have to post your code. Do you have a system for storing which sprites (or BG tiles) are for the ground vs which ones are actual objects that need gravity applied? Generally speaking, for each sprite that you want to apply gravity to, you'll decrease it's y-coordinate by some amount (something exponential if you want it to be realistic) and check for collision with the static terrain. If it's collided, do something to signify that it doesn't need gravity applied. We really do need your code. Posted Edited by Chatter
• #3 ✎ 524 chicken Deep Sleep Hidden Website
snark snark snark. we need your code
The problem is more likely to be that they can't use what we give them just yet. There's probably not any code that we can work with.
Can someone say me how to put gravity in a game pls?
Click this if you know what you're doing: (basically what Chatter described) change the numbers until they feel good WHILE TRUE <code> IF TOUCHINGGROUND THEN IF JUMP THEN YVEL = -10 `jump force ENDIF ELSE INC YVEL, 2 `gravity ENDIF YVEL = YVEL * 0.87 `air resistance INC Y, YVEL WEND Click this if you don't: This is a great tutorial for beginners, written by the very owner of this site. Skip ahead if you know something, don't if you don't. Some things to remember while using SmileBASIC:
1. Don't be afraid to experiment. There are three other 'slots' where you can write short programs to test things. You can run them by typing RUN <SLOT#> in DIRECT mode.
2. There's an incredibly useful help button in the top-right corner for when you're editing programs. Tapping it opens a command list. If your text cursor is on a command, it opens an explanation for that command.
3. What VSYNC does