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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 425a26d38d0419d50ff8cb0126faaa1caaf6d1e0
4
- data.tar.gz: f8f2deaa630c4a9bd247656156d7869aa2725142
3
+ metadata.gz: 0a70f6dc0867aa97326b8806f33db6826e0bc70a
4
+ data.tar.gz: 371d203951eb610f14f66e0b2baaf24bb9a939fb
5
5
  SHA512:
6
- metadata.gz: ae3785d6fd1403caefa5074b9e10fde7da908ad09338bcdce001e32de21c5e464aa8cd5062d977573c109afa4b386457345286bbd5a222dd1bf6da8b099c1f57
7
- data.tar.gz: e0eb2eda6ba106b60420ce7ea59a58c0c89f9af787fe8212660c98fa87514bdd912f1f7590bfd3e7b1b4169d5ba92a389dbb3af94aaf9197077e6df20263142d
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 = BtetrisKp::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}
@@ -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 LOOSE!'
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__))
@@ -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, 80)
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
@@ -10,7 +10,7 @@ module BTetrisKp
10
10
  @font = font
11
11
  @color = Const::MENU_ITEM_CLR
12
12
  @x = x
13
- @y = y + id * (@font.height + 5)
13
+ @y = y + id * (@font.height + Const::FONT_GAP)
14
14
  end
15
15
 
16
16
  # updates menu item, changes item color depending on mouse_over?
@@ -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, 30)
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 - 50.0) / @title_image.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 + 30
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) }
@@ -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, 80)
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
@@ -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, 40)
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 - 50.0) / @title_image.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 + 10
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) - 15
32
- @port_x = @text_x - @font.text_width(Const::PORT_CAPTION) - 15
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 + 10,
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 + 10, 0)
80
+ @text_y + @font.height + 2 * Const::FONT_GAP, 0)
81
81
  @font.draw(Const::CONNECTING, @text_x,
82
- @text_y + 3 * (@font.height + 10), 0) if @connecting
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
 
@@ -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, 40)
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 - 50.0) / @title_image.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 - 60, 0)
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)
@@ -1,3 +1,3 @@
1
- module BtetrisKp
2
- VERSION = '0.0.1'
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.1
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-05 00:00:00.000000000 Z
11
+ date: 2014-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler