Skip to main content

Helper package for pgzero. Includes added support and documentation.

Project description

Pgzhelper

Run using pgzhelper_run.go(), not pgzrun.go()

as camera and changing the frames per second will fail.

Do not import Screen as screen

as screen will overload the pgzero-screen making all capabilities fail.

Helper package to pgzero. Has addition capabilities such as showing the camera. Some capabilities can also be used in pygame.

The first line of your draw function must include init(screen)

In the draw function, when you pass in the screen parameter for init(screen), this is expecting the pgzero screen or the pygame display surface. For pgzero, just enter screen for the screen parameter. This will have a yellow underline under it, but do not worry because this is what is supposed to happen.

If you do not call the init function, then any function that you run will raise a ScreenError. This is for making sure both the pgzero/pygame screen and the surface that Screen uses are both the same. If Screen makes a new surface, then doing one action in one of them will not affect the other.

Example (assuming that Screen creates its own surface):

def draw():
    Screen.fill("blue") # Makes the screen blue
def draw():
    Screen.fill("blue")
    Screen.draw.text("hi", topleft=(100, 100))
    screen.draw.text("bye", topleft=(200, 200)) # You can only see "hi" because Screen is 
    # overloading the screen. With the init(),
    # you would see both the hi and the bye.

This means, that, your draw function can have some Screen drawings and some screen drawings, and the output won't be affected. So, an action in one of them affects the other.

Advantages of using Screen:

All of the Screen functions have the exact same capabilities as the screen functions, just with some more such as drawing lines with 5 thickness.

Also, all of the Screen functions have full documentation, so you do not have to go to the pgzero website to find out what functions and what parameters there are.

Additional capabilities:

thickness parameter for line drawing and drawing rects.

Drawing polygons

set the window position (on the laptop)

center the window (on the laptop)

Changing the cursor shape (on the screen)

Changing the frames per second in the functions (For the this to work, you must call pgzhelper_run.go(), not pgzrun.go())

Shapes:

HRect (helper rect) class that has .collidecircle()

Circle class that has .colliderect(), .collidecircle(), .collidepoint()

Shape class

Polygon class

Ellipse class

Quadrilateral class

Triangle class with rotate around pivot, move up (this is move down to our eyes, because when y increases in pgzero, the shape moves down), move down (this is move up to our eyes, because when y decreases in pgzero, the shape moves up), move left, and move_right

EquilateralTriangle class with direction (DOWN or UP) and the same methods as the Triangle class (moving or rotating will return a Triangle, not an EquilateralTriangle)

Square class

shapes Enum so you can do shapes.rect, shapes.polygon, etc.

Camera capabilities:

loading a camera (with the number which is what camera you want if you have more than 1. 1 will load the first camera and 2 will load the second camera). You do not need to store this in a variable. It will return None.

setting the zoom factor. How zoomed in it should be. 1 means it shows the full camera view. 2 means it zooms into the center of the camera by a factor of 2.

if you want to remove the background and replace it with a color or not.

get camera width and height, the dimentions (in pixels) of how big the camera view is (on screen).

For the camera to work, you must call pgzhelper_run.go(), not pgzrun.go()

Versions

Version 0.0.1: Base code published (Latest) Version 0.0.2: Fix errors and bugs Version 0.0.3: Add documentation to all Screen functions and classes.

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

pgzhelper-0.0.2.tar.gz (223.5 kB view details)

Uploaded Source

Built Distribution

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

pgzhelper-0.0.2-py3-none-any.whl (224.2 kB view details)

Uploaded Python 3

File details

Details for the file pgzhelper-0.0.2.tar.gz.

File metadata

  • Download URL: pgzhelper-0.0.2.tar.gz
  • Upload date:
  • Size: 223.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pgzhelper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 dcf70482678e75c9a578ce56180d4e2847eed5839920d3c636d38a60d703ccd8
MD5 b583e1c4629f08789d03a1f5cf1ff8b7
BLAKE2b-256 9a44721048f0bc5f9eb280dbbb1e969406d89ca5119dbfb6d8d8298588e467ba

See more details on using hashes here.

File details

Details for the file pgzhelper-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pgzhelper-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 224.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for pgzhelper-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a8cffa52c044adad639f7a5f388535f25b9d9c76b7467a618aac7303a6e62047
MD5 670630a3bbdc730afd3f2942aa4f1f25
BLAKE2b-256 708bbe72f3e660ffd1a40ca01dc6e2de742df536376a1d5f513904e2e1c37397

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