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

#1 2012-04-14 12:30:55

s_federici
Scratcher
Registered: 2007-12-18
Posts: 500+

help with platformer

I need the simplest script that would allow me to create a simple platformer game in which a skater will go left/right when left/right arrow is clicked and will go up/jump the ramp when the he is touching it.

I was thinking of using "is touching color" blocks to detect ground/ramp collision. Can someone suggest a project in which such scripts are already present?

Offline

 

#2 2012-04-14 18:46:33

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: help with platformer

I cannot give you a project right now that uses something like this, but you can add 'hit' sprites which can be used to detect whether the player is on a ramp or flat ground. For example if touching the ground and touching on the right then you need to slide downwards left. 

I will try and find a project which uses this but you may need to mess around with things like that:)


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

#3 2012-04-14 18:49:50

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: help with platformer

This may not be too useful but to get a grasp of player reactions to a ramp http://scratch.mit.edu/projects/AtomicBawm3/2184464 might be useful. It shows how a slope can be detected. In your project you won't want the bounce effect but when the ramp orientation has been determined then you can react accordingly. Hope this helps a bit, I can find nothing more relevant at the moment.


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

#4 2012-04-14 19:12:50

aryabtsev
Scratcher
Registered: 2012-02-05
Posts: 81

Re: help with platformer

I guess if you don't want to use a sensor sprite, you can use different colored walls. Maybe something like this?

when flag clicked
set [xv v] to (0)
set [yv v] to (0)
forever
change x by (xv)
change y by (yv)
set [xv v] to ((xv)*(0.96)) // slow down speed (friction)
if <key [left arrow v] pressed?>
change [xv v] by (-1) //movement speed
end
if <key [right arrow v] pressed?>
change [xv v] by (1) //movement speed
end
if <touching color [#00FF00]?> //color of wall
set [xv v] to ((xv)*(-1))
end
if <touching color [#FFFF00]?> //color of normal ground
set [yv v] to (0)
else
change [yv v] by (-0.5) //speed of falling down (gravity)
end
if <touching color [#0000FF]?> //color of ramp
set [yv v] to (15) //jumping force
end
end
If you don't want the things to be such a different color, you can make them almost the same.
Hope this helped!


http://i.imgur.com/NX7AO.jpg

Offline

 

Board footer