Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
I need a nested array please
Old
roofy
Guest
 
Status:
Posts: n/a
Default I need a nested array please - 12-06-2006, 03:25 AM

Hi there all, its me again, the pain in the neck
Our final project is coming up and I thought of the game called Memory. The object of the game is there will be 16 cards in a 4 cards across and 4 cards down giving me a 4x4 col/row table. The user will click on 2 different cards one at a time, and if there is a match between the 2 clicked on cards then the matched cards will be moved to the collection pile. When the user has collected all 8 pairs then the user wins.

Now the easist way I could think of doing this would be to build a nested array. So I wanted to know if it is possible to create nested array's in Alice. I know you can do it in standard C, but I have the faintest idea how I would do this in Alice. However, if I can not create nested array's then how would I go about building a 4x4 col/row setup?
   
Reply With Quote
Alternate to nested array.
Old
DrJim
Guest
 
Status:
Posts: n/a
Lightbulb Alternate to nested array. - 12-06-2006, 09:35 AM

When I started on the Christmas puzzle I posted a few days ago, I was going to use the same approach - but never really figured out how to do a multi-dimensional array in Alice. (Frankly, I didn't try too hard. )

Instead, I went to a simple list and didn't worry about the x-y placement, which was fine for the puzzle, since I eventually wanted to be able to use it with an arbitrary array size.

You might try the same thing with a list of 16 cards and the index also corresponding to a card position (defined in the initial setup). Then the same loop that would check to see if you clicked on a card could also check to see if the previous card checked on was the same type. (I know this is a bit brief, but see the code for the puzzle if you want to try it.)

If you do stay with the array approach, please post the result. I'd really like to see a good example of that method.
   
Reply With Quote
Old
roofy
Guest
 
Status:
Posts: n/a
Default 12-14-2006, 08:59 AM

Dr. Jim,
I have not forgotten you. I have been busy as a bee with my last project. I will have my file uploaded this afternoon with comments in my code
   
Reply With Quote
Old
roofy
Guest
 
Status:
Posts: n/a
Default 12-14-2006, 08:26 PM

I would put up my file for people to look at and see how the code works, but I have a nasty bug that I cannot seem to figure out because sometimes the program works and other times it does not. However, when it does not work, Alice spits out a runtime exception error when it is checking to see if the 2 textureMaps match. Has anyone have this type of problem?
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2019, Carnegie Mellon University
Alice 2.x 1999-2012, Alice 3.x 2008-2012, Carnegie Mellon University. All rights reserved.