Discuss Scratch

dracae
Scratcher
1000+ posts

Beginner with many questions.

Well, you could have a variable “Amount Of Windows Fixed”
Whenever the game starts, set it to 0.
Then, every time a window is fixed, the variable would be increased by 1.
Hope I helped!

drmcw
Scratcher
1000+ posts

Beginner with many questions.

mgrobbel wrote:

After some time off to work on other things, I'm looking for a little more help. I have a question regarding clones:

I'm trying to find a way to detect that all my windows are “fixed”. This will then end the game, but I can change that to end a level in the future. I have made clone windows in my game. Each window is a clone and randomly chooses a costume at the start of the game showing either fixed or two different broken costumes. The main character, Ralph, fixes windows by changing broken ones (costume 2 or 3) to fixed windows (costume 1). I'm not sure if my script for detecting all windows are fixed (costume 1) is faulty or if because the windows are clones, Scratch doesn't keep track of each clones costume. Do clones register as individual sprites to the point where Scatch would know which costume each clone is currently on or does it just track the original sprite?

If Scratch does not know the costume of each clone, is there a different way to end the game/complete the level upon the fixing of each window?

http://scratch.mit.edu/projects/10352728

Clones are very useful but annoying at times, obviously scratch does know what costume each one has but won't allow you access to that information. You'll probably find that you can get the clone's costume if you use the costume # monitor within a when I start as a clone stack but using it anywhere else will just return the sprite's costume. To get around this, as dracae says, you'll have to duplicate the information using variables. In this case probably just have a “broken window” or “fixed window” variable and decrement or increment as windows are fixed. Then just check for 0 or however many windows there are to know when the level is complete.

Last edited by drmcw (June 13, 2013 04:36:38)


10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
ErnieParke
Scratcher
1000+ posts

Beginner with many questions.

ErnieParke wrote:

mgrobbel wrote:

After some time off to work on other things, I'm looking for a little more help. I have a question regarding clones:

I'm trying to find a way to detect that all my windows are “fixed”. This will then end the game, but I can change that to end a level in the future. I have made clone windows in my game. Each window is a clone and randomly chooses a costume at the start of the game showing either fixed or two different broken costumes. The main character, Ralph, fixes windows by changing broken ones (costume 2 or 3) to fixed windows (costume 1). I'm not sure if my script for detecting all windows are fixed (costume 1) is faulty or if because the windows are clones, Scratch doesn't keep track of each clones costume. Do clones register as individual sprites to the point where Scatch would know which costume each clone is currently on or does it just track the original sprite?

If Scratch does not know the costume of each clone, is there a different way to end the game/complete the level upon the fixing of each window?

http://scratch.mit.edu/projects/10352728
No, Scratch cannot simply access each clones costumes (nor variables), which I heard has been an issue with various Scratchers in their programs. Although you can't access the costumes directly, you can still access them with a bit of code. It's late where I am, though I'll come back by tomorrow morning. ;)

With regards,

ErnieParke

P.S. I hadn't gotten a chance to say this yet, but hello mgrobbel and welcome to Scratch! I hope that you have a wonderful time here!
Well, it looks like dracae just did what I was about to do, and so I'd recommend looking at his post above. ;)

With regards,

ErnieParke

mwiedmann
Scratcher
100+ posts

Beginner with many questions.

Whenever Freddy fixes a window, have him “broadcast window_count and wait”. Each window will respond to this broadcast, so using dracae's global variable idea, increment the variable only if the window is still broken. Freddy can then check if BrokenWindows=0 then next level.

turkey3
Scratcher
1000+ posts

Beginner with many questions.

The way to detect clones' costumes is using a local variable for each clone representing its costume# and another variable representing its clone number, and that clone has to insert the costume number in item clone# of a list of clones' costumes. I know that sounds confusing

mgrobbel
Scratcher
9 posts

Beginner with many questions.

When I get a chance, I'll try and figure out what you've all said and implement it. This is the best part of Scratch in my opinion-trying to figure out solutions to problems. I'm sure I'll be back to ask questions if I can't get it to work. Thank you for giving me a starting point. Global variable and check that variable upon window fix. Got it.
mgrobbel
Scratcher
9 posts

Beginner with many questions.

Quick question: What happens when I have made a broadcast message, but it doesn't show up from the pull down list on another sprite? This seems to happen to me occasionally?
drmcw
Scratcher
1000+ posts

Beginner with many questions.

mgrobbel wrote:

Quick question: What happens when I have made a broadcast message, but it doesn't show up from the pull down list on another sprite? This seems to happen to me occasionally?
Never come across that. Either a bug or you haven't created the broadcast message as you expected.

10 !
ScratchVaders or Galaga?
Maybe Eliza can help you decide?
ErnieParke
Scratcher
1000+ posts

Beginner with many questions.

mgrobbel wrote:

Quick question: What happens when I have made a broadcast message, but it doesn't show up from the pull down list on another sprite? This seems to happen to me occasionally?
Well if that happens, then that means your already using the “hidden” broadcast message in that block, or at least that's what should be the case. By chance, is something else happening during these situations?

With regards,

ErnieParke

turkey3
Scratcher
1000+ posts

Beginner with many questions.

The wiki has an article called Detecting Clones that might be helpful for you.

eastons
Scratcher
25 posts

Beginner with many questions.

Here is a sample project to check status of clones to apply a win condition

http://scratch.mit.edu/projects/11112307/

What you can do is have a counter variable call it CountOfWindowClones.
On start give it a value of 1.

Now create a list called WindowState.

Now create a local variable for the window sprite called MyID

In Window Sprite::
When I start as clone {
Set MyID to CountofWindowClones
Change CountofWindowClones by +1
Add “MyRandomWindowState” to WindowState
}

When MyWindowState is Changed
replace item (MyID) of WindowState with “NewState”


Now in you main loop

Wait until <not <WindowState Contains “BROKEN” >>
YOU WIN!



PLEASE! Someone show me a better way

Eastons



Last edited by eastons (June 27, 2013 04:41:15)

Powered by DjangoBB