Games (Tetris and Pong) played through Google Calendar. Game state is displayed as calendar events, and controls work by moving events in the calendar.
- Game state displayed as colored calendar events in a grid
- Controls: move calendar events to control the game
- Optional browser refresh using Playwright
- Tetris displayed as a 24x10 grid of calendar events
- Each cell is a colored calendar event
- Score tracked as a calendar event
- Pong with dual joystick control
- Two paddles controlled by moving joystick events
- Python 3.13+
- Google Calendar API credentials
- Chrome browser (optional, for auto-refresh)
- Install dependencies:
pip install -r requirements.txt- Install Playwright (optional, for browser refresh):
playwright install chromium-
Google Calendar API setup:
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Calendar API
- Create credentials (OAuth 2.0 Client ID)
- Download the credentials file and save it as
credentials.jsonin the project root
-
Run the game:
python game.pyOn first run, authenticate with Google. A token.json file will be created.
- Chrome browser setup (optional, for auto-refresh):
To enable automatic browser refresh, launch Chrome with remote debugging:
macOS:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debugLinux:
google-chrome --remote-debugging-port=9222 --user-data-dir=/tmp/chrome-debugWindows:
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\Temp\chrome-debug"Then open your calendar in that Chrome window.
Start the game:
python game.pySelect a game by moving the selection event in the calendar.
- Move selection joystick event left (past dates) to select Tetris
- Control with joystick event:
- Left: move event to previous day
- Right: move event to next day
- Up: move event earlier in same day
- Down: move event later in same day
- Move selection joystick event right (future dates) to select Pong
- Two joystick events control the paddles
game.py- Main game launchercalendar_api.py- Google Calendar API integrationtetris.py- Tetris game logicpong.py- Pong game logiccredentials.json- Google API credentials (not in repo)token.json- OAuth token (generated on first run)calendar_id.txt- Calendar IDevent_ids.txt- Grid event IDsscore_event_id.txt- Score event IDemote_event_id.txt- Emote button event IDlog.txt- Application logs
Colors:
C- Cyan (color 7)Y- Yellow (color 5)M- Magenta (color 3)G- Green (color 10)R- Red (color 11)B- Blue (color 9)O- Orange (color 6).- Grey (color 8)
Tetris grid: 24 rows × 10 columns of calendar events
Control events:
- Joystick: cyan event for controls
- Score: green event showing score
- Emote button: magenta event
- Selection: event for game selection
Authentication issues:
- Delete
token.jsonand re-authenticate - Ensure
credentials.jsonis in project root - Verify Calendar API is enabled in Google Cloud Console
Events not appearing:
- Check calendar write permissions
- Verify calendar ID in
calendar_id.txt - Check
log.txtfor errors
Browser refresh not working:
- Ensure Chrome launched with remote debugging flags
- Check Playwright is installed:
playwright install chromium - Browser refresh is optional
Controls not responding:
- Verify joystick events are in correct time range
- Check events are being moved in calendar
- Review
log.txtfor errors
To add a new game:
- Create game file (e.g.,
snake.py) - Import functions from
calendar_api.py - Use
update_grid()for display updates - Use
check_joystick()or custom control logic - Add game selection in
game.py
Key API functions:
init_gui(newGame, game)- Initialize calendar interfaceupdate_grid(previous, new)- Update grid displaycheck_joystick()- Detect joystick movementupdate_score(score)- Update score eventcreate_event(name, color, start, end)- Create eventdelete_all_future_events()- Clean up calendar
- Events must be moved manually in Google Calendar
- Game state persists across sessions
- Future events are cleaned up on game start
- Do not commit
credentials.jsonortoken.json