Skip to content

Instantly share code, notes, and snippets.

@yayugu
Created April 22, 2010 17:10
Show Gist options
  • Save yayugu/375492 to your computer and use it in GitHub Desktop.
Save yayugu/375492 to your computer and use it in GitHub Desktop.
require 'dxruby'
def simpleHash(x)
x = x * 1103515245 + 12345
return x & 2147483647
end
Window.width = 640
Window.height = 480
Window.bgcolor = [0, 0, 0]
Window.caption = "マトリックスもどき"
fontsize = 25
font = Font.new(fontsize, 'MS ゴシック')
characterType = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
lines = Array.new(8) do
x = rand(Window.width)
y = rand(Window.height)
Array.new(20) do |index|
{'x'=>x, 'y'=>(y - index * fontsize), 'character1'=>characterType[rand(characterType.size)], 'character2'=>characterType[rand(characterType.size)]}
end
end
# メインループ
Window.loop do
lines.each do |line|
line.each do |c|
Window.drawFont(c['x'], c['y'], c['character1'], font, :color=>[0, 255, 0], :alpha=>128)
Window.drawFont(c['x'], c['y'], c['character2'], font, :color=>[0, 255, 0], :alpha=>128)
c['y'] += 5
if c['y'] > Window.height
c['x'] = simpleHash(c['x']) % Window.width
c['y'] = 0
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment