PDA

View Full Version : Buoy List, Boooyyyyy.


gballa1993
01-11-2014, 07:20 PM
"To determine when the game is over, you need a way to know when all the buoys have been picked up. To track the buoys that have been picked up, create a second world-level list, this one named picked UpBuoys and leave it empty. In the pickUpBuoy method, create a statement that adds the picked up buoy to the pickedUpBuoys list. Create a world-level method named checkIfGameIsOver and call it every time a buoy is picked up. When the size of pickedUpBuoys is equal to seven, the player wins the game and a 3D text object is used to display "You did it!".

Taken from Learning to program with Alice, 3rd Ed. by Wanda P Dann, Stephen Cooper, and Randy Pausch.


So, here's the issue. I've completed the majority of the assignment. Now comes the tricky part, I need to be able to add a +1, to the pickedUpBuoys list whenever I pick up a buoy, and this is driving me insane. Where is my program going wrong, I'd like some perspective, not a laid out list of what to do.

MrMoke
01-12-2014, 06:42 PM
I don't have a copy of the book, but the instructions would seem to indicate that two object lists are needed. One for the unfound allBouys, and one for the pickedUpBouys.
When a picked new bouy is encountered, it is to be removed from allBouys, and added to pickedupBouys. Eventually the size of the second list will equal 7.

Also, if you are using 2.4.1, the "while world is running" event might be broken.:(

gballa1993
01-13-2014, 06:41 PM
See, but I'm trying exactly that, but it doesn't give me the options. Presumably, I'm not doing the correct function.

Every time I try to remove from one list, and add to the other list, I don't know how to indicate at what position in the list that the item from allBuoys needs to go to. It always ends up putting a value of 1,1,1,1,1,1,1,1, etc. once I just pick up one buoy. I can't figure out the correct syntax to add/remove.

MrMoke
01-14-2014, 12:52 PM
See, but I'm trying exactly that, but it doesn't give me the options. Presumably, I'm not doing the correct function.

Every time I try to remove from one list, and add to the other list, I don't know how to indicate at what position in the list that the item from allBuoys needs to go to. It always ends up putting a value of 1,1,1,1,1,1,1,1, etc. once I just pick up one buoy. I can't figure out the correct syntax to add/remove.

Try looking at your list definitions again. They both need to be "Object" lists for it to work.

gballa1993
01-14-2014, 03:36 PM
The only options it gives me when I choose for

If item_from_allBuoys.vehicle == sailboat

(insert correct statement)

The only options it gives me regarding the list are in this screenshot. And if I choose those, when I pick up a buoy, it continues adding that object, similar to the 1,1,1,1,1,1,etc.

chickentree
01-15-2014, 09:20 AM
Of course this has never happened to ME, but I believe you are thinking your setup is basically correct and not carefully reading the responses.

You are meant to have two list of buoys one full and the other empty. Your second list is either not a list or not a list of buoys, if it was a list of buoys the results would not be 1,1,1, ... Due to the resolution I can not see the code in your attached picture and so can not be sure about what you are doing. I have however attached a movie that will show you the basic idea.

Hope this helps,
Mark

MrMoke
01-15-2014, 01:17 PM
But you are making progress.:)

Once you have identified an item in the first list, you can:

1) Add the list item to the (beginning or end) of a hit list.

2) Delete it from the original list so it can't be found again.

3) Perform whatever tasks need to be accomplished using the new hit list entry. To program the actions like turn or go invisible, you must first drag in the command using one of the original objects, then drag the array name in, and replace the original object name with appropriate list position.

If the first list becomes empty, you're done.

gballa1993
01-15-2014, 07:51 PM
I am so thick-skulled! Haha, thank you both very much, that actually makes much more sense now that I took a step back and looked at what I was actually trying to accomplish. If I do a

Do in order
If item_from_allBuoys.vehicle==sailboat
Add item_from_allBuoys.list to beginning of pickedUpBuoys.list
Remove item_from_allBuoys.list from allBuoys.list
Else
Do nothing

Does that sound fairly accurate?
I ask because my computer actually just took a dive, and I may have to re-image the hard drive. So..yay, starting over!

MrMoke
01-16-2014, 09:19 AM
I guess that would work as long as the item has already been attached to the sailboat somewhere else in the program.