0

I'm writing a horse race/bet game using Shoes and I was wondering how I would be able to change the GUI in different areas of code. When I run this, I get the horse on one application and then the race line on another application, but I want them both on the same application. Do I need to set the actual Shoes app as a variable itself?

class Horse 
  def initialize()
    #puts "YOYOYOYO"
    #@number=i
    Shoes.app{
      @icon= image 'horsey.jpg'
      @icon.left = 100
      @icon.top = 50
    }
  end

  def neigh()
    #puts "Neighhhh"
  end

  def raceTime()
    time=rand(100)%20
    return time+10
  end
end

class HorseIcon
  def initialize(h)
    @horse= h
    @imageloc='horsey.jpg'
  end
end

class Game
  def initialize(h1, h2)
    contestants=[h1, h2]
    Shoes.app{
      @icon= image 'raceline.jpg'
      @icon.left = 100
      @icon.top = 70
    }
  end

  def race()
  end
end

game= Game.new(1,2) 
seabiscuit= Horse.new()
fankt
  • 1,007
  • 1
  • 7
  • 16
Skorpius
  • 2,135
  • 2
  • 26
  • 31

1 Answers1

0

You are using two separate Shoes.app classes. I think that's your problem.

Judging by your code you seem to have a background in some other language, like Python. I suggest you clone the Shoes git and look at 'Shoes/samples' directory and play around with it. Or just look at this.

It will help you see what the code should look like.

PS : It will also give you some pointers toward Ruby style. You normally don't use {} for block when using multiple lines. You would use:

    Shoes.app do
      # code goes here
    end
Gill Bates
  • 1
  • 1
  • 4