From 96f36881818e648765183926b3a7ac119dd79fd9 Mon Sep 17 00:00:00 2001 From: Billy Brown Date: Sat, 2 Dec 2017 18:46:01 +0000 Subject: Wrote README --- README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) 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 + +Now start one client on each computer: + + python3 client/longpong.py + +- `` is the client's index in the list of clients, starting at 0, from left to right. +- `` 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` -- cgit v1.2.1 From f8af519f3997b2798b5f7f4e077bf82c603a683e Mon Sep 17 00:00:00 2001 From: Billy Brown Date: Sat, 2 Dec 2017 19:38:49 +0000 Subject: Documentation --- client/bitfont.py | 8 ++++++-- client/render.py | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) 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)) -- cgit v1.2.1