starx 0.1.2 → 0.1.3
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/bin/starx +34 -51
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b2343a38acde7681f1c5eedc31111515a2274a5
|
4
|
+
data.tar.gz: 887129f3992db20f11c5e6158e61ff4a56bc8436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0db518483b50e22c0d74a16ef3ab7b1593a38ca6d273f7f25cdfb027a9b98cc299d99fe9380b480b9d28f21d37c2e087bf8f379805fb57da25fd6f083fabb9e
|
7
|
+
data.tar.gz: 22556d3ba2615f581f465eadf9ffba404af027222a09431b8788ab4b88b58ffc56311550d217044739674a79e1be7588acc1cb6e81466cb5746543c16406da04
|
data/bin/starx
CHANGED
@@ -38,13 +38,14 @@ class Starx
|
|
38
38
|
position_array = position.split('.')
|
39
39
|
y = position_array[0]
|
40
40
|
x = position_array[1]
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
case value
|
42
|
+
when :full
|
43
|
+
print '*'
|
44
|
+
when :empty
|
45
|
+
print " "
|
46
|
+
when :player
|
47
|
+
print "\e[31m>\e[0m"
|
48
|
+
end
|
48
49
|
end
|
49
50
|
WIDTH.times {print '*'}
|
50
51
|
|
@@ -129,58 +130,41 @@ class Starx
|
|
129
130
|
end
|
130
131
|
|
131
132
|
def move_up!
|
132
|
-
|
133
|
-
player_x = player_key[1]
|
134
|
-
player_y = player_key[0].to_i
|
135
|
-
|
136
|
-
cell_x = player_x
|
137
|
-
cell_y = player_y - 1
|
138
|
-
if cell_y < 10
|
139
|
-
cell_y = "0#{cell_y}"
|
140
|
-
else
|
141
|
-
cell_y.to_s
|
142
|
-
end
|
143
|
-
player_y = player_key[0]
|
144
|
-
|
145
|
-
player_new_key = "#{player_y}.#{player_x}"
|
146
|
-
cell_key = "#{cell_y}.#{cell_x}"
|
147
|
-
|
148
|
-
@cells.delete(player_new_key)
|
149
|
-
@cells.delete(cell_key)
|
150
|
-
|
151
|
-
@cells[player_new_key] = :empty
|
152
|
-
@cells[cell_key] = :player
|
133
|
+
switch_player_with(1,0)
|
153
134
|
end
|
154
135
|
|
155
136
|
def move_down!
|
156
|
-
|
157
|
-
|
158
|
-
player_y = player_key[0].to_i
|
159
|
-
|
160
|
-
cell_x = player_x
|
161
|
-
cell_y = player_y + 1
|
162
|
-
if cell_y < 10
|
163
|
-
cell_y = "0#{cell_y}"
|
164
|
-
else
|
165
|
-
cell_y.to_s
|
166
|
-
end
|
167
|
-
player_y = player_key[0]
|
137
|
+
switch_player_with(-1,0)
|
138
|
+
end
|
168
139
|
|
169
|
-
|
170
|
-
|
140
|
+
def switch_player_with(y,x)
|
141
|
+
player_x = find_player[1].to_i
|
142
|
+
player_y = find_player[0].to_i
|
143
|
+
cell_x = player_x - x
|
144
|
+
cell_y = player_y - y
|
171
145
|
|
172
|
-
|
173
|
-
|
146
|
+
player_x = "0#{player_x}" if player_x < 10
|
147
|
+
player_y = "0#{player_y}" if player_y < 10
|
148
|
+
cell_x = "0#{cell_x}" if cell_x < 10
|
149
|
+
cell_y = "0#{cell_y}" if cell_y < 10
|
174
150
|
|
175
|
-
|
176
|
-
|
177
|
-
|
151
|
+
cell_key = "#{cell_y}.#{cell_x}"
|
152
|
+
player_key = "#{player_y}.#{player_x}"
|
153
|
+
|
154
|
+
@cells.delete(cell_key)
|
155
|
+
@cells.delete(player_key)
|
156
|
+
@cells[player_key] = :empty
|
157
|
+
@cells[cell_key] = :player
|
158
|
+
end
|
159
|
+
|
160
|
+
def find_player
|
161
|
+
@cells.select {|_,v| v == :player}.keys[0].split('.')
|
162
|
+
end
|
178
163
|
|
179
164
|
def collision?
|
180
165
|
collision = false
|
181
|
-
|
182
|
-
|
183
|
-
player_y = player_position[0]
|
166
|
+
player_x = find_player[1].to_i
|
167
|
+
player_y = find_player[0]
|
184
168
|
cell_in_front_x = player_x + 1
|
185
169
|
cell_in_front_x = "0#{cell_in_front_x}" if cell_in_front_x < 10
|
186
170
|
cell_in_front = "#{player_y}.#{cell_in_front_x}"
|
@@ -284,7 +268,6 @@ class Starx
|
|
284
268
|
end
|
285
269
|
end
|
286
270
|
end
|
287
|
-
#
|
288
271
|
end
|
289
272
|
|
290
273
|
g = Starx.new
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: starx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justyna Rachowicz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: justynarachowicz@gmail.com
|
@@ -28,17 +28,17 @@ require_paths:
|
|
28
28
|
- lib
|
29
29
|
required_ruby_version: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
|
-
- -
|
36
|
+
- - '>='
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
40
|
rubyforge_project:
|
41
|
-
rubygems_version: 2.4.
|
41
|
+
rubygems_version: 2.4.6
|
42
42
|
signing_key:
|
43
43
|
specification_version: 4
|
44
44
|
summary: Simple, terminal-based game written in ruby
|