rong-elements 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
|
|
1
|
+
require 'rong/elements/behavior/bounding'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Rong
|
2
|
+
module Elements
|
3
|
+
module Entities
|
4
|
+
class GameState
|
5
|
+
attr_reader :paddle_positions, :ball_positions
|
6
|
+
|
7
|
+
def initialize(paddle_positions=[0,0], ball_positions=[0,0])
|
8
|
+
@ball_positions = ball_positions
|
9
|
+
@paddle_positions = paddle_positions
|
10
|
+
end
|
11
|
+
|
12
|
+
%w(first second third fourth).each_with_index do |ordinal, index|
|
13
|
+
define_method("#{ordinal}_paddle_position") do
|
14
|
+
@paddle_positions[index]
|
15
|
+
end
|
16
|
+
|
17
|
+
define_method("#{ordinal}_paddle_position=") do |value|
|
18
|
+
@paddle_positions[index] = value
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def ball_position
|
23
|
+
position = ball_positions.first
|
24
|
+
return position if position.kind_of? Array
|
25
|
+
ball_positions
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Rong
|
2
|
+
module Elements
|
3
|
+
module Entities
|
4
|
+
class Paddle
|
5
|
+
attr_reader :velocity, :y
|
6
|
+
|
7
|
+
def initialize(y_coord)
|
8
|
+
@velocity = 0
|
9
|
+
@y = y_coord
|
10
|
+
end
|
11
|
+
|
12
|
+
def up
|
13
|
+
@velocity = 1
|
14
|
+
end
|
15
|
+
|
16
|
+
def down
|
17
|
+
@velocity = -1
|
18
|
+
end
|
19
|
+
|
20
|
+
def rest
|
21
|
+
@velocity = 0
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rong-elements
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Matt Yoho
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-03 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
- beta
|
32
|
+
- 19
|
33
|
+
version: 2.0.0.beta.19
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
description: Rong-elements contains shared game models and utilities for Rong, a Ruby implementation of Pong that consists of a server module for managing games, a client module for for interfacing with the server, and hopefully a few client implementations for playing some rad Pong, brah.
|
37
|
+
email: mby@mattyoho.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- lib/rong/elements/behavior.rb
|
46
|
+
- lib/rong/elements/entities/ball.rb
|
47
|
+
- lib/rong/elements/entities/game_state.rb
|
48
|
+
- lib/rong/elements/entities/paddle.rb
|
49
|
+
- lib/rong/elements/entities.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/mattyoho/rong
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
segments:
|
64
|
+
- 1
|
65
|
+
- 8
|
66
|
+
- 7
|
67
|
+
version: 1.8.7
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 3
|
75
|
+
- 6
|
76
|
+
version: 1.3.6
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.3.6
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Ruby-based Pong server implementation
|
84
|
+
test_files: []
|
85
|
+
|