I need a tutorial on how to make your char jump. And then after he's done fall to the ground and make sure he doesn't go through the ground...And maybe a a tutorial on how to switch sprites so it looks like your character is walking. Can some on tell me where I might find tutorials like these?
Offline
for gravity, just look for the tag gravity and choose one, for the walking you should make different costumes and then in the scripts use... (forever)next costume wait__sec.
Last edited by Vanslar (2007-10-27 19:06:57)
Offline
To switch sprites while your enemy is walking just use the change costumes block.
I had posted a simple gravity tutorial in another tread but I guess I'll repost it with ways to make it react the the ground.
Ok people I will tell you how to implement gravity!
The way I implement gravity is very simple and logical and you probally won't think gravity is such a big deal anymore.
// First create a "this sprite only" variable on your sprite called yVelocity
Then put this script into your sprite.
// yVelocity will only change if player is not touching the ground
<when green flag clicked>
<set{ yVelocity}to(0
<forever>
<if>
<touching[ ground ]
<set{ yVelocity }to( 0
<end>
<else>
<change{ yVelocity }by(-1
<change y by( yVelocity
<end>
//Now that wasn't so hard was it?
Now to jump we invert gravity.
//The player should only jump if he is touching the ground
<when[ up ]key pressed>
<if>
<touching[ ground ]
<set{ yVelocity}to( 10
<end>
Controlling x and y velocity is an important of game design and it's good to learn about it
The player should not fall though the ground but he might get stuck in it a little. To fix this the best way is to use color sensing. So if the color of the upper part of the sprites is touching the color in the ground make the sprite rise.
Last edited by archmage (2007-10-27 20:12:17)
Offline
Thanks but im stuck on the first one on change Y by yVelocity there's only change y by "number"....Can you help me out?
Offline
You need to create a variable and name it yVelocity.
click the variables button below the numbers button and then click make a variable on the place where the blocks are.
Offline
Ok I got them down thank you One last question how would I get an attack without making it go through the attack when I run...Like the sprites I make all go to the walking/running cycle how would I get it to press a single button then it would only do it for that button if you can under stand that...Not sure how to explain it any better...
Offline
Umm are you saying that you want an sprite to go through a certain animation when a certain button is pressed?
Offline
Yes. When I push a certain button I want it do do a certain action so far when I make a new costum all it does is add it to the walk animation is there a way to create a new sprite and not have it added to the walk cycle/walk animation?
Offline
I found a easyer way to explain...Is there any way I could "Link" Two costumes?
Offline
Just keep switching coustumes based on what the sprite is doing.
if you sprites is running then forever
switch to run1, switch to run 2, switch to run 3 and so on
if the sprite is jumping then
switch to jumping
and so on.
Offline
Bit hard to follow but I think I know what you ment.
Offline
This tutorial should attract people!
Offline
The code for the main sprite's gravity is in my ssbm project is
<when green flag clicked>
<forever>
<set y to( sprite x )>
<end>
<when green flag clicked>
<forever>
<if> <key[ space ]pressed?>
<repeat( 20 )>
<change{ sprite x }by(0.3)>
<end>
<repeat until><< <not><touching color[blue] >>
<change{ sprite x }by(0.1)>
<end>
<end>
Offline
What you need, I think, is for your walkcycle to only cycle through a set number of costumes, so that the other costumes can be used for other thinks.
Its fairly straightforward. Say you have the 1st 6 costumes for walking.
Instead of just "nextcostume" you need
If costume = 5
> change to costume 1
Else
>Next costume.
Then costumes 7+ can be for different things.
Offline
You can also use the "mod" function to cycle through a range of costumes in one command.
Let's say you wanted to cycle through 5 costumes, numbered 4,5,6,7,8.
You could do this with
change to costume 4+ ( (costume+1) mod 5)
Offline
i did this but i get stuck in the black before i can jump. it's like i go down to deep, or if im touching the ground i cant move.
Offline
I read the script. Thanks. I just have one question. Say i want to have barrieors so that i can stand on them and not go through them. Do you know how i can do that?
It is basicly a platform that you can stand on.
Thx
Offline
Use If touching color whatever, change y by one
Offline
kslich1 wrote:
I read the script. Thanks. I just have one question. Say i want to have barrieors so that i can stand on them and not go through them. Do you know how i can do that?
It is basicly a platform that you can stand on.
Thx
I think this project may have the codes you are looking for.
http://scratch.mit.edu/projects/archmage/101212
Offline
Try this project I just made, it tell you what to do:
http://scratch.mit.edu/projects/Oneandonly/510350
This is just basic gravity. If you want more advanced, read the description for my project with ohysics and stuff...
Offline
archmage wrote:
To switch sprites while your enemy is walking just use the change costumes block.
I had posted a simple gravity tutorial in another tread but I guess I'll repost it with ways to make it react the the ground.
Ok people I will tell you how to implement gravity!
The way I implement gravity is very simple and logical and you probally won't think gravity is such a big deal anymore.
// First create a "this sprite only" variable on your sprite called yVelocity
Then put this script into your sprite.
// yVelocity will only change if player is not touching the ground
<when green flag clicked>
<set{ yVelocity}to(0
<forever>
<if>
<touching[ ground ]
<set{ yVelocity }to( 0
<end>
<else>
<change{ yVelocity }by(-1
<change y by( yVelocity
<end>
//Now that wasn't so hard was it?
Now to jump we invert gravity.
//The player should only jump if he is touching the ground
<when[ up ]key pressed>
<if>
<touching[ ground ]
<set{ yVelocity}to( 10
<end>
Controlling x and y velocity is an important of game design and it's good to learn about it![]()
The player should not fall though the ground but he might get stuck in it a little. To fix this the best way is to use color sensing. So if the color of the upper part of the sprites is touching the color in the ground make the sprite rise.
My Sprite Doesn't Jump! the velocity just goes up. what do i do?
Offline