Sha256: c017cbccb777adbb5d7c1d13cd6234d4112755a666974d37fdc02d99fb76d471

Contents?: true

Size: 643 Bytes

Versions: 2

Compression:

Stored size: 643 Bytes

Contents

require "gosu"
require "gosu_more_drawables"

class DemoWindow < Gosu::Window
  def initialize
    super(500, 500, false)

    @nodes = []
  end

  def draw
    sine = Math.sin(Gosu.milliseconds / 1000.0)
    c = (255 * sine).to_i.clamp(10, 255)
    color = Gosu::Color.rgb(c, 255, c / 2)

    Gosu.draw_path(@nodes, color)

    @nodes.each do |node|
      Gosu.draw_circle(node.x, node.y, 4, 4, color)
    end
  end

  def update
    x = 20
    @nodes.clear
    20.times do |i|
      @nodes << Gosu::PathNode.new(x + i, Math.cos(Gosu.milliseconds / 100.0 + i.to_f) * 10 + self.height / 2)
      x += 20
    end
  end
end

DemoWindow.new.show

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gosu_more_drawables-0.3.1 examples/path_with_circles.rb
gosu_more_drawables-0.3.0 examples/path_with_circles.rb