Class: Bang::View
Constant Summary
Constants included
from CursesLib
CursesLib::BLUE_COLOR, CursesLib::CYAN_COLOR, CursesLib::GREEN_COLOR, CursesLib::MAGENTA_COLOR, CursesLib::ORANGE, CursesLib::ORANGE_COLOR, CursesLib::RED_COLOR, CursesLib::WHITE_COLOR, CursesLib::YELLOW_COLOR
Instance Method Summary
collapse
Methods included from CursesLib
#attrib
Constructor Details
#initialize(origin) ⇒ View
Returns a new instance of View.
17
18
19
|
# File 'lib/bang_view.rb', line 17
def initialize origin
@last_frame = Bang::InitialFrame.new(origin)
end
|
Instance Method Details
#render ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/bang_view.rb', line 21
def render
@last_frame = Bang::Frame.new(@last_frame)
frames = [ @last_frame.last_frame.last_frame,
@last_frame.last_frame,
@last_frame ]
frames.each do |frame|
frame.particles.each do |part|
color do
Curses::setpos *translate(part)
Curses::addstr "*"
end
end
end
return @last_frame.alive?
end
|
#translate(part) ⇒ Object
39
40
41
42
43
|
# File 'lib/bang_view.rb', line 39
def translate(part)
x = part[:x]
y = YMAX - part[:y]
[y, x]
end
|