I was wondering how you would make a game that one sprite touches another sprite and you move on to the next level.
Also, while I have your attention. How would I make a sprite jump? Thanks so much!
Offline
Scratch doesn't come equipped with a level system (which is good) so you have to build your own. Most people use backgrounds as levels so you can do something like this:
When flag clicked If <[sprite 1] touching [sprite 2]> Broadcast [level up] when I receive [level up] Set background to [level 2]Since you will have more than just a background for each scenes, use a variable to save what level you are currently on, and then use if blocks to say "if the variable says it's level two, get all the level two enemies in place (broadcast)".
Offline
A variable is like a slot where you can store a number or a word (also called a string). You can read the value of the variable, or change the value of the variable. You can take the variable, and compare it with another value...
<(variable) > ()>
<(variable) = ()>
<(variable) < ()>You can also perform arithmetic operations on a variable, using the () + (), () - (), (etc.) blocks.
set [variable v] to []... or change its value (set it to itself + value)
change [variable v] by []Your project can have an indefinite number of variables. They are useful if you need to store current game statistics. For example, the player's health, attack strength, level, etc. Storing data and then recalling it -- or using it somewhere in the program -- is the basis for programming in any language.
Last edited by amcerbu (2012-09-02 23:15:47)
Offline
Okay, but my problem is more along the lines of:
If I want to say something like:
If sprite 1 touching sprite 2
then
And then that's where I want to find away to switch to another background or level and make "obstacles" or enemies appear.
(By the way, thanks you guys for the help. It means a lot)
Offline
Here's the simplest way to do this:
Put this script in "Sprite1":
when gf clicked forever if < touching [Sprite2 v]?> broadcast [ChangeBG1 v] end endAnd then put this script in the stage:
when I receive [ChangeBG1 v] switch to background [BG1 v]
Last edited by amcerbu (2012-09-02 23:37:59)
Offline
In regards to jumping:
This platforming base wiki article, this jumping wiki article, and this forum post should help
Offline
stevetheipad wrote:
Scratch doesn't come equipped with a level system (which is good) so you have to build your own. Most people use backgrounds as levels so you can do something like this:
When flag clicked If <[sprite 1] touching [sprite v]> Broadcast [level up v] when I receive [level up v] Set background to [level 2 v]Since you will have more than just a background for each scenes, use a variable to save what level you are currently on, and then use if blocks to say "if the variable says it's level two, get all the level two enemies in place (broadcast)".
just a fix!
Offline
4 jumping: Find a platform game where you like how the avatar moves (specifically jumps) and use that engine (moving script) in your game, just give credit to the person you took the engine from. You can make a avatar jump a lot of ways so I suggest finding a way that you like. If ur confused with something just tell me
4 next level thing:
You'll need a variable (like this):
(level)Once you've made that you can get started. Here's ur script:
when gf clicked set [level v] to (0) forever if <touching [exit door v]?> change [level v] by (1) end endyou might also want this script, it goes to the background:
when gf clicked if <(level) = (1)> switch to background [level1] endDuplicate the if part 4 each level. Improvise a script like this 4 other sprites (telling the avatar where to go at the start of a level, telling the exit door where to move, instructing baddies to be on the scene etc.). Good Luck
Last edited by tree-hugger (2012-09-07 00:08:36)
Offline
tree-hugger wrote:
4 jumping: Find a platform game where you like how the avatar moves (specifically jumps) and use that engine (moving script) in your game, just give credit to the person you took the engine from. You can make a avatar jump a lot of ways so I suggest finding a way that you like. If ur confused with something just tell me
4 next level thing:
You'll need a variable (like this):(level)Once you've made that you can get started. Here's ur script:when gf clicked set [level v] to (0) forever if <touching [exit door v]?> change [level v] by (1) wait until <not <touching [exit door v]?>> endyou might also want this script, it goes to the background:when gf clicked forever if <(level) = (1)> switch to background [level1] endDuplicate the if part 4 each level. Improvise a script like this 4 other sprites (telling the avatar where to go at the start of a level, telling the exit door where to move, instructing baddies to be on the scene etc.). Good Luck
Fixed.
Offline