rtanque 0.1.3 → 0.1.4
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/.ruby-version +1 -1
- data/README.md +1 -1
- data/lib/rtanque/gui/bot/health_color_calculator.rb +15 -12
- data/lib/rtanque/gui/bot.rb +4 -8
- data/lib/rtanque/version.rb +1 -1
- data/resources/images/bar.png +0 -0
- data/rtanque.gemspec +5 -5
- metadata +13 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9c2fceb359226e5765e885345e46744173258946f92116640db15d1ca6bb863
|
4
|
+
data.tar.gz: b59da92bcd466e6d5e87ffeb18e70e67bff99b430c1384070e8d646be12590f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5e78583c53a6db4606974550e34f7947bd48bbc3e42c0679954e1089fc55c8206e1aa4a129cc48317196d8f272f08a077b01269db19d1d8212616b25d4284e6
|
7
|
+
data.tar.gz: 3299bea6a7f9f788ed94ea05968e7e76728d069dc7dd7b3001caf25779433de7148ac223e2a537805a3662ca3c8297a0eb52bffce20e5193f69ed4f5ebd3e736
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.4.5
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
**What is this?**
|
4
4
|
RTanque is a game for ( *Ruby* ) programmers. Players program the brain of a tank and then send their tank+brain into battle with other tanks. All tanks are otherwise equal.
|
5
5
|
|
6
|
-
[Getting started guide](
|
6
|
+
[Getting started guide](https://awilliams.github.io/posts/rtanque-getting-started/)
|
7
7
|
|
8
8
|
Rules of the game are simple: Last bot standing wins. Gameplay is also pretty simple. Each tank has a **base**, **turret** and **radar**, each of which rotate independently. The base moves the tank, the turret has a gun mounted to it which can fire at other tanks, and the radar detects other tanks in its field of vision.
|
9
9
|
|
@@ -3,10 +3,11 @@ module RTanque
|
|
3
3
|
class Bot
|
4
4
|
class HealthColorCalculator
|
5
5
|
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# Different health-colors as RGB values
|
7
|
+
# Blue, Green,Red, Alpha
|
8
|
+
FULL_HEALTH_COLOR = [0x4A, 0xBE, 0x4A, 0xFF].freeze
|
9
|
+
MEDIUM_HEALTH_COLOR = [0x00, 0xBE, 0xFF, 0xFF].freeze
|
10
|
+
LOW_HEALTH_COLOR = [0x00, 0x00, 0xDC, 0xFF].freeze
|
10
11
|
|
11
12
|
attr_reader :health
|
12
13
|
|
@@ -14,22 +15,24 @@ module RTanque
|
|
14
15
|
@health = health
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
+
def color
|
18
19
|
if health > 50
|
19
20
|
percentage = ((100 - health) / 50)
|
20
|
-
color_between
|
21
|
+
color_between(FULL_HEALTH_COLOR, MEDIUM_HEALTH_COLOR, percentage)
|
21
22
|
else
|
22
23
|
percentage = ((50 - health) / 50)
|
23
|
-
color_between
|
24
|
+
color_between(MEDIUM_HEALTH_COLOR, LOW_HEALTH_COLOR, percentage)
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
private
|
29
|
+
|
27
30
|
def color_between(color_a, color_b, percentage)
|
28
|
-
[
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
4.times.map { |i| graduated(color_a[i], color_b[i], percentage) << (8 * i) }.sum
|
32
|
+
end
|
33
|
+
|
34
|
+
def graduated(min, max, percentage)
|
35
|
+
((max - min) * percentage + min).round
|
33
36
|
end
|
34
37
|
end
|
35
38
|
end
|
data/lib/rtanque/gui/bot.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'gosu'
|
2
|
-
require 'texplay'
|
3
2
|
|
4
3
|
require 'rtanque/gui/bot/health_color_calculator'
|
5
4
|
|
@@ -17,8 +16,8 @@ module RTanque
|
|
17
16
|
@body_image = Gosu::Image.new(@window, Gui.resource_path("images/body.png"))
|
18
17
|
@turret_image = Gosu::Image.new(@window, Gui.resource_path("images/turret.png"))
|
19
18
|
@radar_image = Gosu::Image.new(@window, Gui.resource_path("images/radar.png"))
|
20
|
-
@score_bar_image = TexPlay.create_blank_image(@window, HEALTH_BAR_WIDTH, HEALTH_BAR_HEIGHT)
|
21
19
|
@name_font = Gosu::Font.new(@window, Window::FONT_NAME, Window::SMALL_FONT_SIZE)
|
20
|
+
@health_bar_image = ::Gosu::Image.new(Gui.resource_path('images/bar.png'))
|
22
21
|
@x_factor = 1
|
23
22
|
@y_factor = 1
|
24
23
|
end
|
@@ -50,17 +49,14 @@ module RTanque
|
|
50
49
|
x,y = *position
|
51
50
|
x_health = health.round(0)
|
52
51
|
health_color = color_for_health
|
53
|
-
@
|
54
|
-
|
55
|
-
rect 0, 0, x_health, HEALTH_BAR_HEIGHT, :color => health_color, :fill => true
|
56
|
-
}
|
57
|
-
@score_bar_image.draw(x - (HEALTH_BAR_WIDTH/2) * @x_factor, y + (5 + RTanque::Bot::RADIUS) * @y_factor, ZOrder::BOT_HEALTH, @x_factor, @y_factor)
|
52
|
+
@health_bar_image.draw(x - ((HEALTH_BAR_WIDTH / 2) * @x_factor), y + ((5 + RTanque::Bot::RADIUS) * @y_factor),
|
53
|
+
ZOrder::BOT_HEALTH, x_health / 200.0, 0.5, health_color)
|
58
54
|
end
|
59
55
|
|
60
56
|
private
|
61
57
|
|
62
58
|
def color_for_health
|
63
|
-
HealthColorCalculator.new(health).
|
59
|
+
HealthColorCalculator.new(health).color
|
64
60
|
end
|
65
61
|
|
66
62
|
def health
|
data/lib/rtanque/version.rb
CHANGED
Binary file
|
data/rtanque.gemspec
CHANGED
@@ -16,18 +16,18 @@ Rules of the game are simple: Last bot standing wins. Gameplay is also pretty si
|
|
16
16
|
Have fun competing against friends' tanks or the sample ones included. Maybe you'll start a small league at your local Ruby meetup.}
|
17
17
|
gem.homepage = "https://github.com/awilliams/RTanque"
|
18
18
|
gem.license = 'MIT'
|
19
|
+
gem.required_ruby_version = '>= 3.4'
|
19
20
|
|
20
21
|
gem.files = `git ls-files`.split($/)
|
21
22
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
22
23
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
23
24
|
gem.require_paths = ["lib"]
|
24
25
|
|
25
|
-
gem.add_dependency 'gosu', '~>
|
26
|
+
gem.add_dependency 'gosu', '~> 1.4.6'
|
26
27
|
gem.add_dependency 'configuration', '~> 1.3.4'
|
27
|
-
gem.add_dependency 'octokit', '~>
|
28
|
-
gem.add_dependency 'thor', '~>
|
29
|
-
gem.add_dependency 'texplay', '>= 0.4.4pre'
|
28
|
+
gem.add_dependency 'octokit', '~> 10.0.0'
|
29
|
+
gem.add_dependency 'thor', '~> 1.4.0'
|
30
30
|
|
31
31
|
gem.add_development_dependency 'pry'
|
32
|
-
gem.add_development_dependency 'rspec', '~> 3.
|
32
|
+
gem.add_development_dependency 'rspec', '~> 3.13.1'
|
33
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rtanque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Williams
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: gosu
|
@@ -16,14 +15,14 @@ dependencies:
|
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
18
|
+
version: 1.4.6
|
20
19
|
type: :runtime
|
21
20
|
prerelease: false
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
23
22
|
requirements:
|
24
23
|
- - "~>"
|
25
24
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
25
|
+
version: 1.4.6
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: configuration
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,42 +43,28 @@ dependencies:
|
|
44
43
|
requirements:
|
45
44
|
- - "~>"
|
46
45
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
46
|
+
version: 10.0.0
|
48
47
|
type: :runtime
|
49
48
|
prerelease: false
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
51
50
|
requirements:
|
52
51
|
- - "~>"
|
53
52
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
53
|
+
version: 10.0.0
|
55
54
|
- !ruby/object:Gem::Dependency
|
56
55
|
name: thor
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
58
57
|
requirements:
|
59
58
|
- - "~>"
|
60
59
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
60
|
+
version: 1.4.0
|
62
61
|
type: :runtime
|
63
62
|
prerelease: false
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
65
64
|
requirements:
|
66
65
|
- - "~>"
|
67
66
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: texplay
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 0.4.4pre
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 0.4.4pre
|
67
|
+
version: 1.4.0
|
83
68
|
- !ruby/object:Gem::Dependency
|
84
69
|
name: pry
|
85
70
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +85,14 @@ dependencies:
|
|
100
85
|
requirements:
|
101
86
|
- - "~>"
|
102
87
|
- !ruby/object:Gem::Version
|
103
|
-
version: 3.
|
88
|
+
version: 3.13.1
|
104
89
|
type: :development
|
105
90
|
prerelease: false
|
106
91
|
version_requirements: !ruby/object:Gem::Requirement
|
107
92
|
requirements:
|
108
93
|
- - "~>"
|
109
94
|
- !ruby/object:Gem::Version
|
110
|
-
version: 3.
|
95
|
+
version: 3.13.1
|
111
96
|
description: |-
|
112
97
|
RTanque is a game for programmers. Players program the brain of a tank and then send their tank+brain into battle with other tanks. All tanks are otherwise equal.
|
113
98
|
|
@@ -160,6 +145,7 @@ files:
|
|
160
145
|
- lib/rtanque/runner.rb
|
161
146
|
- lib/rtanque/shell.rb
|
162
147
|
- lib/rtanque/version.rb
|
148
|
+
- resources/images/bar.png
|
163
149
|
- resources/images/body.png
|
164
150
|
- resources/images/bullet.png
|
165
151
|
- resources/images/explosions/explosion2-1.png
|
@@ -256,7 +242,6 @@ homepage: https://github.com/awilliams/RTanque
|
|
256
242
|
licenses:
|
257
243
|
- MIT
|
258
244
|
metadata: {}
|
259
|
-
post_install_message:
|
260
245
|
rdoc_options: []
|
261
246
|
require_paths:
|
262
247
|
- lib
|
@@ -264,16 +249,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
264
249
|
requirements:
|
265
250
|
- - ">="
|
266
251
|
- !ruby/object:Gem::Version
|
267
|
-
version: '
|
252
|
+
version: '3.4'
|
268
253
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
269
254
|
requirements:
|
270
255
|
- - ">="
|
271
256
|
- !ruby/object:Gem::Version
|
272
257
|
version: '0'
|
273
258
|
requirements: []
|
274
|
-
|
275
|
-
rubygems_version: 2.7.3
|
276
|
-
signing_key:
|
259
|
+
rubygems_version: 3.6.9
|
277
260
|
specification_version: 4
|
278
261
|
summary: RTanque is a game for programmers. Players program the brain of a tank and
|
279
262
|
then send their tank into battle against other tanks.
|