Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Initial commit.
- Loading branch information
Adam Fraser, Jason Weathered, Nate Kane, Odin Dutton, and Tate Johnson
authored and
twe4ked
committed
Nov 16, 2012
0 parents
commit 78496e7f83b39c603fc2a2fa5ee94674c09d388b
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# hrdlr | ||
|
||
TODO: Add a sweet README. |
43
hrdlr.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |