Skip to main content

Live coding in your pygame projects!

Project description

About

This module provides live coding in pygame.You can see your code changes at once without restart application.

https://user-images.githubusercontent.com/125838640/226334376-04f91f11-1775-49e5-8b04-2704e3355197.mp4

     

Note: Your Game should be implemented OOP style

Installing

pip install pygamelive

How to use?

Step 1

Import PygameLive class from package.

from pygamelive import debugger

Step 2

Create instance of PygameLive class in your game class.

def __init__(self):
        pg.init()
        self.screen = pg.display.set_mode(RES)
        self.clock = pg.time.Clock()
        self.load_assets()
        self.sound = Sound()
        self.score = Score(self)
        self.fire = DoomFire(self)
        self.new_game()

        self.py_live = debugger.PygameLive()

Step 3

Use debug method on your draw, update and check_event methods in your game loop.

def run(self):
        while True:
            # self.check_events()
            # self.draw()
            # self.update()
            #Live coding
            self.py_live.debug(self.draw)
            self.py_live.debug(self.update)
            self.py_live.debug(self.check_events)

Your code changes on the methods which you added using self.py_live.debug(self.draw) will be displayed immediately

Note: You can name your methods differently but the design of your game should be alike the design pattern noted below.

Example Game

Example game (FlappyDooM) is made by Stanislav Petrov StanislavPetrovV.

Critical Info

You should design your game like this to work PygameLive properly(highly recommended to look up example folder):

graph LR

B(Game Object Renderer 1) --> C(Main Renderer)
D(Game Object Renderer 2) --> C(Main Renderer)
E(Game Object Renderer 3) --> C(Main Renderer)

Note: Please look up example repo and change main.py file with the orginal one.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygamelive-1.0.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygamelive-1.0.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file pygamelive-1.0.0.tar.gz.

File metadata

  • Download URL: pygamelive-1.0.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for pygamelive-1.0.0.tar.gz
Algorithm Hash digest
SHA256 c6067941e9a50f356100bd7b5d32e605377bf6380733fc4b56652dd23dd0ee71
MD5 8a346af415ca8b6c8078a149c2b6da30
BLAKE2b-256 1ad944592f593187f11c5d5f271a63855032999ec47872d735a57e03571b337f

See more details on using hashes here.

File details

Details for the file pygamelive-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pygamelive-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for pygamelive-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 529860a05425630e390a17b76eb9d393867104abc416e0705e2b5edf193e7635
MD5 7d619b59d7aac1c9317dfd63379aa200
BLAKE2b-256 06a1b3e9611d9417871ca109a9132d366b271e18cf56b967526b378709df0a98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page