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

#1 2011-07-30 22:27:09

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

A tutorial for all your platformer needs

Hello! I am going to teach you how to make make a platformer! First off, Velocity and sensing. 

First, copy the costume and fill it all in black. Next, put a different color on each side. Then use this script:
When green flag clicked
forever
Switch to costume sensing
If color on right touching color black
Set X Velocity to -1
End if

If color on left touching color black
Set X Velocity to 1
End if

If bottom color touching black
If key up arrow pressed
set Y Velocity to 10
End if
Else
Change Y Velocity by -1
End If Else

If Top color touching color black
set Y Velocity to -3
End if

If key right arrow pressed
Change X Velocity by 1
End If

If key left arrow pressed
Change X Velocity by -1
End If
set X Velocity to X Velocity * 0.9
change x by X Velocity
change y by Y Velocity
end forever
Switch to costume Regular

Last edited by ImagineIt (2011-07-31 10:58:38)

Offline

 

#2 2011-07-31 00:38:00

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

Thanks Imagineit! I will try it out  wink . But one question. Of course no body wants others to see that sensor costume. Are we allowed to change it and the script will still work?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#3 2011-07-31 10:57:42

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: A tutorial for all your platformer needs

Thescratch3 wrote:

Thanks Imagineit! I will try it out  wink . But one question. Of course no body wants others to see that sensor costume. Are we allowed to change it and the script will still work?

It won't show up. I forgot to finsish it too.

Offline

 

#4 2011-07-31 13:10:47

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

ImagineIt wrote:

Thescratch3 wrote:

Thanks Imagineit! I will try it out  wink . But one question. Of course no body wants others to see that sensor costume. Are we allowed to change it and the script will still work?

It won't show up. I forgot to finsish it too.

It won't show up?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#5 2011-07-31 18:21:33

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: A tutorial for all your platformer needs

Thescratch3 wrote:

ImagineIt wrote:

Thescratch3 wrote:

Thanks Imagineit! I will try it out  wink . But one question. Of course no body wants others to see that sensor costume. Are we allowed to change it and the script will still work?

It won't show up. I forgot to finsish it too.

It won't show up?

It happens so fast that you don't see the sensing.

Offline

 

#6 2011-07-31 18:30:50

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

ImagineIt wrote:

Thescratch3 wrote:

ImagineIt wrote:


It won't show up. I forgot to finsish it too.

It won't show up?

It happens so fast that you don't see the sensing.

Huh?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#7 2011-07-31 19:11:17

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: A tutorial for all your platformer needs

That is, depending on a script length in scratch and a  block's location on the script, it may occur between renderings.  The script is executed, but a change afterword negates/overrides it before it is rendered.  In this example:

CostumeToSee changes to SensingCostume
Find out which directions you can go
Switch back to CostumeToSee
RenderImage/RenderFrame

Curiously, this only works in presentation mode, so while in the script editor, the sprite WILL appear to flash from one costume to the next very quickly, but try it in presentation mode, and it should (hopefully) remain only on the costume you want.  Hope this helps.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#8 2011-07-31 19:16:05

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: A tutorial for all your platformer needs

MoreGamesNow wrote:

That is, depending on a script length in scratch and a  block's location on the script, it may occur between renderings.  The script is executed, but a change afterword negates/overrides it before it is rendered.  In this example:

CostumeToSee changes to SensingCostume
Find out which directions you can go
Switch back to CostumeToSee
RenderImage/RenderFrame

Curiously, this only works in presentation mode, so while in the script editor, the sprite WILL appear to flash from one costume to the next very quickly, but try it in presentation mode, and it should (hopefully) remain only on the costume you want.  Hope this helps.

Yup!

Offline

 

#9 2011-07-31 19:42:33

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

ImagineIt wrote:

MoreGamesNow wrote:

That is, depending on a script length in scratch and a  block's location on the script, it may occur between renderings.  The script is executed, but a change afterword negates/overrides it before it is rendered.  In this example:

CostumeToSee changes to SensingCostume
Find out which directions you can go
Switch back to CostumeToSee
RenderImage/RenderFrame

Curiously, this only works in presentation mode, so while in the script editor, the sprite WILL appear to flash from one costume to the next very quickly, but try it in presentation mode, and it should (hopefully) remain only on the costume you want.  Hope this helps.

Yup!

So your script says switch to costume sensor. I can easily say at the end of the script switch to costume whatever?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#10 2011-07-31 19:47:33

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

Thanks! I am working on one using this technique!


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#11 2011-07-31 19:48:58

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

Can you post the scrolling one with y and x?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#12 2011-07-31 19:52:20

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: A tutorial for all your platformer needs

Well, I'm not sure if clear cut rules have been developed, but here are some I can think of:

The script can be fairly lengthy (see many 1s1s games that use this to paste walls/floors and return to position between frames)

Adding repeat(), repeat until<>, or other blocks with a built-in time restraint will break this neat trick too.
The built-in time restraint is a small amount of time.  It is quite nice in some cases (e.g. not making your sprite move extremely quickly across the screen, but gliding more slowly), but it slows down Scratch as a whole.  This is a main difference between normal and TURBO speed. TURBO speed eliminates the delay, but can also be devastating if you rely on the delay in your project.

You're probably thinking: TMI, lol.  But to answer your question, usually yes, as long as you avoid loops.


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#13 2011-07-31 19:55:17

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

ImagineIt wrote:

Hello! I am going to teach you how to make make a platformer! First off, Velocity and sensing. 

First, copy the costume and fill it all in black. Next, put a different color on each side. Then use this script:
When green flag clicked
forever
Switch to costume sensing
If color on right touching color black
Set X Velocity to -1
End if

If color on left touching color black
Set X Velocity to 1
End if

If bottom color touching black
If key up arrow pressed
set Y Velocity to 10
End if
Else
Change Y Velocity by -1
End If Else

If Top color touching color black
set Y Velocity to -3
End if

If key right arrow pressed
Change X Velocity by 1
End If

If key left arrow pressed
Change X Velocity by -1
End If
set X Velocity to X Velocity * 0.9
change x by X Velocity
change y by Y Velocity
end forever
Switch to costume Regular

big_smile  Thanks I am actually changing the scripts from velocities to scroll! I might got the grasp for scroll thanks to you  big_smile ....


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#14 2011-08-10 15:32:16

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

Imagineit will you post anything else about this?


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

#15 2011-08-10 17:15:27

ImagineIt
Scratcher
Registered: 2011-02-28
Posts: 1000+

Re: A tutorial for all your platformer needs

Thescratch3 wrote:

Imagineit will you post anything else about this?

What should I? Please give more information on what you would like!

Offline

 

#16 2011-08-10 18:55:38

Thescratch3
Scratcher
Registered: 2011-06-14
Posts: 1000+

Re: A tutorial for all your platformer needs

ImagineIt wrote:

Thescratch3 wrote:

Imagineit will you post anything else about this?

What should I? Please give more information on what you would like!

How about some you know fighting game stuff? (Just to let you know I used this technique again but this time no scrolling and it didn't work but I managed some how)


View my projects. Or face The scratch curse! (Get it?)
http://i56.tinypic.com/2cdk8hy.png

Offline

 

Board footer