joyce 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -28
  3. data/lib/joyce.rb +11 -1
  4. data/lib/joyce/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17b6e2acc99201cb764f1396588e676e9ea884d9
4
- data.tar.gz: 8b762837b8aaffcfe6383e2634132e4050d3858e
3
+ metadata.gz: 5c5093b30bd0defdbf53c6453b0d650f0f97c96c
4
+ data.tar.gz: a71c98b65b59eeba9c05f451580a97fca09e998d
5
5
  SHA512:
6
- metadata.gz: 83f8879e432dfd00cfaaa771d71f55d87112d6ec631af93ce5bcb46bbc91d4415b73dcc47ef06cee20f07b32b36315723783357322441b052eec750df8f2f387
7
- data.tar.gz: 36053b131206f044b7e6587f09c34e166d04df90c01648d068149da0373f7fc2988821116236821d8eb98abc4a6b47fc97f2cd8dcaa59fb1319c887a6eef7429
6
+ metadata.gz: ab1ed1b2dcbc30c2418be1afe99810d6e31db40e924c3cda8ad1a3b3831093fac5b3b65edaa4ce2aa51f5df8bfefb967a510d12c5feca326c354be8bd741c912
7
+ data.tar.gz: 59171c9b077b3b23578832f43ca26f5ff51758067fbf1e58368767c50533b038c93f2ce868b21a3ea6b495af07d42ae84cce5d74c05720d7ddf50ef443f98ff6
data/README.md CHANGED
@@ -13,22 +13,19 @@ Joyce is a multiplayer game server framework built on top of Metacosm
13
13
 
14
14
  ## What is the big idea?
15
15
 
16
- The idea is to build 'isomorphic' Ruby games: to target both a Gosu game client as well as a game server
17
- running in the cloud. Both are running the same code, but the responsibilities are split:
16
+ The idea is to build 'isomorphic' Ruby games: to target both a Gosu game client as well as a game server running in the cloud. Both are running the same code, but the responsibilities are split:
18
17
 
19
18
  - The game server runs game business logic, and publishes events that the clients consume to hydrate their local views
20
19
  - Clients publish commands the the server validates and handles, updating game state and generating events
21
20
 
22
- One upshot of this is that all game processing is kept on the server, and clients are doing nothing but
23
- rendering views and when necessary figuring out what commands to publish (when the user interacts).
21
+ One upshot of this is that all game processing is kept on the server, and clients are doing nothing but rendering views and when necessary figuring out what commands to publish (when the user interacts).
24
22
 
25
23
  ## Features
26
24
 
27
25
  ## Examples
28
26
 
29
- Below is the source for a toy app that displays a list of other connected players and how long they've been connected. The server uses a ping command from clients to determine if players have disconnected.
27
+ Below is the source for a toy app that displays a list of other connected players and how long they've been connected. The server uses a ping command from clients to determine if players have disconnected.
30
28
 
31
- ```ruby
32
29
  require 'joyce'
33
30
  module Example
34
31
  class SampleAppView < Joyce::ApplicationView
@@ -43,12 +40,10 @@ rendering views and when necessary figuring out what commands to publish (when t
43
40
 
44
41
  class SampleServer < Joyce::Server
45
42
  def setup
46
- # p [ :sample_server_setup ]
47
43
  Game.create
48
44
  end
49
45
 
50
46
  def tick
51
- # p [ :sample_server_tick ]
52
47
  Game.all.each(&:iterate!)
53
48
  end
54
49
  end
@@ -57,7 +52,6 @@ rendering views and when necessary figuring out what commands to publish (when t
57
52
  viewed_with Example::SampleAppView
58
53
 
59
54
  def setup
60
- # p [ :sample_app_setup ]
61
55
  GameView.create(active_player_id: player_id)
62
56
  sim.params[:active_player_id] = player_id
63
57
  end
@@ -144,7 +138,7 @@ rendering views and when necessary figuring out what commands to publish (when t
144
138
 
145
139
  private
146
140
  def player_names
147
- self.player_views.map { |p| "#{p.name} (#{time_ago_in_words(p.joined_at)})" } #(&:name)
141
+ self.player_views.map { |p| "#{p.name} (#{time_ago_in_words(p.joined_at)})" }
148
142
  end
149
143
  end
150
144
 
@@ -154,13 +148,8 @@ rendering views and when necessary figuring out what commands to publish (when t
154
148
 
155
149
  class PingCommandHandler
156
150
  def handle(player_id:, player_name:)
157
- p [ :ping, from_player: player_id ]
158
151
  game = Game.find_by(players: { id: player_id })
159
152
  if game.nil?
160
- # we could try to create a new game for the player?
161
- # or add them to an existing one?
162
- p [ :no_game_yet! ]
163
-
164
153
  game = Game.first || Game.create
165
154
  game.admit_player(player_id: player_id, player_name: player_name)
166
155
  end
@@ -169,14 +158,6 @@ rendering views and when necessary figuring out what commands to publish (when t
169
158
  end
170
159
  end
171
160
 
172
- #
173
- # class GameController
174
- # def ping(player_id:, player_name:)
175
- # game = Game.find_by ...
176
- # end
177
- # end
178
- #
179
-
180
161
  class ApplicationEventListener < Metacosm::EventListener
181
162
  def game_view
182
163
  GameView.find_by(active_player_id: active_player_id)
@@ -193,10 +174,7 @@ rendering views and when necessary figuring out what commands to publish (when t
193
174
 
194
175
  class PlayerAdmittedEventListener < ApplicationEventListener
195
176
  def receive(player_id:, player_name:, connected_player_list:)
196
- p [ :player_admitted_event_listener ]
197
177
  if game_view
198
- # game_view.create_player_view(player_id: player_id, name: player_name, joined_at: Time.now)
199
- # go through connected player list and make views...
200
178
  connected_player_list.each do |id:, name:, joined_at:|
201
179
  player_view = game_view.player_views.where(player_id: id).first_or_create
202
180
  player_view.update(name: name, joined_at: joined_at)
@@ -211,7 +189,6 @@ rendering views and when necessary figuring out what commands to publish (when t
211
189
 
212
190
  class PlayerDroppedEventListener < ApplicationEventListener
213
191
  def receive(player_id:, connected_player_list:)
214
- p [ :player_dropped_event_listener! ]
215
192
  if game_view
216
193
  game_view.player_views.map(&:destroy)
217
194
  connected_player_list.each do |id:, name:, joined_at:|
@@ -222,7 +199,6 @@ rendering views and when necessary figuring out what commands to publish (when t
222
199
  end
223
200
  end
224
201
  end
225
- ```
226
202
 
227
203
  ## Requirements
228
204
 
@@ -14,6 +14,8 @@ module Joyce
14
14
  COMMAND_QUEUE = :joyce_command_queue
15
15
 
16
16
  class ApplicationView
17
+ include PassiveRecord
18
+
17
19
  attr_reader :application
18
20
 
19
21
  def initialize(application)
@@ -29,7 +31,11 @@ module Joyce
29
31
  end
30
32
 
31
33
  def font
32
- @font ||= Gosu::Font.new(18)
34
+ @font ||= Gosu::Font.new(24)
35
+ end
36
+
37
+ def mouse_position
38
+ window.mouse_position
33
39
  end
34
40
  end
35
41
 
@@ -52,6 +58,10 @@ module Joyce
52
58
  def update
53
59
  app.tick
54
60
  end
61
+
62
+ def mouse_position
63
+ [ mouse_x, mouse_y ]
64
+ end
55
65
  end
56
66
 
57
67
  class NullWindow
@@ -1,4 +1,4 @@
1
1
  module Joyce
2
2
  # joyce version
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: joyce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Weissman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-17 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gosu