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

#1 2012-09-02 21:31:13

lizzyhippo
Scratcher
Registered: 2012-04-10
Posts: 89

Platform??

How do you make a platform to jump on?


http://i50.tinypic.com/ofvtpy.png

Offline

 

#2 2012-09-02 22:07:29

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

Re: Platform??

This wiki article offers some links to some good platformer bases (projects that should be easily remixable to make a platformer).

If you want a working script with an explanation of how it works, I can give you that.

The script you want will probably be slightly different than the bases, since there are many slight variances in platformers (wall jumping, x velocity, etc.)


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

Offline

 

#3 2012-09-03 09:00:11

lizzyhippo
Scratcher
Registered: 2012-04-10
Posts: 89

Re: Platform??

MoreGamesNow wrote:

This wiki article offers some links to some good platformer bases (projects that should be easily remixable to make a platformer).

If you want a working script with an explanation of how it works, I can give you that.

The script you want will probably be slightly different than the bases, since there are many slight variances in platformers (wall jumping, x velocity, etc.)

Thank you!  If its not much trouble could you tell me?


http://i50.tinypic.com/ofvtpy.png

Offline

 

#4 2012-09-03 11:36:52

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

Re: Platform??

This is a script I've developed.  On the bright side it doesn't require any special costumes or bumpers, and a simple copy-paste should be fine for just about any scenario; furthermore you can either use a single sprite for both the walls and floors, or a single color, rather than, as some scripts require, using separate colors/sprites for each.  The downside is that it doesn't work well with animations (walking animations, jumping animations, etc.) as you could "animate" into a wall.

when gf clicked
forever
x-velocity part of script beneath this point
if<key [right arrow v] pressed?> // increase velocity if right key pressed
change [x-vel v] by (0.2)
end
if<key [left arrow v] pressed?> // decrease velocity if left key pressed
change [x-vel v] by (-0.2)
end
change x by (x-vel) // move sprite by x-velocity
if<touching [wall/floor v]?> // if sprite collides with wall
set [x-vel v] to ((-0.5)*(x-vel)) // bounce off at half the velocity
change x by (x-vel) // move out of wall
if<touching [wall/floor v]?>
change x by (x-vel) // keep moving out of wall if you're still touching it
end
end
y-velocity part of script beneath this point
change [y-vel v] by (-0.2) // decrease y velocity to simulate gravity
change y by (y-vel) // move sprite along the y-axis
if<touching [wall/floor v]?> // if touching wall/floor
set [x-vel v] to ((0.94)*(x-vel)) // decrease x velocity to simulate friction
set [y-vel v] to ((-0.5)*(y-vel)) // reverse y velocity and divide by 2
change y by (y-vel) // bounce
if<touching [wall/floor v]?>
change y by (y-vel) // continue to bounce out of wall/floor
end
if<<key [up arrow v] pressed?> and <(y-vel) > (0)>> // if I just hit the floor, I can jump
set [y-vel v] to (4) // jump if up arrow pressed
end
else
set [x-vel v] to ((x-vel)*(0.98)) // friction if you're not on the ground
end

Last edited by MoreGamesNow (2012-09-03 11:37:22)


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

Offline

 

#5 2012-09-03 12:34:23

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Platform??

... unless you make sure that all your animation costumes have the same shape, i.e. have the same pattern of transparent pixels.  That way, switching costumes won't change the value of any "touching" blocks.  If that doesn't make sense, I can explain in more depth (or someone else can).

Offline

 

#6 2012-09-03 14:27:18

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

Re: Platform??

amcerbu wrote:

... unless you make sure that all your animation costumes have the same shape, i.e. have the same pattern of transparent pixels.  That way, switching costumes won't change the value of any "touching" blocks.  If that doesn't make sense, I can explain in more depth (or someone else can).

Another way is to revert to the same costume every frame before running the movement script, and then reverting back to the costume you want visible.

Edit: taking advantage of single frame  smile

Last edited by MoreGamesNow (2012-09-03 14:27:48)


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

Offline

 

#7 2012-09-03 21:48:17

lizzyhippo
Scratcher
Registered: 2012-04-10
Posts: 89

Re: Platform??

MoreGamesNow wrote:

This is a script I've developed.  On the bright side it doesn't require any special costumes or bumpers, and a simple copy-paste should be fine for just about any scenario; furthermore you can either use a single sprite for both the walls and floors, or a single color, rather than, as some scripts require, using separate colors/sprites for each.  The downside is that it doesn't work well with animations (walking animations, jumping animations, etc.) as you could "animate" into a wall.

when gf clicked
forever
x-velocity part of script beneath this point
if<key [right arrow v] pressed?> // increase velocity if right key pressed
change [x-vel v] by (0.2)
end
if<key [left arrow v] pressed?> // decrease velocity if left key pressed
change [x-vel v] by (-0.2)
end
change x by (x-vel) // move sprite by x-velocity
if<touching [wall/floor v]?> // if sprite collides with wall
set [x-vel v] to ((-0.5)*(x-vel)) // bounce off at half the velocity
change x by (x-vel) // move out of wall
if<touching [wall/floor v]?>
change x by (x-vel) // keep moving out of wall if you're still touching it
end
end
y-velocity part of script beneath this point
change [y-vel v] by (-0.2) // decrease y velocity to simulate gravity
change y by (y-vel) // move sprite along the y-axis
if<touching [wall/floor v]?> // if touching wall/floor
set [x-vel v] to ((0.94)*(x-vel)) // decrease x velocity to simulate friction
set [y-vel v] to ((-0.5)*(y-vel)) // reverse y velocity and divide by 2
change y by (y-vel) // bounce
if<touching [wall/floor v]?>
change y by (y-vel) // continue to bounce out of wall/floor
end
if<<key [up arrow v] pressed?> and <(y-vel) > (0)>> // if I just hit the floor, I can jump
set [y-vel v] to (4) // jump if up arrow pressed
end
else
set [x-vel v] to ((x-vel)*(0.98)) // friction if you're not on the ground
end

THANK YOU SO MUCH!!!!


http://i50.tinypic.com/ofvtpy.png

Offline

 

#8 2012-09-03 23:50:38

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Platform??

Yeah, MoreGamesNow's platforming script is good!

Offline

 

#9 2012-09-04 13:06:20

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

Re: Platform??

No problem  smile


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

Offline

 

#10 2012-09-04 15:43:18

dvd4
Scratcher
Registered: 2010-06-30
Posts: 1000+

Re: Platform??

when gf clicked
forever
if (not touching ground)
 //if it isn't touching the ground,it goes down
go down
end
if (touching ground)
 //if it is,it goes up
go up
end
when gf clicked
 //this is the controls script
forever
if (up)
go up
end
if (down)
go down
end
if (left)
go left
end
if (right)
go right
end

Last edited by dvd4 (2012-09-04 15:43:35)


I made a mod  big_smile  It's called blook!
http://i49.tinypic.com/16ia63p.png

Offline

 

#11 2012-09-04 15:58:15

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Platform??

dvd4 wrote:

when gf clicked
forever
if (not touching ground) //if it isn't touching the ground,it goes down
go down
end
if (touching ground) //if it is,it goes up
go up
end
when gf clicked //this is the controls script
forever
if (up)
go up
end
if (down)
go down
end
if (left)
go left
end
if (right)
go right
end

Offline

 

Board footer