class InvertedPendulum::InvPendWindow

Attributes

cart[RW]
pix_height[R]
pix_width[R]

Public Class Methods

new(width: 1280, height: 1024) click to toggle source
Calls superclass method
# File neater/rnlib/inverted_pendulum.rb, line 63
def initialize(width: 1280, height: 1024)
  super(@pix_width = width, @pix_height = height, false)
  self.caption = "RubyNEAT Inverted Pendulum Simulation -- use mouse wheel to bang the cart."

  @background = {image: Gosu::Image.new(self, 'public/background.png', true),
                 x: 0,
                 y: 0,
                 scale: 1.0
                }
end

Public Instance Methods

button_down(id) click to toggle source
# File neater/rnlib/inverted_pendulum.rb, line 90
def button_down(id)
  @cart.button_down(id) unless @cart.nil?
end
button_up(id) click to toggle source
# File neater/rnlib/inverted_pendulum.rb, line 94
def button_up(id)
  @cart.button_up(id) unless @cart.nil?
end
draw() click to toggle source
# File neater/rnlib/inverted_pendulum.rb, line 78
def draw
  @background[:image].draw(@background[:x],
                           @background[:y],
                           0,
                           @background[:scale],
                           @background[:scale])

  @cart.draw unless cart.nil?
end
needs_cursor?() click to toggle source
# File neater/rnlib/inverted_pendulum.rb, line 88
def needs_cursor?; true; end
update() click to toggle source
# File neater/rnlib/inverted_pendulum.rb, line 74
def update
  @cart.update unless @cart.nil?
end