bricks_meet_balls 0.0.2 → 0.0.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/NEWS.md +9 -0
- data/README.md +8 -1
- data/examples/groonga/main.rb +5 -1
- data/lib/bricks_meet_balls.rb +1 -0
- data/lib/bricks_meet_balls/ball.rb +1 -1
- data/lib/bricks_meet_balls/brick.rb +4 -0
- data/lib/bricks_meet_balls/version.rb +1 -1
- data/lib/bricks_meet_balls/window.rb +28 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66706a65047376f0a85a62aed149e15f17608265
|
4
|
+
data.tar.gz: 76c2a71feb7c8f7259df3cbbf8157e1c3cbee0d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0691572b829556820dc0e44220ce8e5f81e2e73ad7d4446964a9f884907f4c5160b4ed5c4b7e9022594d0abdc82e3dc59f4da1ed538e17299edfcf82bab556a2
|
7
|
+
data.tar.gz: 77a05581f232059bf850be09d13ef1bbbad33f3b188314221c9a1e6f091b1b1f8699dc0b002c5ff6de55b94e2ba536d9ca29801360ba4375465b58134c881dd5
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Bricks meet Balls
|
2
2
|
|
3
|
-
A game template as Break the Bricks using Gosu and Ruby.
|
3
|
+
A game template as Break the Bricks using [Gosu][] and [Ruby][].
|
4
|
+
|
5
|
+
[Gosu]: http://www.libgosu.org/
|
6
|
+
[Ruby]: https://www.ruby-lang.org/
|
4
7
|
|
5
8
|
## Installation
|
6
9
|
|
@@ -26,6 +29,10 @@ Or install it yourself as:
|
|
26
29
|
|
27
30
|
See examples/ directory.
|
28
31
|
|
32
|
+
## License
|
33
|
+
|
34
|
+
MIT License. See LICENSE.txt for details.
|
35
|
+
|
29
36
|
## Contributing
|
30
37
|
|
31
38
|
1. Fork it ( http://github.com/myokoym/bricks_meet_balls/fork )
|
data/examples/groonga/main.rb
CHANGED
@@ -39,6 +39,7 @@ height = 480
|
|
39
39
|
num_of_rows = 10
|
40
40
|
num_of_columns = 8
|
41
41
|
num_of_balls = 29
|
42
|
+
endless = true
|
42
43
|
|
43
44
|
base_dir = File.expand_path(File.dirname(__FILE__))
|
44
45
|
ball_images = BALL_IMAGES.collect do |ball_image|
|
@@ -54,6 +55,9 @@ window = BricksMeetBalls::Window.new(width,
|
|
54
55
|
num_of_columns,
|
55
56
|
num_of_balls,
|
56
57
|
ball_images,
|
57
|
-
brick_images
|
58
|
+
brick_images,
|
59
|
+
endless)
|
60
|
+
|
61
|
+
window.set_background_image(brick_images.first)
|
58
62
|
|
59
63
|
window.show
|
data/lib/bricks_meet_balls.rb
CHANGED
@@ -12,7 +12,7 @@ module BricksMeetBalls
|
|
12
12
|
@window = window
|
13
13
|
@x = @y = 0.0
|
14
14
|
@ball_radius = @window.height * 0.01
|
15
|
-
@angle =
|
15
|
+
@angle = ([*30..85, *95..150].sample) - 90
|
16
16
|
@speed = @window.height * 0.005
|
17
17
|
@moving = true
|
18
18
|
if image_path
|
@@ -12,7 +12,7 @@ module BricksMeetBalls
|
|
12
12
|
|
13
13
|
def initialize(width=240, height=480,
|
14
14
|
num_of_rows=2, num_of_columns=3, num_of_balls=1,
|
15
|
-
ball_images=nil, brick_images=nil)
|
15
|
+
ball_images=nil, brick_images=nil, endless=false)
|
16
16
|
super(width, height, false)
|
17
17
|
self.caption = "Bricks meet Balls"
|
18
18
|
@x1 = 0
|
@@ -25,8 +25,13 @@ module BricksMeetBalls
|
|
25
25
|
@message = nil
|
26
26
|
@ball_images = ball_images
|
27
27
|
@brick_images = brick_images
|
28
|
-
|
29
|
-
|
28
|
+
@num_of_columns = num_of_columns
|
29
|
+
@num_of_rows = num_of_rows
|
30
|
+
@num_of_balls = num_of_balls
|
31
|
+
@endless = endless
|
32
|
+
create_bricks(@num_of_columns, @num_of_rows)
|
33
|
+
create_balls(@num_of_balls)
|
34
|
+
@background_image = nil
|
30
35
|
end
|
31
36
|
|
32
37
|
def update
|
@@ -63,10 +68,18 @@ module BricksMeetBalls
|
|
63
68
|
end
|
64
69
|
|
65
70
|
if @message.nil? && @balls.empty?
|
66
|
-
@
|
71
|
+
if @endless
|
72
|
+
create_balls(@num_of_balls)
|
73
|
+
else
|
74
|
+
@message = Message.new(self, "Game Over...")
|
75
|
+
end
|
67
76
|
end
|
68
77
|
if @message.nil? && @bricks.empty?
|
69
|
-
@
|
78
|
+
if @endless
|
79
|
+
create_bricks(@num_of_columns, @num_of_rows)
|
80
|
+
else
|
81
|
+
@message = Message.new(self, "Congratulations!")
|
82
|
+
end
|
70
83
|
end
|
71
84
|
end
|
72
85
|
|
@@ -95,12 +108,22 @@ module BricksMeetBalls
|
|
95
108
|
end
|
96
109
|
end
|
97
110
|
|
111
|
+
def set_background_image(image_path)
|
112
|
+
@background_image = Gosu::Image.new(self, image_path, false)
|
113
|
+
end
|
114
|
+
|
98
115
|
private
|
99
116
|
def draw_area
|
100
117
|
draw_square(self,
|
101
118
|
0, 0,
|
102
119
|
self.width, self.height,
|
103
120
|
Gosu::Color::WHITE, ZOrder::Background)
|
121
|
+
return unless @background_image
|
122
|
+
@background_image.draw(0,
|
123
|
+
0,
|
124
|
+
ZOrder::Background,
|
125
|
+
1.0 * self.width / @background_image.width,
|
126
|
+
0.5 * self.height / @background_image.height)
|
104
127
|
end
|
105
128
|
|
106
129
|
def create_bricks(num_of_columns, num_of_rows)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bricks_meet_balls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masafumi Yokoyama
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gosu
|