Spence wrote:
Can anyone make me a project + a link for a 3D basis for my Stick-Man Fighter 4 game? I want to make it 3D, but I would rather not use 5 billion sprites doing it. Any ideas?
You really can't make a well working 3-D game in scratch. Scratch is very limited in it's programming resources and the only person to make accurate looking 3-D is Cathier. Making "fake" 3-D in scratch involves advanced math, or you can give your game a 3-D looking effect just don't expect to create freely rotating polygons.
Offline
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 local variable on your sprite called yVelocity
Then put this script into your sprite.
<when green flag clicked>
<set{ yVelocity}to(0
<forever>
<change{ yVelocity }by(-1
<change y by( yVelocity
//Now that wasn't so hard was it?
Now to jump we invert gravity.
<when[ up ]key pressed>
<set{ yVelocity}to( 10
Controlling x and y velocity is an important of game design and it's good to learn about it
Last edited by archmage (2007-10-17 22:53:46)
Offline
archmage wrote:
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 local variable on your sprite called yVelocity
Then put this script into your sprite.
<when green flag clicked>
<set{ yVelocity}to(0
<forever>
<change{ yVelocity }by(-1
<change y by( yVelocity
//Now that wasn't so hard was it?
Now to jump we invert gravity.
<when[ up ]key pressed>
<set{ yVelocity}to( 10
Controlling x and y velocity is an important of game design and it's good to learn about it![]()
Yah, I made the same in my Boing Gloing game.
Offline
archmage wrote:
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 local variable on your sprite called yVelocity
Then put this script into your sprite.
<when green flag clicked>
<set{ yVelocity}to(0
<forever>
<change{ yVelocity }by(-1
<change y by( yVelocity
//Now that wasn't so hard was it?
Now to jump we invert gravity.
<when[ up ]key pressed>
<set{ yVelocity}to( 10
Controlling x and y velocity is an important of game design and it's good to learn about it![]()
No! Do not invert gravity
try something like this:
Create the following Variables (doesn't matter how it's named)
DX, DY,Gravity, OnGround
Loop
{
x:=x+DX
y:=y+DY
If OnGround=0 then DY:= DY-gravity
}
when it's on a solid ground, set DY to 0, and OnGround to 1
Done!
Do note that, once you use gravity, if a thing falls too hard, it will go right into a wall, there are 3 possible ways that work right, that I can think of (in scratch) to counter that. I'll leave it to you to find that out!
Oh, but I know how to, just not telling yet, else you wouldn't learn much.
Anyhow, if you think hard and long enough about it, and you still haven't come to a solution, feel free to ask.
Offline
....That code would do the same thing as the one I posted. Only you included a variable that seems to influence x velocity even though the script has no effect on x velocity.
Also the purpose of inverting gravity was to get a jumping effect which is something you did not explain how to do in your above post.
Offline
Hmm sorry, only read the header, but then still, inverting gravity is so wrong to say.
Then I do not know what your issue is with my 'Jump Example II', that it was too overcomplicated, it is exactly that, plus a script to move the character, and to stop it from falling into the ground
Offline
archmage wrote:
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 local variable on your sprite called yVelocity
Then put this script into your sprite.
<when green flag clicked>
<set{ yVelocity}to(0
<forever>
<change{ yVelocity }by(-1
<change y by( yVelocity
//Now that wasn't so hard was it?
Now to jump we invert gravity.
<when[ up ]key pressed>
<set{ yVelocity}to( 10
Controlling x and y velocity is an important of game design and it's good to learn about it![]()
but how do you make it bounce?

Offline
OK now i will tell you how to scroll
First make a variable called x speed and another called y speed
<when green flag clicked>
<set{x speed }to( 0
<set{y speed }to( o
<forever>
<set x to( <{x speed }>
<set y to( <{ y speed }>
<if><key[ right arrow ]pressed?>
<set{ x speed }to( (( <{ x speed }> <+> 5 ))
<if><key[ left arrow ]pressed?>
<set{ x speed }to( (( <{ x speed }> <+> -5 ))
<if><key[ up arrow ]pressed?>
<set{ y speed }to( (( <{ y speed }> <+> 5 ))
<if><key[ down arrow ]pressed?>
<set{ y speed }to( (( <{ y speed }> <+> -5 ))
And there you have it.
Offline
That code will only move a sprite like it normally would move. It would scroll a sprite if you set x speed and y speed to different initial values but you didn't give any explanations on how to do that. Also having this kind of code on every sprite is a bad idea as it will cause unnecessary lag. I typed out a scrolling tutorial @ http://scratch.mit.edu/forums/viewtopic.php?id=2440
If you follow the instructions carefully it will produce nice scrolling.
Offline
funkymonkey wrote:
archmage wrote:
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 local variable on your sprite called yVelocity
Then put this script into your sprite.
<when green flag clicked>
<set{ yVelocity}to(0
<forever>
<change{ yVelocity }by(-1
<change y by( yVelocity
//Now that wasn't so hard was it?
Now to jump we invert gravity.
<when[ up ]key pressed>
<set{ yVelocity}to( 10
Controlling x and y velocity is an important of game design and it's good to learn about it![]()
but how do you make it bounce?
I have made a bouncing ball project, although it isn't as realistic as possible it may be ok for some needs.
View it here: http://scratch.mit.edu/projects/messd002/76976
Offline
menith1 wrote:
I would like to know how to jump of to the side and stuff.
I am afriad I can't tell you how, however I know it invloves X velocity and some really clever stuff like that. Try looking at archmages sprite movement done right and have a go from there.
Offline
Menith,
Do you mean "jump off the side" as in getting to the edge and switching to another background, or just sprite movement?
Movement in response to the operator is pretty easy to do. There are several easy demos in the Gravity to Games Gallery. These are all simple projects that show sprite movement, different implementations of gravity, projectile motion, etc. Different ways to do things are in there and some of Archmage's demo projects are posted.
http://scratch.mit.edu/galleries/view/9206
If you don't see something that gets you started in the right direction, post a reply that describes the kind of motion you want, as specifically as possible, and someone can put together a simple demo for you.
Do you want to move in x and y in response to the arrow keys?
Or
Move forward and "steer" with the arrow keys? Reverse?
It's best to start simple and work up to more complex stuff, so a project that stays on a single screen is a good start before starting to dream up big stuff.
-Mr Ed
Offline
Hello! I am wanting a gravity ball that you can't control. Does someone know how to do this?
Offline
Can you describe in more detail what a "gravity ball" is and what you want to do?
Some really cool stuff can be done with Scratch, have you looked at the sample projects that are included, or at the demos in "Gravity to Games"?
http://scratch.mit.edu/galleries/view/9206
The "moonlander" project has gravity centered on the screen (the moon). This may help you get started...
Offline
I mean this: http://www.freewebarcade.com/game/paint-ball-the-game/ The ball in this game is what i want.
Offline
That is going to be a challenge. The ball is free-falling under vertical gravity (that's not hard) but then it bounces repeatedly off of pre-drawn lines (various angles) and lines drawn by the user (at any angle). The bouncing is going to present the biggest problem. I've played a little with bouncing balls in my Mini-Golf game:
http://scratch.mit.edu/projects/Paddle2See/82463
but that was only bouncing off of flat surfaces. I expect some sort of approximation will have to be devleoped to handle bouncing off of a hand-drawn line.
Offline
Yeah. That's a tough one. As Paddle2See noted, the trick with that game is that you're going to have to first determine the slope of the curve where the ball touches it. After you know that, the bounce angle is fairly easy to determine. I don't think anybody has tackled the slope problem yet (the problem of determining the slope of a user-drawn curve at an arbitrary point). I'd be interested in how people would approach this.
Offline
My initial thought would be "cheat" - make the pen only movable in specific directions (say, increments of 30 degrees). Change the colour of the pen depending on the angle of motion and then the ball will be able to tell which angle any line it hits is at.
Not an ideal solution, of course.
The only other way would be to use a sensor-web of invisible sprites around the ball's direction of movement to try to interpret the relative angle of whatever it is about to hit.
The principle would be simple but it would be hard to make it foolproof.
Offline
Slope detection is tough and slow.
I was experimenting with a slope sensor sprite consisting of two almost identical costumes, each containing two horizontally aligned differently colored pixels (red and green) one (neutral) pixel apart. In one costume the rotation center was on the red pixel, in the other one on the green pixel. I then moved the sensor sprite in the direction of the shape whose slope it was about to measure until both touched, let the sprite switch to the costume, whose rotation axis was on the pixel touching the slope, and kept rotating the sensor sprite according to which pixel (left or right one) hit first, until the other pixel also touched the shape (by checking if color a touched color b). And there I had it. Worked fine, but was way too slow for the "paint ball" game Icarlyrocks pointed out. So now I'm thinking about "dumbing" down the algorithm, or increasing the turning intervals.....
Offline
I wonder if instead of turning the detector you could use the timer, recording somehow the difference in the time that each hits the surface and using that to approximate the angle?
Offline