rong-client 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/rong/client/window.rb +18 -9
  2. metadata +72 -10
@@ -29,12 +29,11 @@ module Rong
29
29
  super(WINDOW_WIDTH, WINDOW_HEIGHT, false)
30
30
  self.caption = "Rong: Ruby Pong"
31
31
 
32
- self.game = Rong::Elements::Game.new
33
- game.on_score {|left, right| update_scores(left, right) }
34
- game.on_hit { paddle_blip.play(1,1) }
35
- game.on_bounce { wall_blip.play(1,1) }
36
- game.on_win do |winner|
37
- self.winner_image = Gosu::Image.from_text(self, "#{winner.name} wins!", SCORE_FONT, SCORE_HEIGHT)
32
+ self.game = Rong::Elements::Game.new do |g|
33
+ g.on_score {|left, right| update_scores(left, right) }
34
+ g.on_hit { paddle_blip.play }
35
+ g.on_bounce { wall_blip.play }
36
+ g.on_win {|winner| create_winner_banner(winner) }
38
37
  end
39
38
 
40
39
  self.paddle_boxes = game.paddles.map {|p| DrawableElement.new(self, p) }
@@ -75,9 +74,7 @@ module Rong
75
74
  draw_background
76
75
  paddle_boxes.each {|p| p.draw }
77
76
  ball_box.draw
78
- if winner_image
79
- winner_image.draw(WINDOW_CENTER_X - (winner_image.width / 2), WINDOW_CENTER_Y, Window::ZIndex::HUD)
80
- end
77
+ draw_winner_banner if winner?
81
78
  end
82
79
 
83
80
  def draw_background
@@ -100,6 +97,18 @@ module Rong
100
97
  right_score_image.draw(WINDOW_CENTER_X + SCORE_X_OFFSET, SCORE_Y_OFFSET, Window::ZIndex::BACKGROUND)
101
98
  end
102
99
 
100
+ def create_winner_banner(winner)
101
+ self.winner_image = Gosu::Image.from_text(self, "#{winner.name} wins!", SCORE_FONT, SCORE_HEIGHT)
102
+ end
103
+
104
+ def draw_winner_banner
105
+ winner_image.draw(WINDOW_CENTER_X - (winner_image.width / 2), WINDOW_CENTER_Y, Window::ZIndex::HUD)
106
+ end
107
+
108
+ def winner?
109
+ winner_image
110
+ end
111
+
103
112
  def update_scores(left_score, right_score)
104
113
  left_score_text = left_score > 9 ? left_score.to_s : "0#{left_score}"
105
114
  right_score_text = right_score > 9 ? right_score.to_s : "0#{right_score}"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 3
9
- version: 0.2.3
8
+ - 4
9
+ version: 0.2.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matt Yoho
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-07 00:00:00 +01:00
17
+ date: 2011-08-20 00:00:00 -05:00
18
18
  default_executable: rong
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -43,8 +43,8 @@ dependencies:
43
43
  segments:
44
44
  - 0
45
45
  - 2
46
- - 1
47
- version: 0.2.1
46
+ - 2
47
+ version: 0.2.2
48
48
  type: :runtime
49
49
  version_requirements: *id002
50
50
  - !ruby/object:Gem::Dependency
@@ -57,24 +57,86 @@ dependencies:
57
57
  - !ruby/object:Gem::Version
58
58
  segments:
59
59
  - 2
60
- - 5
60
+ - 6
61
61
  - 0
62
- version: 2.5.0
62
+ version: 2.6.0
63
63
  type: :development
64
64
  version_requirements: *id003
65
65
  - !ruby/object:Gem::Dependency
66
- name: ruby-debug19
66
+ name: guard
67
67
  prerelease: false
68
68
  requirement: &id004 !ruby/object:Gem::Requirement
69
69
  none: false
70
70
  requirements:
71
- - - ">="
71
+ - - ~>
72
72
  - !ruby/object:Gem::Version
73
73
  segments:
74
74
  - 0
75
- version: "0"
75
+ - 6
76
+ - 1
77
+ version: 0.6.1
76
78
  type: :development
77
79
  version_requirements: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ name: guard-rspec
82
+ prerelease: false
83
+ requirement: &id005 !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ - 4
91
+ - 2
92
+ version: 0.4.2
93
+ type: :development
94
+ version_requirements: *id005
95
+ - !ruby/object:Gem::Dependency
96
+ name: rb-fsevent
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
99
+ none: false
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ segments:
104
+ - 0
105
+ - 4
106
+ - 3
107
+ version: 0.4.3
108
+ type: :development
109
+ version_requirements: *id006
110
+ - !ruby/object:Gem::Dependency
111
+ name: growl
112
+ prerelease: false
113
+ requirement: &id007 !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ~>
117
+ - !ruby/object:Gem::Version
118
+ segments:
119
+ - 1
120
+ - 0
121
+ - 3
122
+ version: 1.0.3
123
+ type: :development
124
+ version_requirements: *id007
125
+ - !ruby/object:Gem::Dependency
126
+ name: growl_notify
127
+ prerelease: false
128
+ requirement: &id008 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ segments:
134
+ - 0
135
+ - 0
136
+ - 1
137
+ version: 0.0.1
138
+ type: :development
139
+ version_requirements: *id008
78
140
  description: Rong-client is the catch-all Rong client package, and in the future will hopefully be replaced with platform-specifc implementations.
79
141
  email: mby@mattyoho.com
80
142
  executables: