Hi everyone. I am in a computer science class, and I am trying to make a maze game in scratch (not a scary one, mind you all!), and I am trying to make something happen. At the end of the maze, there is a wall blocking off the exit to the outside of the maze. When the player (a tiny black square) hits another sprite located somewhere in the maze, the wall at the end should be gone, not just hidden, but gone. I do not want to get rid of the script completely, I just need something that will temporarily get rid of the wall and it's code. Any help would be greatly appreciated. Thanks!
Offline
Well, if you post your scripts, i could help you better, as i do not know the whole situation. Sounds like you need a Boolean variable.
Regards,
CAA14
Offline
You should do something like this
When sprite 1 touches sprite 2
broadcast (hide)
Now on the objects code that is to be hidden, add this.
When I receive (hide)
Hide.
Sorry I could not give a better visual representation. I can't get scratch block a to work.
Offline
CAA14, I don't actually have any code for this part. I just need to know the code, as it is for homework. If you have any ideas for this from what I have said previously, go right ahead. Thanks.
Offline
Well, if you need the actual code, I don't think we should be helping you, because it's considered cheating.
Offline
Sorry, new here, don't get the logistics of scratch and what not... Sorry! I think I have a solution but if you guys could just tell me if it could work that would be great...
I think I should use a
[x position] of [Sprite1]And also a
[y position] of [Sprite 1]so that when my character gets to the exact x and y coords it gets rid of the wall at the end. Would that work?
Offline
No, because then it would have to be to the exact pixel.
Try if touching sprite 1.
Offline
Thanks! I'll try that and post back with what happens! Thanks everyone for helping me out!
Offline
Hmmm... Still not working... I put in a
when gf clicked
if touching sprite4
broadcast hide
(sorry for no blocks)
and still nothing. Now what? I am completely clueless on what to do.
Offline
That code only hides the wall if you click on the green flag if at that moment the two sprites are touching. If I understand you correctly, what you want is for the wall to hide when the two sprites touch. How about this:
When gf clicked
Wait until touching sprite4
broadcast hide
then the wall will hide when the two sprites touch.
(I think. I'm new at this too)
Offline
Yes, you need to have that in a forever loop, like this:
when gf clicked forever if <touching? [Switch v]> broadcast [hide wall v] stop script end endThat should work.
Offline
However, the wall needs the when I receive hide, hide script.
Offline
Yes, of course.
when i receive [hide wall v] hide^ That would go in the wall that you want to make disappear.
Offline
Hey, thanks everybody, I will try this out, and thanks for all the help! I'll post back in a few minutes!
Offline
Yay! It works, thanks so much everybody! This helps me out so much! Thanks again!
Offline
No problem, if you need anymore help, just ask.
Regards,
CAA14
Offline
It should be this:
For the main sprite:
when gf clicked forever if <touching [that sprite]> broadcast [hide]For "that sprite"
when i receive [hide] hideHope this helps!
Offline