[gosuhunt] fiddling around

This commit is contained in:
Gwenhael Le Moine 2023-02-09 16:21:33 +01:00
parent e6bb987641
commit 801490298c
No known key found for this signature in database
GPG key ID: FDFE3669426707A7

View file

@ -16,6 +16,7 @@ class GosuHunt < Gosu::Window
@finished = false
@state = { dead: false, victory: false }
@font = Gosu::Font.new( 20 )
@images = { explorer: Gosu::Image.from_text( '()', 20 ),
dead_explorer: Gosu::Image.from_text( '☠ ', 20 ),
door: Gosu::Image.from_text( '=>', 20 ),
@ -81,7 +82,7 @@ class GosuHunt < Gosu::Window
self.caption = "#{@field.number_of_mines} mines, #{@field.count_nearby_mines} nearby, score #{@field.score}"
end
Gosu::Font.new( 20 ).draw_text( self.caption, 0, 0, 0 )
@font.draw_text( self.caption, 0, 0, 0 )
@field.height.times do |y|
@field.width.times do |x|
@ -95,7 +96,8 @@ class GosuHunt < Gosu::Window
@images[:mine]
else
@images[:cell]
end ).draw( x * 2 * 10, (y * 20) + 20, 0 )
end )
.draw( x * 2 * 10, (y * 20) + 20, 0 )
end
end
end