Permalink
Browse files

Initial commit.

  • Loading branch information...
0 parents commit 78496e7f83b39c603fc2a2fa5ee94674c09d388b Adam Fraser, Jason Weathered, Nate Kane, Odin Dutton, and Tate Johnson committed with Nov 16, 2012
Showing with 46 additions and 0 deletions.
  1. +3 −0 README.markdown
  2. +43 −0 hrdlr.rb
@@ -0,0 +1,3 @@
+# hrdlr
+
+TODO: Add a sweet README.
@@ -0,0 +1,43 @@
+class Sprite
+ def self.player_normal
+ <<-SPRITE.gsub(/^ {4}/, '')
+ o
+ <|-
+ / >
+ SPRITE
+ end
+
+ def self.hurdle
+ '#'
+ end
+
+ def self.track_line
+ '-' * 80
+ end
+end
+
+class Frame
+ def initialize(width, height)
+ @rows = height.times.map { ' ' * width }
+ end
+
+ def draw(x, y, sprite)
+ lines = sprite.split("\n")
+ lines.each_with_index do |line, i|
+ @rows[y+i][x..x+line.size-1] = line
+ end
+ end
+
+ def render
+ @rows.each do |row|
+ puts row
+ end
+ end
+end
+
+frame = Frame.new 80, 6
+frame.draw 0, 0, Sprite.track_line
+frame.draw 0, 5, Sprite.track_line
+frame.draw 4, 2, Sprite.player_normal
+frame.draw 10, 4, Sprite.hurdle
+frame.render

0 comments on commit 78496e7

Please sign in to comment.