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

#1 2012-12-05 13:41:45

finlayvscott
New Scratcher
Registered: 2012-12-05
Posts: 14

Obstacles (probably pretty basic)

How do you make an object impossable to walk through, but still able to climb on? I'm making a platformer game (sort of) and I want crates that the guy can climb on and jump between etc. Thanks!

Offline

 

#2 2012-12-05 14:35:38

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

Re: Obstacles (probably pretty basic)

I've never tried something quite like that and don't have access to Scratch at the moment, but try this:

when gf clicked
set [yvel v] to (0)
forever
change [yvel v] by (-0.2) // gravity
change y by (yvel)
if<touching [any solid objects v]?>
set [yvel v] to ((yvel)/(-2))
change y by (yvel)
if<touching [any solid objects v]?>
change y by (yvel)
end
if<<key [up arrow v] pressed?> and <(yvel) > (0)>>
set [yvel v] to (5) // jump
end
if<key [right arrow v] pressed?>
change x by (2)
if<touching [any climbable objects v]?>
change x by (-2)
change y by (2)
set [yvel v] to (0)
else
if<touching [any solid objects v]?>
change x by (-2)
end
end
if<key [left arrow v] pressed?>
change x by (-2)
if<touching [any climbable objects v]?>
change x by (2)
change y by (2)
set [yvel v] to (0)
else
if<touching [any solid objects v]?>
change x by (2)
end
end


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

Offline

 

Board footer