Skip to content

Commit 78496e7

Browse files
Adam Fraser, Jason Weathered, Nate Kane, Odin Dutton, and Tate Johnsontwe4ked
authored andcommitted
Initial commit.
0 parents  commit 78496e7

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

README.markdown

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# hrdlr
2+
3+
TODO: Add a sweet README.

hrdlr.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
class Sprite
2+
def self.player_normal
3+
<<-SPRITE.gsub(/^ {4}/, '')
4+
o
5+
<|-
6+
/ >
7+
SPRITE
8+
end
9+
10+
def self.hurdle
11+
'#'
12+
end
13+
14+
def self.track_line
15+
'-' * 80
16+
end
17+
end
18+
19+
class Frame
20+
def initialize(width, height)
21+
@rows = height.times.map { ' ' * width }
22+
end
23+
24+
def draw(x, y, sprite)
25+
lines = sprite.split("\n")
26+
lines.each_with_index do |line, i|
27+
@rows[y+i][x..x+line.size-1] = line
28+
end
29+
end
30+
31+
def render
32+
@rows.each do |row|
33+
puts row
34+
end
35+
end
36+
end
37+
38+
frame = Frame.new 80, 6
39+
frame.draw 0, 0, Sprite.track_line
40+
frame.draw 0, 5, Sprite.track_line
41+
frame.draw 4, 2, Sprite.player_normal
42+
frame.draw 10, 4, Sprite.hurdle
43+
frame.render

0 commit comments

Comments
 (0)