How do you make a platform to jump on?

Offline
This wiki article offers some links to some good platformer bases (projects that should be easily remixable to make a platformer).
If you want a working script with an explanation of how it works, I can give you that.
The script you want will probably be slightly different than the bases, since there are many slight variances in platformers (wall jumping, x velocity, etc.)
Offline
MoreGamesNow wrote:
This wiki article offers some links to some good platformer bases (projects that should be easily remixable to make a platformer).
If you want a working script with an explanation of how it works, I can give you that.
The script you want will probably be slightly different than the bases, since there are many slight variances in platformers (wall jumping, x velocity, etc.)
Thank you! If its not much trouble could you tell me?

Offline
This is a script I've developed. On the bright side it doesn't require any special costumes or bumpers, and a simple copy-paste should be fine for just about any scenario; furthermore you can either use a single sprite for both the walls and floors, or a single color, rather than, as some scripts require, using separate colors/sprites for each. The downside is that it doesn't work well with animations (walking animations, jumping animations, etc.) as you could "animate" into a wall.
when gf clicked forever x-velocity part of script beneath this point if<key [right arrow v] pressed?> // increase velocity if right key pressed change [x-vel v] by (0.2) end if<key [left arrow v] pressed?> // decrease velocity if left key pressed change [x-vel v] by (-0.2) end change x by (x-vel) // move sprite by x-velocity if<touching [wall/floor v]?> // if sprite collides with wall set [x-vel v] to ((-0.5)*(x-vel)) // bounce off at half the velocity change x by (x-vel) // move out of wall if<touching [wall/floor v]?> change x by (x-vel) // keep moving out of wall if you're still touching it end end y-velocity part of script beneath this point change [y-vel v] by (-0.2) // decrease y velocity to simulate gravity change y by (y-vel) // move sprite along the y-axis if<touching [wall/floor v]?> // if touching wall/floor set [x-vel v] to ((0.94)*(x-vel)) // decrease x velocity to simulate friction set [y-vel v] to ((-0.5)*(y-vel)) // reverse y velocity and divide by 2 change y by (y-vel) // bounce if<touching [wall/floor v]?> change y by (y-vel) // continue to bounce out of wall/floor end if<<key [up arrow v] pressed?> and <(y-vel) > (0)>> // if I just hit the floor, I can jump set [y-vel v] to (4) // jump if up arrow pressed end else set [x-vel v] to ((x-vel)*(0.98)) // friction if you're not on the ground end
Last edited by MoreGamesNow (2012-09-03 11:37:22)
Offline
... unless you make sure that all your animation costumes have the same shape, i.e. have the same pattern of transparent pixels. That way, switching costumes won't change the value of any "touching" blocks. If that doesn't make sense, I can explain in more depth (or someone else can).
Offline
amcerbu wrote:
... unless you make sure that all your animation costumes have the same shape, i.e. have the same pattern of transparent pixels. That way, switching costumes won't change the value of any "touching" blocks. If that doesn't make sense, I can explain in more depth (or someone else can).
Another way is to revert to the same costume every frame before running the movement script, and then reverting back to the costume you want visible.
Edit: taking advantage of single frame
Last edited by MoreGamesNow (2012-09-03 14:27:48)
Offline
MoreGamesNow wrote:
This is a script I've developed. On the bright side it doesn't require any special costumes or bumpers, and a simple copy-paste should be fine for just about any scenario; furthermore you can either use a single sprite for both the walls and floors, or a single color, rather than, as some scripts require, using separate colors/sprites for each. The downside is that it doesn't work well with animations (walking animations, jumping animations, etc.) as you could "animate" into a wall.
when gf clicked forever x-velocity part of script beneath this point if<key [right arrow v] pressed?> // increase velocity if right key pressed change [x-vel v] by (0.2) end if<key [left arrow v] pressed?> // decrease velocity if left key pressed change [x-vel v] by (-0.2) end change x by (x-vel) // move sprite by x-velocity if<touching [wall/floor v]?> // if sprite collides with wall set [x-vel v] to ((-0.5)*(x-vel)) // bounce off at half the velocity change x by (x-vel) // move out of wall if<touching [wall/floor v]?> change x by (x-vel) // keep moving out of wall if you're still touching it end end y-velocity part of script beneath this point change [y-vel v] by (-0.2) // decrease y velocity to simulate gravity change y by (y-vel) // move sprite along the y-axis if<touching [wall/floor v]?> // if touching wall/floor set [x-vel v] to ((0.94)*(x-vel)) // decrease x velocity to simulate friction set [y-vel v] to ((-0.5)*(y-vel)) // reverse y velocity and divide by 2 change y by (y-vel) // bounce if<touching [wall/floor v]?> change y by (y-vel) // continue to bounce out of wall/floor end if<<key [up arrow v] pressed?> and <(y-vel) > (0)>> // if I just hit the floor, I can jump set [y-vel v] to (4) // jump if up arrow pressed end else set [x-vel v] to ((x-vel)*(0.98)) // friction if you're not on the ground end
THANK YOU SO MUCH!!!!

Offline
when gf clicked forever if (not touching ground) //if it isn't touching the ground,it goes down go down end if (touching ground) //if it is,it goes up go up end when gf clicked //this is the controls script forever if (up) go up end if (down) go down end if (left) go left end if (right) go right end
Last edited by dvd4 (2012-09-04 15:43:35)
Offline
dvd4 wrote:
when gf clicked forever if (not touching ground) //if it isn't touching the ground,it goes down go down end if (touching ground) //if it is,it goes up go up end when gf clicked //this is the controls script forever if (up) go up end if (down) go down end if (left) go left end if (right) go right end
Offline