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

#1 2012-06-03 06:55:47

chachicnd
New Scratcher
Registered: 2012-06-03
Posts: 2

Help with platform scripts

I am making a platform game. (With your help, it will roll off the production line quickly)The jumping, moving, and dieing work. The only major problem is that the character, when moving, can just glide right through platforms. It is the only thing keeping me from posting this game. PLEASE HELP!  sad

Offline

 

#2 2012-06-03 07:44:42

PhirripSyrrip
Scratcher
Registered: 2012-02-11
Posts: 100+

Re: Help with platform scripts

There are 3 methods you could use:
1. Make the Walls a different colour to the floor and everything else

forever
if <key [right arrow v] pressed ?>
change x by [5]
if <touching color [#000000] ?>
change x by [-5]
end
end
if <key [left arrow v] pressed ?>
change x by [-5]
if <touching color [#000000] ?>
change x by [5]
end
end
Make 2 sprites representing walls. Call them "LeftWall" and "RightWall"
forever
if <key [right arrow v] pressed ?>
if <not <touching [RightWall v] ?>>
change x by [5]
end
end
if <key [left arrow v] pressed ?>
if <not <touching [LeftWall v] ?>>
change x by [-5]
end
end
3. My favourite- colour the sides of the sprite two different colours
forever
if <key [left arrow v] pressed ?>
if <not <color [#FF0000] is touching [#000000] ?>>
change x by [-5]
end
end
if <key [right arrow v] pressed ?>
if <not <color [#1900FF] is touching [#000000] ?>>
change x by [5]
end
end
there is a chance that these may glitch a bit, in which case all you need to do is rearrange the scripts slightly.

Last edited by PhirripSyrrip (2012-06-03 07:45:47)


http://i46.tinypic.com/ao03lk.png

Offline

 

Board footer