From: Khat Harr Date: 2011-12-25T08:37:36+09:00 Subject: Re: Game of memory First thing's first: it's easier to theorize when you're looking at more concise code. Code is not designed for computers, it's designed for programmers (otherwise we'd still be using punchcards). So make your code clean and clear, even if you're the only one reading it. num=array1.pop num=num.to_s @b1=ClickButton.new(self, 0, 0, num) num=array1.pop num=num.to_s @b2=ClickButton.new(self, 0, 80, num) If you're numbering a set of variables it's a hint that you should be using a container of some sort. In this case an array. --------------------------------- No: @b1 = ? @b2 = ? Yes: @b = [] @b[0] = ? @b[1] = ? Reason why: @b = [] array1.each_with_index do |ary_element, index| num = ary_element.to_s x = 100 * (index / 4) y = 80 * (index % 4) @b[index] = ClickButton.new(self, x, y, num) end --------------------------------- That should give you the ability to look at what you're doing far more easily. In regards to your question, I don't know anything about Fox so I can't give you a direct answer. I wouldn't give you code for an assignment anyway, but I can give you general advice as follows: You want to impose a specific state on an object. The state can be either on or off, so it is a 'boolean' state. Add a property to the object's class: @matched and initialize it to false. When the user creates a condition where the state of that object should be changed, set @matched to true. In the methods that determine how the object interacts (how to draw it, what to do when it is clicked, etc) check the value of @matched and react accordingly. As a side-note, I don't see what part of your code handles what to do when the user clicks on a button, so I don't really know where that check would go. Finally, when posting code that is more than 10 lines or so please save the code into a text file or rb file and attach it to your post rather than posting the code in the message body. :) Hope that helps. -- Posted via http://www.ruby-forum.com/.