I wanna know how to make my sprite hop when I press the space key, please help!
Offline
Try this:
when green flag clicked set [YVelocity# v] to (0) forever change y by (YVelocity#) if <key [space key v] pressed?> set [YVelocty# v] to (10) end if <touching color [ground color]?> set [YVelocity# v] to (0) else change [YVelocity# v] by (-1) endThis will work, basically, though you will get stuck slightly into the ground.
if <touching color [push up color]?> change y by (1) end
Offline
Ruso306444 wrote:
I wanna know how to make my sprite hop when I press the space key, please help!
OverPowered wrote:
Try this:
when green flag clicked set [YVelocity# v] to (0) forever change y by (YVelocity#) if <key [space key v] pressed?> set [YVelocty# v] to (10) end if <touching color [ground color]?> set [YVelocity# v] to (0) else change [YVelocity# v] by (-1) endThis will work, basically, though you will get stuck slightly into the ground.
To prevent this, make the "ground" color 1 pixel thick, and below it, have another color. Add this script at the end of your previous script:if <touching color [push up color]?> change y by (1) end
He said a simple hop
Try this:
when gf clicked forever if <key [space v] pressed?> repeat [10] change y by [5] wait [0.01] secs end wait [0.3] secs repeat [10] change y by [-5] wait [0.01] secs end endHope that helped!
Offline
7734f wrote:
Ruso306444 wrote:
I wanna know how to make my sprite hop when I press the space key, please help!
OverPowered wrote:
Try this:
when green flag clicked set [YVelocity# v] to (0) forever change y by (YVelocity#) if <key [space key v] pressed?> set [YVelocty# v] to (10) end if <touching color [ground color]?> set [YVelocity# v] to (0) else change [YVelocity# v] by (-1) endThis will work, basically, though you will get stuck slightly into the ground.
To prevent this, make the "ground" color 1 pixel thick, and below it, have another color. Add this script at the end of your previous script:if <touching color [push up color]?> change y by (1) endHe said a simple hop
Try this:when gf clicked forever if <key [space v] pressed?> repeat [10] change y by [5] wait [0.01] secs end wait [0.3] secs repeat [10] change y by [-5] wait [0.01] secs end endHope that helped!
With regards
~7734f
Even simpler:
when key [space v] pressed change y by (25) wait (.5) secs change y by (-25)
Last edited by Hyperbola (2013-04-15 19:54:59)
Offline