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

#1 2011-03-16 05:43:05

DizzyPixel
New Scratcher
Registered: 2011-03-16
Posts: 1

Help on Platformers

I've started Scratch recently and am having trouble with scripting. So far I know how to move left and right, have made a background, and have some music. Any help with jumping, goals and things such as spikes. Thanks  big_smile

Offline

 

#2 2011-03-16 06:02:30

ssss
Scratcher
Registered: 2007-07-29
Posts: 1000+

Re: Help on Platformers

Right...  Using Scroller game, or stationary?


Hey.  It's me SSSS, back from the dead!  smile

Offline

 

#3 2011-03-16 22:47:09

kingofdallamas
Scratcher
Registered: 2010-03-07
Posts: 500+

Re: Help on Platformers

Okay, let's say the spikes causes the sprite to die or lose a life. Have this script for the main sprite:

When green flag clicked
set life to 3
if touching spike, change life to -1

Or life could be health, but you get the main jist of it.  wink  Now, for gravity, there are tons of ways scripting works with gravity. My way, well, is different from others, and this script allows the sprite to not go through platforms and has a goof gravity engine.
Here it is below (tell me if you don't understand something in here):

Hit right test shall be a variable.
Xvelocity will be set as x.
Hit test left will also be a variable.
Gravity set as y.
The sensor sprite will have four lines at each corner like a rectangle but an empty middle. Each line will have a different color.


Sensore sprite- When green flag clicked
go to main sprite
set ghost effect to 100
forever if color green (this will be platform color bottom) touching color yellow
broadcast hit test left
if color green touching color blue
broadcast hit test right
etc
etc

The main sprite will then have the script as this:
When green flag clicked
    hit right test =1, change xvelocity by -4, set hit test left to 0
   hit test left=1, change xvelocity by 4, set hit test leeft to 0.
Forever
<if else touching color <whatever color platform bottom> set gravity to .2 <if touching whatever color platform top>set gravity to -1
   change gravity by -0.2
if <key up arrow pressed and touching color <whatever color platform bottom>
set gravity to 4.3
change y by Gravity
if else key right arrow presssed
move five steps right
set xVelocity to 5
if else key left arrow pressed
move five steps left
set xVelocity to -2.5
set xVelocity to 0
change x by xVelocity

Again, sorry if I coded some things wrong; it's hard to explain if not looking at scripts of somebody's gravity game. Other scripting of Other Scratchers would be different though. Hope this helps, and good luck! If you need more help, look at Scratch Wiki. THey have alot of articles.  wink

Last edited by kingofdallamas (2011-03-16 22:55:10)


http://i853.photobucket.com/albums/ab99/Gilgamesh1192/Ninja%20Saga/ElementalJutsus2.gifhttp://i27.photobucket.com/albums/c192/BoomKaTish/GIF/thgfhgfhfhgf.gif
ハロー友だち!

Offline

 

Board footer