a_maze_ing 0.1.1 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6978ebabbd13e2b6f25e6b23ff29ee6dd44473a4
4
- data.tar.gz: bc73dc41ff26d5cbfdf8cf136b5443828a0a0bcf
3
+ metadata.gz: 8f499815c9f7632f0af92f21e7a3585953de04c2
4
+ data.tar.gz: 188e5eb04c736af94764263f3d4940f222dd5288
5
5
  SHA512:
6
- metadata.gz: 24b2b6a28f767b53ef6d5bbf955b6b32c6d875c119153ecb981ba0b4696bd0890dcb8672b39e0d8364fba1fd6c624d43af71b81d2245fad2dd95d4565e5d0eab
7
- data.tar.gz: cf502656f63fa27d6edcad888c4b38fa4e9b5a4ddb10dad014594b4c5167dcf52367c44e8eeaf9080db0102131927088d86fb5bcdf04108fe2c5179ae2ea3e14
6
+ metadata.gz: ba93e529fa680331c7b4760ac838901ac4584f5b6919cebdb091832fa8f48e17b4b827f9877196cbd84b5f69d124e3eb38a65fe7389f2d8771c35aec45c05e1b
7
+ data.tar.gz: 68be57d00463ab18ef685afe7e2e54a228dfacf6619e60c0e58da2f6c446cecefc3fc2f2fd6c230e1930184346ee5ad357c74110c80c1cd31245b2444db613e2
data/a_maze_ing.gemspec CHANGED
@@ -3,7 +3,6 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  require "a_maze_ing/version"
6
- require 'rubygems/dependency_installer.rb'
7
6
 
8
7
  Gem::Specification.new do |spec|
9
8
  spec.name = "a_maze_ing"
@@ -28,6 +27,7 @@ Gem::Specification.new do |spec|
28
27
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
29
28
  f.match(%r{^(test|spec|features)/})
30
29
  end
30
+ puts spec.files
31
31
  spec.executables = "a_maze_ing"
32
32
  # spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ["lib"]
@@ -0,0 +1,21 @@
1
+ module AMazeIng
2
+ class Infor
3
+ attr_accessor :level
4
+ def initialize
5
+ @level = 1
6
+ @label = 'LEVEL'
7
+
8
+ @label_image = Gosu::Image.from_text @label, 40
9
+ end
10
+
11
+ def center_x(width)
12
+ return $dimension + SIDE_BAR/2 - width/2
13
+ end
14
+
15
+ def draw
16
+ @level_image = Gosu::Image.from_text @level.to_s, 36
17
+ @label_image.draw(center_x(@label_image.width), 80, 1)
18
+ @level_image.draw(center_x(@level_image.width), 130, 1)
19
+ end
20
+ end
21
+ end
@@ -4,34 +4,33 @@ require 'gosu'
4
4
  include Gosu
5
5
 
6
6
  module AMazeIng
7
+ DIMENSION = 700
8
+ SIDE_BAR = 180
7
9
  class GameWindow < Window
8
- $dimension = 550
9
- $rows = $cols = 11
10
-
11
- until $dimension/$cols % 3 == 0
12
- $dimension -= 1
13
- end
14
-
15
- $cell_size = $dimension/$cols
16
- $speed_per_tick = $cell_size/3
17
- $player_size = 0.5 * $cell_size
18
-
19
- $cells = Array.new
20
-
10
+ $rows = $cols = 10
21
11
  def initialize
22
- super $dimension + 100, $dimension, false
12
+ super DIMENSION + SIDE_BAR, DIMENSION, false, 1
23
13
  self.caption = "Maze"
24
14
  generate_maze
15
+ @infor = Infor.new
25
16
  end
26
17
 
18
+ def check_dimension
19
+ until $dimension/$cols % 4 == 0
20
+ $dimension -= 1
21
+ end
22
+ end
23
+
27
24
  def generate_maze
25
+ $dimension = DIMENSION
26
+ check_dimension
27
+ $cell_size = $dimension/$cols
28
+ $speed_per_tick = $cell_size/4
29
+ $player_size = 0.5 * $cell_size
30
+
28
31
  $cells = Array.new
29
32
  @stack = Array.new
30
33
  @player = Player.new
31
- # @player.set_position(0,0)
32
-
33
- $cell_size = $dimension/$cols
34
- $player_size = 0.5 * $cell_size
35
34
 
36
35
  $rows.times do |row_index|
37
36
  $cols.times do |col_index|
@@ -94,21 +93,18 @@ module AMazeIng
94
93
 
95
94
  def check_for_finish
96
95
  if @player.cell_index_x == $cells[-1].cell_index_x && @player.cell_index_y == $cells[-1].cell_index_y
97
- puts 'finished'
98
- $rows += 3
99
- $cols += 3
96
+ $rows += 2
97
+ $cols += 2
100
98
  generate_maze
99
+ @infor.level += 1
101
100
  end
102
101
  end
103
102
 
104
-
105
-
106
103
  def update
107
-
104
+ check_for_finish
108
105
  end
109
106
 
110
107
  def draw
111
-
112
108
  $cells.each do |cell|
113
109
  if cell.visited
114
110
  cell.draw($cell_size, Color::BLUE)
@@ -118,24 +114,10 @@ module AMazeIng
118
114
  end
119
115
  @player.draw
120
116
  @player.move
117
+ @infor.draw
121
118
  draw_target($cells[-1])
122
119
  end
123
120
 
124
- # def check_for_path(ignore_path)
125
- # path = nil
126
- # $cells[@player.cell_index_x + @player.cell_index_y * $cols].walls.each_with_index do |wall, i|
127
- # if !wall and i != ignore_path
128
- # if path == nil
129
- # path = i
130
- # else
131
- # path = nil
132
- # break
133
- # end
134
- # end
135
- # end
136
- # return path
137
- # end
138
-
139
121
  def button_down(id)
140
122
  if id == Gosu::KB_LEFT
141
123
  if !$cells[@player.cell_index_x + @player.cell_index_y * $cols].walls[3]
@@ -144,8 +126,6 @@ module AMazeIng
144
126
  @player.cell_index_x -= 1
145
127
  @player.set_target
146
128
  @player.is_moving = true
147
- # @player.move_left
148
- # check_for_finish
149
129
  end
150
130
  end
151
131
 
@@ -156,8 +136,6 @@ module AMazeIng
156
136
  @player.cell_index_x += 1
157
137
  @player.set_target
158
138
  @player.is_moving = true
159
- # @player.move_right
160
- # check_for_finish
161
139
  end
162
140
  end
163
141
 
@@ -168,8 +146,6 @@ module AMazeIng
168
146
  @player.cell_index_y -= 1
169
147
  @player.set_target
170
148
  @player.is_moving = true
171
- # @player.move_up
172
- # check_for_finish
173
149
  end
174
150
  end
175
151
 
@@ -180,8 +156,6 @@ module AMazeIng
180
156
  @player.cell_index_y += 1
181
157
  @player.set_target
182
158
  @player.is_moving = true
183
- # @player.move_down
184
- # check_for_finish
185
159
  end
186
160
  end
187
161
 
@@ -1,3 +1,3 @@
1
1
  module AMazeIng
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
data/lib/a_maze_ing.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "a_maze_ing/version"
2
2
  require "a_maze_ing/cell"
3
3
  require "a_maze_ing/player"
4
+ require "a_maze_ing/infor"
4
5
  require "a_maze_ing/maze"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: a_maze_ing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gt-cuongtran
@@ -86,6 +86,7 @@ files:
86
86
  - bin/setup
87
87
  - lib/a_maze_ing.rb
88
88
  - lib/a_maze_ing/cell.rb
89
+ - lib/a_maze_ing/infor.rb
89
90
  - lib/a_maze_ing/maze.rb
90
91
  - lib/a_maze_ing/player.rb
91
92
  - lib/a_maze_ing/version.rb