From: Sathya Levy Date: 2011-12-25T04:42:42+09:00 Subject: Game of memory writing a game of memory, stuck on how to freeze buttons once a match is made any help would be appreciated. Yes, this is for school intro to programming, my code isn't very eloquent. require "fox16" include Fox class ClickButton < FXButton def initialize(parent, a, b, num) super(parent, nil, :width =>100, :height=>80, :x=>a, :y=>b, :opts=>LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|FRAME_RAISED|FRAME_THICK|LAYOUT_FIX_X|LAYOUT_FIX_Y) @symbol = num self.connect(SEL_COMMAND) do self.parent.list(self) if self.parent.check == true self.text = @symbol end end end end class MemoryWindow < FXMainWindow def initialize(app_instance) super(app_instance,"Memory Game", :width => 400, :height => 320) @clicked_list=[] array1 = [1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8] array1=array1.shuffle 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) num=array1.pop num=num.to_s @b3=ClickButton.new(self, 0, 160, num) num=array1.pop num=num.to_s @b4=ClickButton.new(self, 0, 240, num) num=array1.pop num=num.to_s @b5=ClickButton.new(self, 100, 0, num) num=array1.pop num=num.to_s @b6=ClickButton.new(self, 100, 80, num) num=array1.pop num=num.to_s @b7=ClickButton.new(self, 100, 160, num) num=array1.pop num=num.to_s @b8=ClickButton.new(self, 100, 240, num) num=array1.pop num=num.to_s @b9=ClickButton.new(self, 200, 0, num) num=array1.pop num=num.to_s @b10=ClickButton.new(self, 200, 80, num) num=array1.pop num=num.to_s @b11=ClickButton.new(self, 200, 160, num) num=array1.pop num=num.to_s @b12=ClickButton.new(self, 200, 240, num) num=array1.pop num=num.to_s @b13=ClickButton.new(self, 300, 0, num) num=array1.pop num=num.to_s @b14=ClickButton.new(self, 300, 80, num) num=array1.pop num=num.to_s @b15=ClickButton.new(self, 300, 160, num) num=array1.pop num=num.to_s @b16=ClickButton.new(self, 300, 240, num) num=array1.pop num=num.to_s end def list(some_button) @clicked_list << some_button puts @clicked_list.inspect end def check if @clicked_list.length > 2 @clicked_list=[] @b1.text=nil @b2.text=nil @b3.text=nil @b4.text=nil @b5.text=nil @b6.text=nil @b7.text=nil @b8.text=nil @b9.text=nil @b10.text=nil @b11.text=nil @b12.text=nil @b13.text=nil @b14.text=nil @b15.text=nil @b16.text=nil return false else return true end end def create super self.show(PLACEMENT_SCREEN) end end app=FXApp.new MemoryWindow.new(app) app.create app.run -- Posted via http://www.ruby-forum.com/.