Commit 78496e7 Adam Fraser, Jason Weathered, Nate Kane, Odin Dutton, and Tate Johnson
authored and committed
0 parents commit 78496e7 Copy full SHA for 78496e7
File tree 2 files changed +46
-0
lines changed
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
1
+ # hrdlr
2
+
3
+ TODO: Add a sweet README.
Original file line number Diff line number Diff line change
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
You can’t perform that action at this time.
0 commit comments