Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

readme

  • Loading branch information...
commit 405af6f04941cda6dd9240ba90ea48462f31998b 1 parent 7fa4d26
@pedro authored
Showing with 49 additions and 0 deletions.
  1. +49 −0 README.md
View
49 README.md
@@ -0,0 +1,49 @@
+= Autopong
+
+A Ruby engine implementing the rules of ping pong.
+
+=== Usage
+
+Use as a backend for your game or whatever:
+
+```
+p1 = Autopong::Player.new("John Malkovich")
+p2 = Autopong::Player.new("Edward Norton")
+game = Autopong::Game.new(p1, p2)
+
+# the game will pick a random server
+puts "serve, #{game.current_server}"
+
+# ping means the ball hit the table
+# accepted values are:
+# 0: ball hit the p1 side
+# 1: ball hit the p2 side
+game.ping(0)
+
+# out means the ball went outside
+game.out
+
+# at any time you can check the score
+game.score # => [0, 1]
+
+# check the game state
+game.state # => :serve (other values are :ended and :progress)
+
+# and the winner, if any
+game.winner # => nil (would return a player if any
+```
+
+Check `bin/game` for a proxy that can be used with hardware hooked up to your table:
+
+```
+bin/game "John Malkovich" "Edward Norton"
+
+current match : John Malkovich vs Edward Norton
+serve : John Malkovich
+interactive mode ===
+ s : left (John Malkovich side)
+ d : out
+ f : right (Edward Norton side)
+-> s
+ good move from John Malkovich
+```
Please sign in to comment.
Something went wrong with that request. Please try again.