Hi. I'm in the middle of a Scratch project and I'm having difficulties with one thing.
The objective of my game is to collect a number of items by killing enemies to proceed to the next level. I managed to do it for the first level, but on the next level, the door I use to get to the next level still shows on the second level when I only want to appear when the player collects a number of items. How do I repeat this and the other levels?
Offline
MarkWilson123 wrote:
Hi. I'm in the middle of a Scratch project and I'm having difficulties with one thing.
The objective of my game is to collect a number of items by killing enemies to proceed to the next level. I managed to do it for the first level, but on the next level, the door I use to get to the next level still shows on the second level when I only want to appear when the player collects a number of items. How do I repeat this and the other levels?
Do you mind post the link of your project?
It'll be easier to see what's your question.
Offline
rlojunior wrote:
MarkWilson123 wrote:
Hi. I'm in the middle of a Scratch project and I'm having difficulties with one thing.
The objective of my game is to collect a number of items by killing enemies to proceed to the next level. I managed to do it for the first level, but on the next level, the door I use to get to the next level still shows on the second level when I only want to appear when the player collects a number of items. How do I repeat this and the other levels?Do you mind post the link of your project?
It'll be easier to see what's your question.
How do I do that?
Offline
At the top next to file, click "share" and "share this project online". Did you remember to reset the variable every time you start a new level and not just when the green flag is clicked?
Offline
Prestige wrote:
At the top next to file, click "share" and "share this project online". Did you remember to reset the variable every time you start a new level and not just when the green flag is clicked?
Alright. And I'm not quite sure how to do that.
Offline
when gf clicked forever if <touching [object v]?> change [var v] by (1) end wait until <(var) = (number)> broadcast [next level v]You will need to hide the items after they're collected and you may want to change the variable number according to the number of items in the level.
Offline
shpeters wrote:
when gf clicked forever if <touching [object v]?> change [var v] by (1) end wait until <(var) = (number)> broadcast [next level v]You will need to hide the items after they're collected and you may want to change the variable number according to the number of items in the level.
Thanks, but what number do I put in the var = bit? Or do I have to create a new variable called "number"?
Offline
MarkWilson123 wrote:
shpeters wrote:
when gf clicked forever repeat until <(var) = (number)> if <touching [object v]?> change [var v] by (1) wait until <not (touching [object v]?)> end end set [var v] to (0)//Added. broadcast [next level v]You will need to hide the items after they're collected and you may want to change the variable number according to the number of items in the level.Thanks, but what number do I put in the var = bit? Or do I have to create a new variable called "number"?
I edited the script above ^^ so that it would work.
Anyway, it depends how you look at it. You could, but then you'd need to set (number) to the number of objects in the next level, or you could use a conditional like this:
<<<<(level) = (1)> and <(var) = [number]>> or <<(level) = (2)> and <(var) = [number]>>> or (more...)>
Offline
MarkWilson123 wrote:
Hi. I'm in the middle of a Scratch project and I'm having difficulties with one thing.
The objective of my game is to collect a number of items by killing enemies to proceed to the next level. I managed to do it for the first level, but on the next level, the door I use to get to the next level still shows on the second level when I only want to appear when the player collects a number of items. How do I repeat this and the other levels?
You could do this:
when gf clicked set [items collected v] to [0] forever if <touching [item v]?> change [items collected v] by (1) wait until <not<touching [item v]?>> end when gf clicked broadcast [door show v] //this makes the door show forever if <(items collected) > (whatever you want)> broadcast [door hide v] endThis works only if I understood you right:
Offline
TorbyFork234 wrote:
MarkWilson123 wrote:
Hi. I'm in the middle of a Scratch project and I'm having difficulties with one thing.
The objective of my game is to collect a number of items by killing enemies to proceed to the next level. I managed to do it for the first level, but on the next level, the door I use to get to the next level still shows on the second level when I only want to appear when the player collects a number of items. How do I repeat this and the other levels?You could do this:
when gf clicked set [items collected v] to [0] forever if <touching [item v]?> change [items collected v] by (1) wait until <not<touching [item v]?>> end when gf clicked broadcast [door show v] //this makes the door show forever if <(items collected) > (whatever you want)> broadcast [door hide v] endThis works only if I understood you right:
You want it so that the door will show, and once you collect a certain amount of items, it'll hide, and not reappear.
If I got it wrong, please explain a little clearer what you want.
Sorry. I meant I want the door to show when I collect a number of items, not hide. I want the door to hide and wait on the next level and when I collect a number of items again, it shows again. Hopefully you've got it now.
Offline
when gf clicked forever if <touching [enemy1 v]?> change [items v] by 1 broadcast [enemy 1 defeated v] end if <touching [enemy2 v]?> change [items v] by 1 broadcast [enemy 2 defeated v] end endand
when gf clicked wait until <(items) > (number)> change [level v] by (1) set [items v] to 0
Offline
bubby3 wrote:
when gf clicked forever if <touching [enemy1 v]?> change [items v] by 1 broadcast [enemy 1 defeated v] end if <touching [enemy2 v]?> change [items v] by 1 broadcast [enemy 2 defeated v] end endandwhen gf clicked wait until <(items) > (number)> change [level v] by (1) set [items v] to 0
Thanks, but do these go in the script of the character I'm playing as or the door I use to get to the next level?
Offline
bubby3 wrote:
when gf clicked forever if <touching [enemy1 v]?> change [items v] by 1 broadcast [enemy 1 defeated v] end if <touching [enemy2 v]?> change [items v] by 1 broadcast [enemy 2 defeated v] end endandwhen gf clicked wait until <(items) > (number)> change [level v] by (1) set [items v] to 0
That won't work, because as soon as the items are collected, the next level will start without the player needing to go into the door.
Offline