btetris_kp 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/btetris_kp.gemspec +1 -1
- data/lib/btetris_kp/constants.rb +8 -1
- data/lib/btetris_kp/game.rb +1 -1
- data/lib/btetris_kp/gui/menuitem.rb +1 -1
- data/lib/btetris_kp/menu.rb +4 -4
- data/lib/btetris_kp/netgame.rb +1 -1
- data/lib/btetris_kp/netjoin.rb +8 -8
- data/lib/btetris_kp/netsetup.rb +3 -3
- data/lib/btetris_kp/version.rb +2 -2
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 0a70f6dc0867aa97326b8806f33db6826e0bc70a
         | 
| 4 | 
            +
              data.tar.gz: 371d203951eb610f14f66e0b2baaf24bb9a939fb
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7c2b705f40abcdd49b30656139a4f9cb57b45ef3d37fdcbafe1565e2d61aebfa1324b8928a6bc29dd9215cecd06b724d6aa88dab7e29b423fbfe85553486945a
         | 
| 7 | 
            +
              data.tar.gz: 9e7edd9ae546d95e9628c322365247c99e65d176b6a220b99cb9e3f7c247344507c0ea93fd8d27a5031f5ca0f5e19de2ef7e209b4e6c87d0e9ee12c54a96b42e
         | 
    
        data/btetris_kp.gemspec
    CHANGED
    
    | @@ -5,7 +5,7 @@ require 'btetris_kp/version' | |
| 5 5 |  | 
| 6 6 | 
             
            Gem::Specification.new do |spec|
         | 
| 7 7 | 
             
              spec.name          = "btetris_kp"
         | 
| 8 | 
            -
              spec.version       =  | 
| 8 | 
            +
              spec.version       = BTetrisKp::VERSION
         | 
| 9 9 | 
             
              spec.authors       = ["Pavel Kocka"]
         | 
| 10 10 | 
             
              spec.email         = ["kockapav@gmail.com"]
         | 
| 11 11 | 
             
              spec.description   = %q{Battle Tetris}
         | 
    
        data/lib/btetris_kp/constants.rb
    CHANGED
    
    | @@ -4,11 +4,18 @@ module BTetrisKp | |
| 4 4 | 
             
                # Game window Const
         | 
| 5 5 | 
             
                GAME_WIDTH = 800
         | 
| 6 6 | 
             
                GAME_HEIGHT = 600
         | 
| 7 | 
            +
                GAME_WIN_GAP = (GAME_WIDTH * 0.075).to_i
         | 
| 7 8 | 
             
                GAME_CAPTION = 'Battle tetris'
         | 
| 8 9 | 
             
                PAUSE_CAPTION = 'Paused!'
         | 
| 9 10 | 
             
                GAME_OVER_CAPTION = 'Game over!'
         | 
| 10 11 | 
             
                GAME_WON_CAPTION = 'You WIN!'
         | 
| 11 | 
            -
                GAME_LOST_CAPTION = 'You  | 
| 12 | 
            +
                GAME_LOST_CAPTION = 'You LOSE!'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                # Font constants
         | 
| 15 | 
            +
                FONT_GAP = 5
         | 
| 16 | 
            +
                FONT_SMALL_SIZE = (GAME_WIDTH * 0.035).to_i
         | 
| 17 | 
            +
                FONT_MED_SIZE = (GAME_WIDTH * 0.05).to_i
         | 
| 18 | 
            +
                FONT_BIG_SIZE = (GAME_WIDTH * 0.1).to_i
         | 
| 12 19 |  | 
| 13 20 | 
             
                # File paths
         | 
| 14 21 | 
             
                PATH = File.dirname(File.expand_path(__FILE__))
         | 
    
        data/lib/btetris_kp/game.rb
    CHANGED
    
    | @@ -10,7 +10,7 @@ module BTetrisKp | |
| 10 10 |  | 
| 11 11 | 
             
                def initialize(window, x, y)
         | 
| 12 12 | 
             
                  @window = window
         | 
| 13 | 
            -
                  @font = Gosu::Font.new(@window, Gosu.default_font_name,  | 
| 13 | 
            +
                  @font = Gosu::Font.new(@window, Gosu.default_font_name, Const::FONT_BIG_SIZE)
         | 
| 14 14 | 
             
                  @board = Board.new(@window, x, y)
         | 
| 15 15 | 
             
                  @paused, @game_over = false, false
         | 
| 16 16 | 
             
                  # press time, set 0 when left, right or down key is pressed
         | 
    
        data/lib/btetris_kp/menu.rb
    CHANGED
    
    | @@ -10,7 +10,7 @@ module BTetrisKp | |
| 10 10 | 
             
              class MenuState
         | 
| 11 11 | 
             
                def initialize(window)
         | 
| 12 12 | 
             
                  @window = window
         | 
| 13 | 
            -
                  @font = Gosu::Font.new(@window, Gosu.default_font_name,  | 
| 13 | 
            +
                  @font = Gosu::Font.new(@window, Gosu.default_font_name, Const::FONT_SMALL_SIZE)
         | 
| 14 14 | 
             
                  initialize_title_image
         | 
| 15 15 | 
             
                  generate_back_board
         | 
| 16 16 | 
             
                  generate_menu
         | 
| @@ -19,7 +19,7 @@ module BTetrisKp | |
| 19 19 | 
             
                # loads title image and calculates position, size variables
         | 
| 20 20 | 
             
                def initialize_title_image
         | 
| 21 21 | 
             
                  @title_image = Gosu::Image.new(@window, Const::PATH_IMAGE_TITLE, false)
         | 
| 22 | 
            -
                  @img_size_factor = (@window.width -  | 
| 22 | 
            +
                  @img_size_factor = (@window.width - Const::GAME_WIN_GAP).to_f / @title_image.width
         | 
| 23 23 | 
             
                  @img_x = (@window.width - @title_image.width * @img_size_factor) / 2
         | 
| 24 24 | 
             
                  @img_y = 20
         | 
| 25 25 | 
             
                end
         | 
| @@ -41,8 +41,8 @@ module BTetrisKp | |
| 41 41 | 
             
                # generates menu, menu items and callback procedures for menu items
         | 
| 42 42 | 
             
                def generate_menu
         | 
| 43 43 | 
             
                  @items = []
         | 
| 44 | 
            -
                  @x = @window.width / 3 +  | 
| 45 | 
            -
                  @y = @title_image.height
         | 
| 44 | 
            +
                  @x = @window.width / 3 + Const::FONT_SMALL_SIZE
         | 
| 45 | 
            +
                  @y = @title_image.height * @img_size_factor + Const::GAME_WIN_GAP
         | 
| 46 46 | 
             
                  n_g = proc { @window.state = GameState.new(@window, @window.width / 3, 40) }
         | 
| 47 47 | 
             
                  cr_n = proc { @window.state = NetSetupState.new(@window) }
         | 
| 48 48 | 
             
                  j_n = proc { @window.state = NetJoinState.new(@window) }
         | 
    
        data/lib/btetris_kp/netgame.rb
    CHANGED
    
    | @@ -10,7 +10,7 @@ module BTetrisKp | |
| 10 10 | 
             
                def initialize(window, socket)
         | 
| 11 11 | 
             
                  @window = window
         | 
| 12 12 | 
             
                  @socket = socket
         | 
| 13 | 
            -
                  @font = Gosu::Font.new(@window, Gosu.default_font_name,  | 
| 13 | 
            +
                  @font = Gosu::Font.new(@window, Gosu.default_font_name, Const::FONT_BIG_SIZE)
         | 
| 14 14 | 
             
                  @game = GameState.new(@window, 10, 40)
         | 
| 15 15 | 
             
                  @o_board = Board.new(@window, 2 * @window.width / 3 - 10, 40)
         | 
| 16 16 | 
             
                  @winner = 0
         | 
    
        data/lib/btetris_kp/netjoin.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ module BTetrisKp | |
| 8 8 | 
             
              class NetJoinState
         | 
| 9 9 | 
             
                def initialize(window)
         | 
| 10 10 | 
             
                  @window = window
         | 
| 11 | 
            -
                  @font = Gosu::Font.new(@window, Gosu.default_font_name,  | 
| 11 | 
            +
                  @font = Gosu::Font.new(@window, Gosu.default_font_name, Const::FONT_MED_SIZE)
         | 
| 12 12 | 
             
                  @connecting = false
         | 
| 13 13 | 
             
                  initialize_title_image
         | 
| 14 14 | 
             
                  initialize_textfields
         | 
| @@ -18,7 +18,7 @@ module BTetrisKp | |
| 18 18 | 
             
                # loads title image and calculates position, size variables
         | 
| 19 19 | 
             
                def initialize_title_image
         | 
| 20 20 | 
             
                  @title_image = Gosu::Image.new(@window, Const::PATH_IMAGE_TITLE, false)
         | 
| 21 | 
            -
                  @img_size_factor = (@window.width -  | 
| 21 | 
            +
                  @img_size_factor = (@window.width - Const::GAME_WIN_GAP).to_f / @title_image.width
         | 
| 22 22 | 
             
                  @img_x = (@window.width - @title_image.width * @img_size_factor) / 2
         | 
| 23 23 | 
             
                  @img_y = 20
         | 
| 24 24 | 
             
                end
         | 
| @@ -26,16 +26,16 @@ module BTetrisKp | |
| 26 26 | 
             
                # initializes text fields for reading ip and port
         | 
| 27 27 | 
             
                # initializes positions for texts and textfields
         | 
| 28 28 | 
             
                def initialize_textfields
         | 
| 29 | 
            -
                  @text_x = @window.width / 3 +  | 
| 29 | 
            +
                  @text_x = @window.width / 3 + 2 * Const::FONT_GAP
         | 
| 30 30 | 
             
                  @text_y = @window.height / 3
         | 
| 31 | 
            -
                  @ip_x = @text_x - @font.text_width(Const::IP_CAPTION) -  | 
| 32 | 
            -
                  @port_x = @text_x - @font.text_width(Const::PORT_CAPTION) -  | 
| 31 | 
            +
                  @ip_x = @text_x - @font.text_width(Const::IP_CAPTION) - 3 * Const::FONT_GAP
         | 
| 32 | 
            +
                  @port_x = @text_x - @font.text_width(Const::PORT_CAPTION) - 3 * Const::FONT_GAP
         | 
| 33 33 | 
             
                  @text_fields = []
         | 
| 34 34 | 
             
                  @text_fields << TextField.new(@window, @font, @text_x,
         | 
| 35 35 | 
             
                                                @text_y, Const::DEF_IP, /[^0-9.]/,
         | 
| 36 36 | 
             
                                                @font.text_width('000.000.000.000'), 15)
         | 
| 37 37 | 
             
                  @text_fields << TextField.new(@window, @font, @text_x,
         | 
| 38 | 
            -
                                                @text_y + @font.height +  | 
| 38 | 
            +
                                                @text_y + @font.height + 2 * Const::FONT_GAP,
         | 
| 39 39 | 
             
                                                Const::DEF_PORT, /[^0-9]/,
         | 
| 40 40 | 
             
                                                @font.text_width('00000'), 5)
         | 
| 41 41 | 
             
                end
         | 
| @@ -77,9 +77,9 @@ module BTetrisKp | |
| 77 77 | 
             
                  @font.draw(Const::IP_CAPTION, @ip_x,
         | 
| 78 78 | 
             
                             @text_y, 0)
         | 
| 79 79 | 
             
                  @font.draw(Const::PORT_CAPTION, @port_x,
         | 
| 80 | 
            -
                             @text_y + @font.height +  | 
| 80 | 
            +
                             @text_y + @font.height + 2 * Const::FONT_GAP, 0)
         | 
| 81 81 | 
             
                  @font.draw(Const::CONNECTING, @text_x,
         | 
| 82 | 
            -
                             @text_y + 3 * (@font.height +  | 
| 82 | 
            +
                             @text_y + 3 * (@font.height + 2 * Const::FONT_GAP), 0) if @connecting
         | 
| 83 83 | 
             
                  @title_image.draw(@img_x, @img_y, 1, @img_size_factor, @img_size_factor)
         | 
| 84 84 | 
             
                end
         | 
| 85 85 |  | 
    
        data/lib/btetris_kp/netsetup.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ module BTetrisKp | |
| 8 8 | 
             
              class NetSetupState
         | 
| 9 9 | 
             
                def initialize(window)
         | 
| 10 10 | 
             
                  @window = window
         | 
| 11 | 
            -
                  @font = Gosu::Font.new(@window, Gosu.default_font_name,  | 
| 11 | 
            +
                  @font = Gosu::Font.new(@window, Gosu.default_font_name, Const::FONT_MED_SIZE)
         | 
| 12 12 | 
             
                  initialize_title_image
         | 
| 13 13 | 
             
                  setup_server
         | 
| 14 14 | 
             
                  @connected = false
         | 
| @@ -28,7 +28,7 @@ module BTetrisKp | |
| 28 28 | 
             
                # loads title image and calculates position, size variables
         | 
| 29 29 | 
             
                def initialize_title_image
         | 
| 30 30 | 
             
                  @title_image = Gosu::Image.new(@window, Const::PATH_IMAGE_TITLE, false)
         | 
| 31 | 
            -
                  @img_size_factor = (@window.width -  | 
| 31 | 
            +
                  @img_size_factor = (@window.width - Const::GAME_WIN_GAP).to_f / @title_image.width
         | 
| 32 32 | 
             
                  @img_x = (@window.width - @title_image.width * @img_size_factor) / 2
         | 
| 33 33 | 
             
                  @img_y = 20
         | 
| 34 34 | 
             
                end
         | 
| @@ -60,7 +60,7 @@ module BTetrisKp | |
| 60 60 | 
             
                # draws net setup window
         | 
| 61 61 | 
             
                def draw
         | 
| 62 62 | 
             
                  @font.draw(Const::SERVER_WAIT, @window.width / 5,
         | 
| 63 | 
            -
                             @window.height / 2 -  | 
| 63 | 
            +
                             @window.height / 2 - Const::GAME_WIN_GAP, 0)
         | 
| 64 64 | 
             
                  @font.draw("#{Const::SERVER_PORT}#{@port}", @window.width / 3.5,
         | 
| 65 65 | 
             
                             @window.height / 2, 0)
         | 
| 66 66 | 
             
                  @title_image.draw(@img_x, @img_y, 1, @img_size_factor, @img_size_factor)
         | 
    
        data/lib/btetris_kp/version.rb
    CHANGED
    
    | @@ -1,3 +1,3 @@ | |
| 1 | 
            -
            module  | 
| 2 | 
            -
              VERSION = '0.0. | 
| 1 | 
            +
            module BTetrisKp
         | 
| 2 | 
            +
              VERSION = '0.0.2'
         | 
| 3 3 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: btetris_kp
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.0. | 
| 4 | 
            +
              version: 0.0.2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Pavel Kocka
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014-02- | 
| 11 | 
            +
            date: 2014-02-08 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |