I'm currently making and game called Platformer Boy, and as the name says, its a platformer game. I need to know how the character can jump, then fall down(Gravity?), and stand on platforms, as well as if the character falls off a platform, they lose a life and have to restart. I also need to know how to make it so when you run out of lives, you lose the game. Can someone post some scripts to help me out with my problem? Thanks for your time.
-Mattkrewe
P.S: Does anyone have any decent music I could use in my game, other then the music Scratch already has? Thanks!
Offline
http://wiki.scratch.mit.edu/wiki/Platformer
Hope it helped!
Offline
Offline
I'll just write them out for him
To jump (with gravity)
For the loosing lives if falling off platforms:whenclicked
foreverifkeyandup arrow ▼pressed?touching color ?colour of platformsetyVel ▼to14wait untilnottouching color ?repeat untiltouching color ?changeyVel ▼by-1iftouching color ?setyVel ▼to0whenclicked
foreverchange y byyVel
x:0 y:0 is the spawning point unless it's a scrolling platformer where you'd have to usewhenclicked
go to x:0y:0foreverify position<-180-180 is the bottom of screenchangelives ▼by-1go to x:0y:0
Game Over Script:setscroll ▼to0
you would have to put this script around all the scripts you use so that movement is disabled if it's game over. Then you could add a game over screen which would be a seperate sprite:foreveriflives>0every script you use here
whenclicked
hideforeveriflives=0show
Offline
To jump:
For the lives thing you would need to create a variable called lives and use this script.whenclicked
foreverifchange y by10too high?ifnottouching colourchange y by-3too strong/weak?
when gf is clickedforever iflives v=0broadcastgame over
Offline
Weird, I've used my scripts in the program and it works fine. 1 thing I forgot to mention is that you should probably include this block:
RIGHT AT THE TOP of the script, immediately below the when flag clicked block. Other things that might make it glitch:setyVel ▼to0
Offline
I have uploaded the current version of my game Phirrip. Please check it out and download it, and see what is wrong with it. However, I have an idea of what the problem might be, but I could be wrong.
*Please note that I haven't added in the losing lives if you fall off a platform script yet.
-Mattkrewe
Offline
Fixed.
Basically the problem was that "Level 1-1" was broadcasted while the "Level 1-1" screen was showing, not when the level actually starts so the player was playing without the screen showing. Also, the player wasn't starting on the platform. To fix this, I changed the script for W1 to this:
There was another problem with the jumping. Instead ofwhen I receiveLevel 1-1 ▼go to x:-176y:-2setyVel ▼to0wait5secsforeverrest of script
you included;changeyVel ▼by-1
You should just replace this and the jumping works much better.setyVel ▼to-1
Insert this script and you'll see the results!when I receiveLevel 1-1 ▼foreverifkeya ▼pressed?point in direction-90move5stepsifkeyd ▼pressed?point in direction90move5steps
Last edited by PhirripSyrrip (2012-06-10 03:09:00)
Offline
Which script are you talking about? For the jumping script, keep your current one except change "set yvel to -1" to "change yvel to -1". Add the "go to" block I added immediately under "when I receive level 1-1" and the "wait 5 secs" block where I put it. so change those 3 things about the script, you don't need another one.
For the moving script, add the script I added but delete the two scripts that start "when a key pressed" and "when d key pressed".
Offline
Never mind my last post. I put in all the scripts and it's working fine, however the losing lives script isn't working correctly. When the character falls off a platform, it stays there and doesn't lose a life. I might be able to fix it though.
-Mattkrewe
Offline
Mattkrewe wrote:
I have uploaded the newest version of Platformer Boy, I couldn't tell what was wrong with the losing lives script, so maybe you could figure it out please?
-Mattkrewe
Try using this script.
put a thin line at the bottom in a color you haven't used yet (color x)
whenclicked
foreveriftouching colorcolor xchangelifeby-1
Offline
Here is a gravity script. The color in the script can be changed to whatever color your platform is. The value gravity is set to if the up arrow is pressed can also be changed. It will affect the distance jumped.
whenclicked
setGravity ▼to0foreveriftouching colorcolor of groundsetGravity ▼to0change y by1ifkeyup arrow ▼pressed?setGravity ▼tothe larger this number is, the higher your sprite will jumpelsechangeGravity ▼by-1change y byGravity
Last edited by skippito (2012-06-20 17:23:29)
Offline