This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-10-14 18:49:42

Spence
Scratcher
Registered: 2007-06-18
Posts: 14

Advanced Programming

Anything about advanced programing. Projectiles, grivity, 3D graphics, etc.

Offline

 

#2 2007-10-14 19:07:51

Spence
Scratcher
Registered: 2007-06-18
Posts: 14

Re: Advanced Programming

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?

Offline

 

#3 2007-10-14 19:20:03

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Advanced Programming

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.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#4 2007-10-15 15:26:11

Canthiar
Scratcher
Registered: 2007-05-16
Posts: 100+

Re: Advanced Programming

Scratch wasn't really meant to do any kind of 3D rendering.  Some of the experimental stuff that I have done doesn't really render very well on the web site.

Offline

 

#5 2007-10-17 22:45:35

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Advanced Programming

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  smile

Last edited by archmage (2007-10-17 22:53:46)


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#6 2007-10-18 02:40:00

MyRedNeptune
Community Moderator
Registered: 2007-05-07
Posts: 1000+

Re: Advanced Programming

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  smile

Yah, I made the same in my Boing Gloing game.  smile


http://i52.tinypic.com/5es7t0.png I know what you're thinking! "Neptune! Get rid of those filthy advertisements and give us back the Zarathustra siggy, you horrible person!" Well, don't worry about it, the Zara siggy will be back soon, new and improved! ^^ Meanwhile, just do what the sig tells you to. >.>

Offline

 

#7 2007-10-27 10:45:53

Kaleh
Scratcher
Registered: 2007-09-13
Posts: 2

Re: Advanced Programming

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  smile

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!  smile

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

 

#8 2007-10-27 20:06:01

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Advanced Programming

....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.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#9 2007-10-28 00:28:10

Kaleh
Scratcher
Registered: 2007-09-13
Posts: 2

Re: Advanced Programming

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

 

#10 2007-11-23 09:52:03

funkymonkey
Scratcher
Registered: 2007-06-03
Posts: 1000+

Re: Advanced Programming

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  smile

but how do you make it bounce?


http://i243.photobucket.com/albums/ff67/hprules_photos/banner2.jpg
Kuzimu: Dawn of a New Age                                                                                                  Coming May 2010

Offline

 

#11 2007-12-22 00:02:23

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: Advanced Programming

One way to "Bounce" a falling sprite:

http://scratch.mit.edu/projects/EdnaC/70950

Mr Ed

Offline

 

#12 2007-12-22 11:14:06

brian_rocks
Scratcher
Registered: 2007-12-18
Posts: 1

Re: Advanced Programming

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

 

#13 2007-12-22 12:13:51

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Advanced Programming

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.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#14 2008-01-07 09:13:02

menith1
Scratcher
Registered: 2007-12-17
Posts: 1

Re: Advanced Programming

I would like to know how to jump of to the side and stuff.

Offline

 

#15 2008-01-08 14:13:02

messd002
Scratcher
Registered: 2007-12-07
Posts: 100+

Re: Advanced Programming

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  smile

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


Burn baby Burn!

Offline

 

#16 2008-01-08 14:14:32

messd002
Scratcher
Registered: 2007-12-07
Posts: 100+

Re: Advanced Programming

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.


Burn baby Burn!

Offline

 

#17 2008-01-09 14:56:56

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: Advanced Programming

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

 

#18 2008-02-11 19:13:48

Icarlyrocks
Scratcher
Registered: 2007-11-10
Posts: 19

Re: Advanced Programming

Hello! I am wanting a gravity ball that you can't control. Does someone know how to do this?

Offline

 

#19 2008-02-11 21:42:07

EdnaC
Scratcher
Registered: 2007-08-28
Posts: 100+

Re: Advanced Programming

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

 

#20 2008-02-12 07:50:11

Icarlyrocks
Scratcher
Registered: 2007-11-10
Posts: 19

Re: Advanced Programming

I mean this: http://www.freewebarcade.com/game/paint-ball-the-game/ The ball in this game is what i want.

Offline

 

#21 2008-02-12 09:47:55

Paddle2See
Scratch Team
Registered: 2007-10-27
Posts: 1000+

Re: Advanced Programming

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.


http://i39.tinypic.com/2nav6o7.gif

Offline

 

#22 2008-02-12 11:29:19

chalkmarrow
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: Advanced Programming

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

 

#23 2008-02-12 12:25:46

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Advanced Programming

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.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#24 2008-02-12 16:23:20

Jens
Scratcher
Registered: 2007-06-04
Posts: 1000+

Re: Advanced Programming

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.....


Jens Mönig

Offline

 

#25 2008-02-12 16:53:18

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: Advanced Programming

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?


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

Board footer