Fix segfault by moving "register" to the update call, rather than the draw one
This commit is contained in:
parent
d9bcf32e17
commit
70f888196f
1 changed files with 18 additions and 9 deletions
13
main.rb
13
main.rb
|
|
@ -217,10 +217,12 @@ class Hex
|
||||||
@hexid = SecureRandom.uuid
|
@hexid = SecureRandom.uuid
|
||||||
@dead = false
|
@dead = false
|
||||||
end
|
end
|
||||||
|
def update
|
||||||
def draw
|
|
||||||
amidead?
|
amidead?
|
||||||
$hex_bgs.register(@hexid, @text_props.bg_color)
|
$hex_bgs.register(@hexid, @text_props.bg_color)
|
||||||
|
end
|
||||||
|
def draw
|
||||||
|
amidead?
|
||||||
$hex_bgs[@text_props.bg_color].draw(
|
$hex_bgs[@text_props.bg_color].draw(
|
||||||
@x, @y, 0, 1, 1, Gosu::Color::WHITE
|
@x, @y, 0, 1, 1, Gosu::Color::WHITE
|
||||||
) # layer 0: hex-bg
|
) # layer 0: hex-bg
|
||||||
|
|
@ -344,6 +346,13 @@ class HexagonTerminalWindow < Gosu::Window
|
||||||
end
|
end
|
||||||
print "\x1b[G\x1b[2K#{out}\x1b[#{new_text[2]+1}G"
|
print "\x1b[G\x1b[2K#{out}\x1b[#{new_text[2]+1}G"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# End of update should call hex updates
|
||||||
|
@hexes.each do |rex|
|
||||||
|
rex.each do |hex|
|
||||||
|
hex.update
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def draw
|
def draw
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue