rubygoal 0.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +18 -0
- data/README.md +51 -28
- data/bin/rubygoal +2 -2
- data/lib/rubygoal/gui/ball.rb +26 -0
- data/lib/rubygoal/gui/field.rb +21 -0
- data/lib/rubygoal/gui/game.rb +166 -0
- data/lib/rubygoal/gui/goal.rb +23 -0
- data/lib/rubygoal/gui/players.rb +28 -0
- data/lib/rubygoal/gui/version.rb +5 -0
- data/lib/rubygoal/gui.rb +20 -0
- data/lib/rubygoal.rb +14 -3
- data/media/background.png +0 -0
- data/media/goal.png +0 -0
- metadata +28 -51
- data/MIT-LICENSE +0 -24
- data/lib/rubygoal/ball.rb +0 -41
- data/lib/rubygoal/coach.rb +0 -11
- data/lib/rubygoal/coach_loader.rb +0 -32
- data/lib/rubygoal/coaches/coach_away.rb +0 -52
- data/lib/rubygoal/coaches/coach_home.rb +0 -28
- data/lib/rubygoal/coaches/template.rb +0 -198
- data/lib/rubygoal/config.rb +0 -64
- data/lib/rubygoal/config_definitions.rb +0 -77
- data/lib/rubygoal/coordinate.rb +0 -25
- data/lib/rubygoal/field.rb +0 -84
- data/lib/rubygoal/field_metrics.rb +0 -85
- data/lib/rubygoal/formation.rb +0 -69
- data/lib/rubygoal/game.rb +0 -179
- data/lib/rubygoal/goal.rb +0 -43
- data/lib/rubygoal/match.rb +0 -52
- data/lib/rubygoal/moveable.rb +0 -55
- data/lib/rubygoal/player.rb +0 -86
- data/lib/rubygoal/players/average.rb +0 -20
- data/lib/rubygoal/players/captain.rb +0 -20
- data/lib/rubygoal/players/fast.rb +0 -20
- data/lib/rubygoal/team.rb +0 -217
- data/lib/rubygoal/version.rb +0 -3
- data/test/formation_test.rb +0 -66
- data/test/random.txt +0 -788
- data/test/record.txt +0 -432000
- data/test/test.rb +0 -104
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a9f36e4a9184d9837b4834ab1449995676e02ca
|
4
|
+
data.tar.gz: 6c5e76bef10ba32174430b6ffd68e175eebdb463
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 256936663d874aeb3a2c9a690af37da3bc43811c98442d3f73b2321ccc9eb9ea52d3f4466b5964e6d84fa15f5c5398399fe4e8fc47053db2c58a7fd5e87538a9
|
7
|
+
data.tar.gz: 135a5704aea61868d8286e619821a56db2e7c923ead040dd1c97d2aa0d5b73b9e2f9067897df4f624e74e4e9ff19d095d71f6b06301bc7201e6fa31921bb86d4
|
data/LICENSE
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Copyright 2014 Jorge Bejar
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
14
|
+
|
15
|
+
-----
|
16
|
+
|
17
|
+
This does not apply to files under the "media/" folder. For licensing of
|
18
|
+
those files refer to the Legal section in the README.md file.
|
data/README.md
CHANGED
@@ -1,62 +1,85 @@
|
|
1
|
-
|
1
|
+
[![Build Status](https://travis-ci.org/wyeworks/rubygoal.png)](https://travis-ci.org/wyeworks/rubygoal)
|
2
|
+
[![Code Climate](https://codeclimate.com/github/wyeworks/rubygoal.png)](https://codeclimate.com/github/wyeworks/rubygoal)
|
3
|
+
[![Inline docs](http://inch-ci.org/github/wyeworks/rubygoal.png?branch=master)](http://inch-ci.org/github/wyeworks/rubygoal)
|
2
4
|
|
3
|
-
|
5
|
+
#Welcome to RubyGoal!
|
4
6
|
|
5
|
-
|
6
|
-
fútbol.
|
7
|
+
## What is RubyGoal?
|
7
8
|
|
8
|
-
|
9
|
+
RubyGoal is a game in which you will be coaching your football team.
|
9
10
|
|
10
|
-
|
11
|
+
You will be coding your strategy in RUBY :D .
|
11
12
|
|
12
|
-
|
13
|
+
## Dependencies
|
14
|
+
|
15
|
+
GNU/Linux, Make sure you have all dependencies installed.
|
13
16
|
|
14
17
|
Ubuntu/Debian:
|
15
18
|
|
16
19
|
```bash
|
17
20
|
# Gosu's dependencies for both C++ and Ruby
|
18
|
-
sudo apt-get install build-essential
|
19
|
-
|
20
|
-
|
21
|
+
sudo apt-get install build-essential libsdl2-dev libsdl2-ttf-dev
|
22
|
+
libpango1.0-dev \
|
23
|
+
libgl1-mesa-dev libfreeimage-dev libopenal-dev
|
24
|
+
libsndfile-dev
|
21
25
|
```
|
22
26
|
|
23
|
-
|
27
|
+
For other distros: https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux
|
24
28
|
|
25
|
-
##
|
29
|
+
## How do i run it?
|
26
30
|
|
27
31
|
```bash
|
28
32
|
gem install rubygoal
|
29
33
|
```
|
30
34
|
|
31
|
-
|
35
|
+
Run the game with example `CoachDefinition`
|
32
36
|
```bash
|
33
37
|
rubygoal
|
34
38
|
```
|
35
39
|
|
36
|
-
|
40
|
+
Run the game with your custom `CoachDefinition` implementation
|
37
41
|
```bash
|
38
42
|
rubygoal coach_1.rb
|
39
43
|
```
|
40
44
|
|
41
|
-
|
45
|
+
Run the game with your home and away `CoachDefinition` implementations
|
42
46
|
```bash
|
43
47
|
rubygoal coach_1.rb coach_2.rb
|
44
48
|
```
|
45
49
|
|
46
|
-
|
50
|
+
If you want to run the game from the source code, clone the project and
|
51
|
+
run the following commands:
|
47
52
|
|
48
|
-
|
49
|
-
|
53
|
+
```bash
|
54
|
+
BUNDLE_GEMFILE=Gemfile.dev bundle install
|
55
|
+
BUNDLE_GEMFILE=Gemfile.dev bundle exec ruby gui/bin/rubygoal [coach_file] [coach_file]
|
56
|
+
```
|
50
57
|
|
51
|
-
|
58
|
+
Also, you can simulate a game without the GUI by running
|
59
|
+
|
60
|
+
```bash
|
61
|
+
bundle install
|
62
|
+
bundle exec ruby bin/rubygoal [coach_file] [coach_file]
|
63
|
+
```
|
52
64
|
|
53
|
-
|
54
|
-
|
55
|
-
|
65
|
+
When you simuate a game, a JSON file is created in the same folder. You
|
66
|
+
could run this using our experiment webcomponent to play Rubygoal in the
|
67
|
+
web: https://github.com/jmbejar/rubygoal-webplayer
|
68
|
+
|
69
|
+
## How do i write my own coach class?
|
70
|
+
|
71
|
+
You can find a complete guide explaining how to program a coach in
|
72
|
+
www.rubygoal.com
|
73
|
+
|
74
|
+
Aditionally, you can take a look to the already defined `CoachDefinition` at
|
75
|
+
`lib/rubygoal/coach_definition`.
|
76
|
+
Specially pay attention to the example coaches in `lib/rubygoal/coaches/`
|
77
|
+
|
78
|
+
|
79
|
+
## Legal
|
80
|
+
All source code, except the files under the `media/` folder, is
|
81
|
+
licensed under the Apache License 2.0. Please see the `LICENSE` file under
|
82
|
+
the gem root folder.
|
56
83
|
|
57
|
-
|
58
|
-
|
59
|
-
encuentra licenciada bajo los términos de la licencia CC-BY-SA 3.0
|
60
|
-
(https://creativecommons.org/licenses/by-sa/3.0/deed.es). Como
|
61
|
-
consecuencia, el archivo `media/goal.png` queda licenciado también bajo
|
62
|
-
esta licencia como trabajo derivado.
|
84
|
+
All media files under the `media/` folder are licensed under the Creative
|
85
|
+
Commons 4.0 Attribution license. Please see https://creativecommons.org/licenses/by/4.0/
|
data/bin/rubygoal
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'gosu'
|
2
|
+
|
3
|
+
module Rubygoal::Gui
|
4
|
+
class Ball
|
5
|
+
IMAGE_SIZE = 20
|
6
|
+
|
7
|
+
def initialize(window, ball)
|
8
|
+
@ball = ball
|
9
|
+
|
10
|
+
image_path = File.dirname(__FILE__) + '/../../../media/ball.png'
|
11
|
+
@image = Gosu::Image.new(window, image_path, false)
|
12
|
+
end
|
13
|
+
|
14
|
+
def draw
|
15
|
+
half_side_lenght = IMAGE_SIZE / 2
|
16
|
+
image_center_x = ball.position.x - half_side_lenght
|
17
|
+
image_center_y = ball.position.y - half_side_lenght
|
18
|
+
|
19
|
+
image.draw(image_center_x, image_center_y, 1)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
attr_reader :ball, :image
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'gosu'
|
2
|
+
|
3
|
+
require 'rubygoal/gui/ball'
|
4
|
+
require 'rubygoal/gui/players'
|
5
|
+
|
6
|
+
module Rubygoal::Gui
|
7
|
+
class Field
|
8
|
+
def initialize(window)
|
9
|
+
image_path = File.dirname(__FILE__) + '/../../../media/background.png'
|
10
|
+
@background_image = Gosu::Image.new(window, image_path, true)
|
11
|
+
end
|
12
|
+
|
13
|
+
def draw
|
14
|
+
background_image.draw(0, 0, 0);
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :background_image
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'gosu'
|
2
|
+
|
3
|
+
require 'rubygoal/gui/goal'
|
4
|
+
require 'rubygoal/gui/field'
|
5
|
+
require 'rubygoal/gui/ball'
|
6
|
+
require 'rubygoal/gui/players'
|
7
|
+
|
8
|
+
require 'rubygoal/coordinate'
|
9
|
+
require 'rubygoal/game'
|
10
|
+
|
11
|
+
module Rubygoal::Gui
|
12
|
+
class Game < Gosu::Window
|
13
|
+
WINDOW_WIDTH = 1920
|
14
|
+
WINDOW_HEIGHT = 1080
|
15
|
+
|
16
|
+
TIME_LABEL_POSITION = Rubygoal::Position.new(870, 68)
|
17
|
+
SCORE_HOME_LABEL_POSITION = Rubygoal::Position.new(1150, 68)
|
18
|
+
SCORE_AWAY_LABEL_POSITION = Rubygoal::Position.new(1220, 68)
|
19
|
+
|
20
|
+
TEAM_NAME_HOME_LABEL_POSITION = Rubygoal::Position.new(105, 580)
|
21
|
+
TEAM_NAME_AWAY_LABEL_POSITION = Rubygoal::Position.new(1815, 580)
|
22
|
+
|
23
|
+
DEFAULT_FONT_SIZE = 48
|
24
|
+
|
25
|
+
LABEL_IMAGE_FONT_SIZE = 64
|
26
|
+
LABEL_IMAGE_WIDTH = 669
|
27
|
+
|
28
|
+
def initialize(game)
|
29
|
+
super(WINDOW_WIDTH, WINDOW_HEIGHT, false)
|
30
|
+
self.caption = "Ruby Goal"
|
31
|
+
|
32
|
+
@game = game
|
33
|
+
|
34
|
+
@gui_field = Field.new(self)
|
35
|
+
@gui_goal = Goal.new(self)
|
36
|
+
@gui_ball = Ball.new(self, game.ball)
|
37
|
+
@gui_players = players.map { |p| Players.new(self, p) }
|
38
|
+
|
39
|
+
@font = Gosu::Font.new(
|
40
|
+
self,
|
41
|
+
Gosu.default_font_name,
|
42
|
+
DEFAULT_FONT_SIZE
|
43
|
+
)
|
44
|
+
|
45
|
+
@home_team_label = create_label_image(game.coach_home.name)
|
46
|
+
@away_team_label = create_label_image(game.coach_away.name)
|
47
|
+
end
|
48
|
+
|
49
|
+
def update
|
50
|
+
game.update
|
51
|
+
end
|
52
|
+
|
53
|
+
def draw
|
54
|
+
gui_field.draw
|
55
|
+
gui_ball.draw
|
56
|
+
gui_players.each(&:draw)
|
57
|
+
|
58
|
+
draw_scoreboard
|
59
|
+
draw_team_labels
|
60
|
+
gui_goal.draw if game.celebrating_goal?
|
61
|
+
end
|
62
|
+
|
63
|
+
def button_down(id)
|
64
|
+
if id == Gosu::KbEscape
|
65
|
+
close
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def players
|
72
|
+
game.players
|
73
|
+
end
|
74
|
+
|
75
|
+
def create_label_image(name)
|
76
|
+
name_characters_limit = 20
|
77
|
+
name = truncate_label(name, name_characters_limit)
|
78
|
+
|
79
|
+
font_name = Gosu.default_font_name
|
80
|
+
font_size = LABEL_IMAGE_FONT_SIZE
|
81
|
+
line_spacing = 1
|
82
|
+
label_width = LABEL_IMAGE_WIDTH
|
83
|
+
alignment = :center
|
84
|
+
|
85
|
+
Gosu::Image.from_text(
|
86
|
+
self,
|
87
|
+
name,
|
88
|
+
font_name,
|
89
|
+
font_size,
|
90
|
+
line_spacing,
|
91
|
+
label_width,
|
92
|
+
alignment
|
93
|
+
)
|
94
|
+
end
|
95
|
+
|
96
|
+
def truncate_label(name, limit)
|
97
|
+
words = name.split
|
98
|
+
|
99
|
+
left = limit
|
100
|
+
truncated = []
|
101
|
+
words.each do |word|
|
102
|
+
break unless left > 0
|
103
|
+
|
104
|
+
truncated << word
|
105
|
+
left -= word.length + 1
|
106
|
+
end
|
107
|
+
|
108
|
+
truncated.join(' ')
|
109
|
+
end
|
110
|
+
|
111
|
+
def draw_scoreboard
|
112
|
+
draw_text(time_text, TIME_LABEL_POSITION, :gray)
|
113
|
+
draw_text(game.score_home.to_s, SCORE_HOME_LABEL_POSITION, :white)
|
114
|
+
draw_text(game.score_away.to_s, SCORE_AWAY_LABEL_POSITION, :white)
|
115
|
+
end
|
116
|
+
|
117
|
+
def draw_team_labels
|
118
|
+
draw_vertical_text(home_team_label, TEAM_NAME_HOME_LABEL_POSITION, :down)
|
119
|
+
draw_vertical_text(away_team_label, TEAM_NAME_AWAY_LABEL_POSITION, :up)
|
120
|
+
end
|
121
|
+
|
122
|
+
def draw_text(text, position, color, scale = 1)
|
123
|
+
horizontal_alignment = 0.5
|
124
|
+
vertical_alignment = 0.5
|
125
|
+
z_order = 1
|
126
|
+
horizontal_scale = scale
|
127
|
+
vertical_scale = scale
|
128
|
+
|
129
|
+
font.draw_rel(
|
130
|
+
text,
|
131
|
+
position.x,
|
132
|
+
position.y,
|
133
|
+
horizontal_alignment,
|
134
|
+
vertical_alignment,
|
135
|
+
z_order,
|
136
|
+
horizontal_scale,
|
137
|
+
vertical_scale,
|
138
|
+
color_to_hex(color)
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
def draw_vertical_text(label, position, direction = :down)
|
143
|
+
angle = direction == :down ? -90 : 90
|
144
|
+
label.draw_rot(position.x, position.y, 1, angle)
|
145
|
+
end
|
146
|
+
|
147
|
+
def time_text
|
148
|
+
minutes = Integer(game.time) / 60
|
149
|
+
seconds = Integer(game.time) % 60
|
150
|
+
"%d:%02d" % [minutes, seconds]
|
151
|
+
end
|
152
|
+
|
153
|
+
def color_to_hex(color)
|
154
|
+
case color
|
155
|
+
when :white
|
156
|
+
0xffffffff
|
157
|
+
when :gray
|
158
|
+
0xff6d6e70
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
attr_reader :game, :gui_field, :gui_goal,
|
163
|
+
:gui_ball, :gui_players,
|
164
|
+
:font, :home_team_label, :away_team_label
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'gosu'
|
2
|
+
|
3
|
+
require 'rubygoal/coordinate'
|
4
|
+
|
5
|
+
module Rubygoal::Gui
|
6
|
+
class Goal
|
7
|
+
CELEBRATION_IMAGE_POSITION = Rubygoal::Position.new(680, 466)
|
8
|
+
|
9
|
+
def initialize(window)
|
10
|
+
image_path = File.dirname(__FILE__) + '/../../../media/goal.png'
|
11
|
+
@image = Gosu::Image.new(window, image_path, true)
|
12
|
+
end
|
13
|
+
|
14
|
+
def draw
|
15
|
+
position = CELEBRATION_IMAGE_POSITION
|
16
|
+
image.draw(position.x, position.y, 1)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_reader :image
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'gosu'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
require 'rubygoal/util'
|
5
|
+
|
6
|
+
module Rubygoal::Gui
|
7
|
+
class Players
|
8
|
+
extend Forwardable
|
9
|
+
def_delegators :player, :type, :side, :position, :destination, :rotation, :moving?
|
10
|
+
|
11
|
+
def initialize(window, player)
|
12
|
+
@player = player
|
13
|
+
@image = Gosu::Image.new(window, image_filename, false)
|
14
|
+
end
|
15
|
+
|
16
|
+
def draw
|
17
|
+
image.draw_rot(position.x, position.y, 1, rotation - 180)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def image_filename
|
23
|
+
File.dirname(__FILE__) + "/../../../media/#{type}_#{side}.png"
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_reader :player, :image
|
27
|
+
end
|
28
|
+
end
|
data/lib/rubygoal/gui.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygoal'
|
2
|
+
require 'rubygoal/gui/game'
|
3
|
+
|
4
|
+
module Rubygoal
|
5
|
+
module Gui
|
6
|
+
class << self
|
7
|
+
def start
|
8
|
+
game = Rubygoal::Game.new(load_coach(:home), load_coach(:away))
|
9
|
+
gui = Game.new(game)
|
10
|
+
gui.show
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def load_coach(side)
|
16
|
+
CoachLoader.new(side).coach
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/rubygoal.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
|
-
require 'rubygoal
|
1
|
+
require 'rubygoal-core'
|
2
|
+
require 'rubygoal/gui/game'
|
2
3
|
|
3
4
|
module Rubygoal
|
4
|
-
|
5
|
-
|
5
|
+
class << self
|
6
|
+
def start
|
7
|
+
game = Game.new(load_coach(:home), load_coach(:away))
|
8
|
+
gui = Gui::Game.new(game)
|
9
|
+
gui.show
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def load_coach(side)
|
15
|
+
CoachLoader.new(side).coach
|
16
|
+
end
|
6
17
|
end
|
7
18
|
end
|
data/media/background.png
CHANGED
Binary file
|
data/media/goal.png
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubygoal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Bejar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rubygoal-core
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 1.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: gosu
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
34
|
-
type: :
|
33
|
+
version: '0.9'
|
34
|
+
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.9'
|
41
41
|
description: Rubygoal
|
42
42
|
email:
|
43
43
|
- jorge@wyeworks.com
|
@@ -46,32 +46,17 @@ executables:
|
|
46
46
|
extensions: []
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
|
+
- LICENSE
|
49
50
|
- README.md
|
50
|
-
- MIT-LICENSE
|
51
51
|
- bin/rubygoal
|
52
|
-
- lib/rubygoal/ball.rb
|
53
|
-
- lib/rubygoal/coach.rb
|
54
|
-
- lib/rubygoal/coach_loader.rb
|
55
|
-
- lib/rubygoal/coaches/coach_away.rb
|
56
|
-
- lib/rubygoal/coaches/coach_home.rb
|
57
|
-
- lib/rubygoal/coaches/template.rb
|
58
|
-
- lib/rubygoal/config.rb
|
59
|
-
- lib/rubygoal/config_definitions.rb
|
60
|
-
- lib/rubygoal/coordinate.rb
|
61
|
-
- lib/rubygoal/field.rb
|
62
|
-
- lib/rubygoal/field_metrics.rb
|
63
|
-
- lib/rubygoal/formation.rb
|
64
|
-
- lib/rubygoal/game.rb
|
65
|
-
- lib/rubygoal/goal.rb
|
66
|
-
- lib/rubygoal/match.rb
|
67
|
-
- lib/rubygoal/moveable.rb
|
68
|
-
- lib/rubygoal/player.rb
|
69
|
-
- lib/rubygoal/players/average.rb
|
70
|
-
- lib/rubygoal/players/captain.rb
|
71
|
-
- lib/rubygoal/players/fast.rb
|
72
|
-
- lib/rubygoal/team.rb
|
73
|
-
- lib/rubygoal/version.rb
|
74
52
|
- lib/rubygoal.rb
|
53
|
+
- lib/rubygoal/gui.rb
|
54
|
+
- lib/rubygoal/gui/ball.rb
|
55
|
+
- lib/rubygoal/gui/field.rb
|
56
|
+
- lib/rubygoal/gui/game.rb
|
57
|
+
- lib/rubygoal/gui/goal.rb
|
58
|
+
- lib/rubygoal/gui/players.rb
|
59
|
+
- lib/rubygoal/gui/version.rb
|
75
60
|
- media/average_away.png
|
76
61
|
- media/average_home.png
|
77
62
|
- media/background.png
|
@@ -81,13 +66,9 @@ files:
|
|
81
66
|
- media/fast_away.png
|
82
67
|
- media/fast_home.png
|
83
68
|
- media/goal.png
|
84
|
-
- test/formation_test.rb
|
85
|
-
- test/random.txt
|
86
|
-
- test/record.txt
|
87
|
-
- test/test.rb
|
88
69
|
homepage: https://github.com/wyeworks/rubygoal
|
89
70
|
licenses:
|
90
|
-
-
|
71
|
+
- Apache License 2.0
|
91
72
|
metadata: {}
|
92
73
|
post_install_message:
|
93
74
|
rdoc_options: []
|
@@ -95,22 +76,18 @@ require_paths:
|
|
95
76
|
- lib
|
96
77
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
78
|
requirements:
|
98
|
-
- -
|
79
|
+
- - ">="
|
99
80
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
81
|
+
version: 2.2.2
|
101
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
83
|
requirements:
|
103
|
-
- -
|
84
|
+
- - ">="
|
104
85
|
- !ruby/object:Gem::Version
|
105
86
|
version: '0'
|
106
87
|
requirements: []
|
107
88
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
89
|
+
rubygems_version: 2.4.5
|
109
90
|
signing_key:
|
110
91
|
specification_version: 4
|
111
|
-
summary: Rubygoal
|
112
|
-
test_files:
|
113
|
-
- test/formation_test.rb
|
114
|
-
- test/random.txt
|
115
|
-
- test/record.txt
|
116
|
-
- test/test.rb
|
92
|
+
summary: Rubygoal Game - Soccer game for Rubysts
|
93
|
+
test_files: []
|
data/MIT-LICENSE
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
Copyright (c) 2014 Jorge Bejar
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
-
|
22
|
-
---
|
23
|
-
|
24
|
-
This does not apply to files under the "media/" folder.
|
data/lib/rubygoal/ball.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'gosu'
|
2
|
-
|
3
|
-
require 'rubygoal/field_metrics'
|
4
|
-
require 'rubygoal/moveable'
|
5
|
-
|
6
|
-
module Rubygoal
|
7
|
-
class Ball
|
8
|
-
include Moveable
|
9
|
-
|
10
|
-
def initialize(window, position)
|
11
|
-
super()
|
12
|
-
@position = position
|
13
|
-
@image = Gosu::Image.new(window, Config.ball.image_file, false)
|
14
|
-
end
|
15
|
-
|
16
|
-
def goal?
|
17
|
-
FieldMetrics.goal?(position)
|
18
|
-
end
|
19
|
-
|
20
|
-
def draw
|
21
|
-
image.draw(position.x - Config.ball.width / 2, position.y - Config.ball.height / 2, 1)
|
22
|
-
end
|
23
|
-
|
24
|
-
def update
|
25
|
-
super
|
26
|
-
if FieldMetrics.out_of_bounds_width?(position)
|
27
|
-
velocity.x *= -1
|
28
|
-
end
|
29
|
-
if FieldMetrics.out_of_bounds_height?(position)
|
30
|
-
velocity.y *= -1
|
31
|
-
end
|
32
|
-
|
33
|
-
velocity.x *= 0.95
|
34
|
-
velocity.y *= 0.95
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
attr_reader :image
|
40
|
-
end
|
41
|
-
end
|