Skip to content

Instantly share code, notes, and snippets.

@NakedMoleRatScientist
Forked from jacius/gist:293129
Created February 3, 2010 02:23
Show Gist options
  • Save NakedMoleRatScientist/293270 to your computer and use it in GitHub Desktop.
Save NakedMoleRatScientist/293270 to your computer and use it in GitHub Desktop.
#! /usr/bin/ruby
# Plot random pixels.
require 'rubygems'
require 'rubygame'
include Rubygame
Width = 640
Height = 400
class RandomPixels
def initialize
@screen = Screen.new [Width, Height]
@events = EventQueue.new
@screen.fill [0, 0, 0]
@screen.update
end
def event_loop
loop do
@events.each { |event|
case event
when QuitEvent
return
end
}
draw
@screen.update
end
end
def draw
point = [rand(Width), rand(Height)]
color = [rand(255), rand(255), rand(255)]
@screen.set_at point, color
end
end
Rubygame.init
RandomPixels.new.event_loop
Rubygame.quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment