ruby-pong 0.0.1 → 0.0.2
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.
- data/Gemfile +1 -1
- data/bin/pong +15 -14
- data/lib/ruby-pong.rb +8 -0
- data/lib/ruby-pong/version.rb +1 -1
- metadata +6 -6
data/Gemfile
CHANGED
data/bin/pong
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'rubygems'
|
3
2
|
require 'ruby-pong'
|
4
3
|
|
5
4
|
include Pong
|
@@ -13,12 +12,12 @@ ball = Ball.new do
|
|
13
12
|
set_y_position 200
|
14
13
|
|
15
14
|
set_velocity Arcade::Velocity[5,7]
|
16
|
-
|
15
|
+
|
17
16
|
on_hit_edge do |edge|
|
18
17
|
if edge == :top or edge == :bottom
|
19
18
|
self.velocity = self.velocity.reflect_vertically
|
20
19
|
end
|
21
|
-
|
20
|
+
|
22
21
|
if edge == :left or edge == :right
|
23
22
|
self.velocity = self.velocity.reflect_horizontally
|
24
23
|
end
|
@@ -27,16 +26,16 @@ end
|
|
27
26
|
|
28
27
|
player_paddle = Paddle.new do
|
29
28
|
set_name 'player_paddle'
|
30
|
-
|
29
|
+
|
31
30
|
set_color Arcade::Color::WHITE
|
32
|
-
|
31
|
+
|
33
32
|
set_x_position 10
|
34
33
|
set_y_position 10
|
35
|
-
|
34
|
+
|
36
35
|
on_keypress Arcade::Keyboard::KeyW do
|
37
36
|
if self.top > 0
|
38
37
|
move_up 10
|
39
|
-
end
|
38
|
+
end
|
40
39
|
end
|
41
40
|
|
42
41
|
on_keypress Arcade::Keyboard::KeyS do
|
@@ -46,18 +45,20 @@ player_paddle = Paddle.new do
|
|
46
45
|
end
|
47
46
|
|
48
47
|
on_collides_with Ball do |ball|
|
48
|
+
get_object('opponent_paddle').score!
|
49
|
+
|
49
50
|
ball.velocity = ball.velocity.reflect_horizontally
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
53
54
|
opponent_paddle = Paddle.new do
|
54
55
|
set_name 'opponent_paddle'
|
55
|
-
|
56
|
+
|
56
57
|
set_color Arcade::Color::RED
|
57
|
-
|
58
|
-
set_x_position $main_window.width -
|
58
|
+
|
59
|
+
set_x_position $main_window.width - self.width - 10
|
59
60
|
set_y_position 10
|
60
|
-
|
61
|
+
|
61
62
|
on_keypress Arcade::Keyboard::KeyUp do
|
62
63
|
if self.top > 0
|
63
64
|
move_up 10
|
@@ -71,14 +72,14 @@ opponent_paddle = Paddle.new do
|
|
71
72
|
end
|
72
73
|
|
73
74
|
on_collides_with Ball do |ball|
|
75
|
+
get_object('player_paddle').score!
|
76
|
+
|
74
77
|
ball.velocity = ball.velocity.reflect_horizontally
|
75
78
|
end
|
76
79
|
end
|
77
80
|
|
78
|
-
|
79
81
|
$main_window.register player_paddle
|
80
82
|
$main_window.register opponent_paddle
|
81
83
|
$main_window.register ball
|
82
84
|
|
83
|
-
|
84
|
-
$main_window.show
|
85
|
+
$main_window.show
|
data/lib/ruby-pong.rb
CHANGED
data/lib/ruby-pong/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-pong
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04
|
12
|
+
date: 2012-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: arcade
|
16
|
-
requirement: &
|
16
|
+
requirement: &70162674271220 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70162674271220
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70162674270760 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70162674270760
|
36
36
|
description: Pong in Ruby, to demonstrate jfarmer's Arcade framework
|
37
37
|
email:
|
38
38
|
- jesse@20bits.com
|