diff --git a/ruby/HP50g_screenshots.png b/ruby/HP50g_screenshots.png deleted file mode 100644 index b9b9523..0000000 Binary files a/ruby/HP50g_screenshots.png and /dev/null differ diff --git a/ruby/bin/gosuhunt b/ruby/bin/gosuhunt index decf7a0..303e323 100755 --- a/ruby/bin/gosuhunt +++ b/ruby/bin/gosuhunt @@ -7,7 +7,11 @@ require 'minehunt' class GosuHunt < Gosu::Window def initialize( number_of_mines = 20 ) - super 325, 180 + @scale = 4 + @sprite_size = 6 + + super ( @scale * ( @sprite_size * 16 ) ) + 16 + @scale, + ( @scale * ( @sprite_size * 8 ) ) + 20 + 8 + @scale self.caption = 'Gosu Hunt' @@ -17,12 +21,16 @@ class GosuHunt < Gosu::Window @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 ), - mine: Gosu::Image.from_text( '<>', 20 ), - cell: Gosu::Image.from_text( '██', 20 ), - visited_cell: Gosu::Image.from_text( ' ', 20 ) } + @images = { explorer: Gosu::Image.from_blob( @sprite_size, @sprite_size, bits_to_rgbas( '000000001100011110011110001100000000' ) ), + dead_explorer: Gosu::Image.from_blob( @sprite_size, @sprite_size, bits_to_rgbas( '100001010010001100001100010010100001' ) ), + door: Gosu::Image.from_blob( @sprite_size, @sprite_size, bits_to_rgbas( '010101101010' ) * ( @sprite_size / 2 ) ), + mine: Gosu::Image.from_blob( @sprite_size, @sprite_size, bits_to_rgbas( '111111110011100001100001110011111111' ) ), + cell: Gosu::Image.from_blob( @sprite_size, @sprite_size, bits_to_rgbas( '1' ) * @sprite_size * @sprite_size ), + visited_cell: Gosu::Image.from_blob( @sprite_size, @sprite_size, bits_to_rgbas( '0' ) * @sprite_size * @sprite_size ) } + end + + def bits_to_rgbas( bits ) + bits.gsub( '0', "\0\0\0\0" ).gsub( '1', "\255\255\255\255" ) end def new_level @@ -75,11 +83,11 @@ class GosuHunt < Gosu::Window def draw self.caption = if @state[:dead] - "You died! :(, score #{@field.score} " + "You blew up!! :(, score: #{@field.score} " elsif @state[:victory] - "You won!! :), score #{@field.score} " + "You won!! :), score: #{@field.score} " else - "#{@field.number_of_mines} mines, #{@field.count_nearby_mines} nearby, score #{@field.score}" + "Near #{@field.count_nearby_mines} mines, score: #{@field.score}" end @font.draw_text( caption, 0, 0, 0 ) @@ -96,7 +104,11 @@ class GosuHunt < Gosu::Window @images[:mine] else @images[:cell] - end ).draw( x * 10, (y * 20) + 20, 0 ) + end ).draw ( @scale * ( x * @sprite_size ) ) + x + @scale, + ( @scale * ( y * @sprite_size ) ) + 20 + y + @scale, + 0, + @scale, + @scale end end end