aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Harley2017-12-02 19:43:44 +0000
committerTom Harley2017-12-02 19:43:44 +0000
commit50cc91d3343401d081557114469eed64306c6db3 (patch)
tree1d5d6a02cd2360c5fae3fa5d3edf0622108a4d7e
parentyes (diff)
parentDocumentation (diff)
downloadlongpong-50cc91d3343401d081557114469eed64306c6db3.tar.gz
longpong-50cc91d3343401d081557114469eed64306c6db3.zip

Merge branch ‘master’ of https://github.com/magnostherobot/longpong

-rw-r--r--README.md26
-rw-r--r--client/bitfont.py8
-rw-r--r--client/render.py18
3 files changed, 44 insertions, 8 deletions
diff --git a/README.md b/README.md
index 696018a..df5413a 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,27 @@
# longpong
+
+longpong is a game of Pong that spans multiple screens and computers.
+
+## Starting a game of longpong
+
+First, start a server:
+
+ node server/server.js <port>
+
+Now start one client on each computer:
+
+ python3 client/longpong.py <server_ip> <server_port> <index> <num_windows>
+
+- `<index>` is the client's index in the list of clients, starting at 0, from left to right.
+- `<num_windows>` is the number of windows that this client should have.
+
+In each client, position the windows as desired, typing the window's number (see its title) to make it fullscreen on its current screen. Press `return` when the windows are positioned.
+
+When all of the clients are ready, press `space` on one of the clients to tell the server that the clients are all ready to start. The game then begins.
+
+Control your paddle with the up and down arrow keys.
+
+## Dependencies
+
+- `python3`
+- `PySDL2`
diff --git a/client/bitfont.py b/client/bitfont.py
index 7fa27b4..094616d 100644
--- a/client/bitfont.py
+++ b/client/bitfont.py
@@ -61,8 +61,12 @@ _bitfont_9 = [ True, True, True,
_bitfonts = [ _bitfont_0, _bitfont_1, _bitfont_2, _bitfont_3, _bitfont_4, _bitfont_5, _bitfont_6, _bitfont_7, _bitfont_8, _bitfont_9 ]
def bitfont(number):
- # Create the fonts
- # Generate the digits
+ """
+ Convert a base 10 number into a bitfont, which is represented by a list
+ representing a 3x5 grid, row by row. A value of True represents a cell
+ that should be drawn and a value of False represents a cell that should
+ be left blank.
+ """
result = []
number = add_digit(result, number)
while number > 0:
diff --git a/client/render.py b/client/render.py
index 8e4b0eb..3efa27a 100644
--- a/client/render.py
+++ b/client/render.py
@@ -23,6 +23,15 @@ class Renderer:
Initialise the renderer with a foreground colour and a background colour
and create an SDL2 window for drawing to. This assumes that SDL2 has
already been initialised.
+
+ Arguments:
+ title -- the title to give the client windows
+ dimensions -- the dimensions (in pixels) at which to start the windows
+ num_windows -- the number of windows to run the client with
+
+ Keyword arguments:
+ fg -- the foreground colour to draw with (default (255, 255, 255))
+ bg -- the background colour to draw with (default (0, 0, 0))
"""
self.fg = fg
self.bg = bg
@@ -34,6 +43,7 @@ class Renderer:
screen.window.show()
def set_offset(self, offset):
+ """Set this client's offset in the full-sized screen made by all clients."""
self.offset = offset
def render(self, balls, paddles, score):
@@ -108,14 +118,10 @@ class Renderer:
sdl2.SDL_SetWindowFullscreen(window.window, sdl2.SDL_WINDOW_FULLSCREEN)
def get_rightmost_edge(self):
- """
- Get the relative coordinate of the rightmost edge.
- """
+ """Get the relative coordinate of the rightmost edge."""
return self.offset + sum(self.get_screen_widths())
def get_screen_widths(self):
- """
- Get the relative screen widths in screen order.
- """
+ """Get the relative screen widths in screen order."""
# Window height is '1' between all clients, so divide the width by the height
return list(map(lambda screen: float(screen.width) / float(screen.height), self.screens))