Discuss Scratch

fupi437
Scratcher
25 posts

Platformer Movements

For a basic platformer, use this script:
when green flag clicked
set rotation style [left-right v]
forever
if <key [left arrow v] pressed>
point in direction (-90 v)
move (...) steps
end
if <key [right arrow v] pressed
point in direction (90 v)
move (...) steps
end
end
when green flag clicked
forever
if <key [up arrow v] pressed> // Don't snap this on the previous script
repeat (...)
change y by (...)
end
repeat until <touching color [color of the ground]>
change y by (-...) // Put in a negative number
end
when green flag clicked
forever
if <not <touching color [color of the ground]>>
repeat until <touching color [color of the ground]>
change y by (-...) // Put in a negative number
end
end
if <touching color [color of the ground]>
change y by (...) // Put in a short number
For an advanced platformer (perfect moving and jumping), use this:
when green flag clicked
forever
change [Yv v] by (-0.5)
if <key [right arrow v] pressed?> then
point in direction (90 v)
change [Xv v] by (0.7)
end
if <key [left arrow v] pressed?> then
point in direction (-90 v)
change [Xv v] by (-0.7)
end
set [Xv v] to ((Xv) * (0.9))
change x by (Xv)
if <touching color [...]?> then
change y by (1)
if <touching color [...]?> then
change y by (1)
if <touching color [...]?> then
change y by (1)
if <touching color [...]?> then
change y by (1)
if <touching color [...]?> then
change y by (1)
if <touching color [...]?> then
change x by ((Xv) * (-1))
change x by (-1)
change y by (-5)
change x by (1)
if <key [up arrow v] pressed?> then
if <(Xv) > [0]> then
set [Xv v] to [-8]
else
set [Xv v] to [8]
end
set [Yv v] to [10]
else
set [Xv v] to [0]
end
end
end
end
end
end
end
change y by (Yv)
if <touching color [...]?> then
change y by ((Yv) * (-1))
set [Yv v] to [0]
end
change y by (-1)
if <touching color [...]?> then
if <key [up arrow v] pressed?> then
set [Yv v] to [10]
end
end
change y by (1)
end

Last edited by fupi437 (Dec. 2, 2013 11:25:59)


Fupi437. A diversão começa aqui. Projetos incríveis completamente em português!!
Switta70
Scratcher
100+ posts

Platformer Movements

good but do you kno smooth walking
fupi437
Scratcher
25 posts

Platformer Movements

Switta70 wrote:

good but do you kno smooth walking
Yes, I know.

Fupi437. A diversão começa aqui. Projetos incríveis completamente em português!!

Powered by DjangoBB