diff --git a/README.md b/README.md index 51a2a61..afc6915 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,12 @@ This is my attempt at building Conway's game of life in multiple languages. My first attempt is to do it in Python using Pygame and other libraries. I do plan on showcasing these on my website. -## Running with Python +## Setting up Python -To run the Python version I recommend that you set up a python virtual environment, you can do this with the following command +To run the Python version of this program, I recommend that you set up a python virtual environment. The current recommended Python version is Python 3.13 by Pygame. You can set up the virtual environment with the following command: + +`python3.13 -m venv /path/to/virtual/environment` -`python -m venv /path/to/virtual/environment` After that you can use it to run the program and pip installs to get the libraries. @@ -16,16 +17,30 @@ After that you can use it to run the program and pip installs to get the librari The following commands should install any dependencies and ensure you are ready to run the program. -`pip install --upgrade pip` - This will update pip to the version compatible with the virtual environment. +`pip install --upgrade pip` + - This will update pip to the version compatible with the virtual environment. -`pip install pygame pygame-menu pygbag numpy importlib` - This will install the dependencies needed for the project. +`pip install pygame pygame-menu numpy` + - This will install the dependencies needed for the project. ### Running the program -Running the program is fairly simple. +Running the program is fairly simple. Starting the program can be done with the following command: -Starting the program can be done with the following command: +`python -m src.main` -`python -m src.main` -Once running the menu is fairly simple and some parts do not work at the moment. However once in game the right mouse will remove a cell and a left click will create a cell. To start the simulation you press the return button, this will prevent you from making new cells. the same button will stop the simulation in place. To clear the screen and stop the simulation if running simply press C. Escape will pause the game but the simulation will not stop. To exit press escape and follow prompts to quit the game. +### Basic Controls + +Once running, the menu is fairly simple and some parts are still a work in progress. This can be navagated by using the Left mouse and clicking on the buttons on-screen to navigate. + +Once in the game: + +- Use Right mouse will remove a cell +- Use Left mouse will create a cell. +- Use Return/ Enter to start/stop the simulation + - NOTE: This will prevent you from making new cells while the simulation is running. +- Use C to clear the screen and stop the simulation. +- Use Escape to pause the game + - NOTE: The simulation will not stop. +- To exit press escape and follow prompts to quit the game. diff --git a/src/__pycache__/main.cpython-313.pyc b/src/__pycache__/main.cpython-313.pyc index 5265459..fce4dd4 100644 Binary files a/src/__pycache__/main.cpython-313.pyc and b/src/__pycache__/main.cpython-313.pyc differ diff --git a/src/main.py b/src/main.py index d98c721..8084e96 100644 --- a/src/main.py +++ b/src/main.py @@ -1,14 +1,13 @@ import sys import pygame -#import pygbag used for serving on a website would need to change the code import os import pygame_menu import numpy as np import math import random as rand -SCREEN_X = 1280 -SCREEN_Y = 720 +SCREEN_X = 1920 +SCREEN_Y = 1080 SCREEN = None MENU_X = 1 MENU_Y = 1 @@ -54,16 +53,17 @@ def updateGame(): pygame.display.flip() def drawRect(x,y, color): - global CELL_SIZE #Draw the rectangle square = pygame.Rect((x,y, CELL_SIZE, CELL_SIZE)) pygame.draw.rect(SCREEN, color, square) def drawGrid(): - # Draw the grid lines only - for x in range(0, SCREEN.get_width(), 100): + # Draw the grid lines + gridOffset = CELL_SIZE * 10 + for x in range(0, SCREEN.get_width(), gridOffset): + #(display,color, start, end) pygame.draw.line(SCREEN, (0, 0, 60), (x, 0), (x, SCREEN.get_height())) - for y in range(0, SCREEN.get_height(), 100): + for y in range(0, SCREEN.get_height(), gridOffset): pygame.draw.line(SCREEN, (0, 0, 60), (0, y), (SCREEN.get_width(), y)) def displayMenu(): @@ -79,7 +79,10 @@ def displayMenu(): def controlsMenu(): SCREEN.fill((0, 0, 0)) menu = pygame_menu.Menu('Controls', MENU_X, MENU_Y, theme=MENU_THEME) - menu.add.label('Controls coming soon') + menu.add.label('Esc - Goes to the settings / options menu') + menu.add.label('C - Clears the screen while in the game') + menu.add.label('Left mouse - Adds a cell to the screen while in the game') + menu.add.label('Right mouse - Removes a cell from the screen while in the game') menu.add.button('Back', settingsMenu) menu.mainloop(SCREEN) @@ -248,7 +251,7 @@ def main(): pygame.init() try: #initialize the screen and set the height and widths - SCREEN = pygame.display.set_mode((1920,1080), pygame.RESIZABLE | pygame.SCALED) + SCREEN = pygame.display.set_mode((SCREEN_X,SCREEN_Y), pygame.RESIZABLE | pygame.SCALED) SCREEN_X, SCREEN_Y = SCREEN.get_size() MENU_Y = .9 * SCREEN_Y