Account Settings 0 items for $0.00 Checkout Now

Screen Graphics Module

Quick Links

General Information

PScreen is a Python module that provides simple 2D drawing functions as well as mouse and keyboard I/O. So why use PScreen when there are many other APIs out there?

Simplicity.  PScreen lets you do more with less.  PScreen is small and concise.  With PScreen you can draw on the screen, handle keyboard and mouse input, play sounds and music with less lines of code.

Great for learners.  With PScreen you can learn by example!  Our simple code samples show you how to use PScreen by example.

Small amount of code.  It does not have hundreds of thousands of lines of code for things you won’t use anyway.  The core is kept simple, and extra things like GUI libraries, and effects are developed separately outside of pygame.

Portable.  PScreen runs on Windows, Linux and Mac OS X!

Pygame.   PScreen is built on pygame.  After mastering PScreen, you will be ready to dig in and create even more advanced games.

Installers and Installation Instructions

Download the full PScreen installer and run it. Alternatively, if the pyglet and pygame libraries are already installed on your computer, you can download just the individual installer for PScreen.  Pygame and pyglet can also be obtained from www.pygame.org and www.pyglet.org, respectively.

VersionDescription
PScreen Full InstallerIncludes the PScreen module and also the pygame/pyglet libraries.
PScreen Only InstallerIncludes just the PScreen module.

Example Programs

Program NameDescription
MovementDemonstrates simple key input and movement.
Alpha and TextDemonstrates various shapes and alpha blending/transparency.
Mouse and CollisionDemonstrates mouse movement and collision (requires the sprite below in order to run).

Example Sprite

 

Click to download this sprite that can be used in your own games.  Put it in the same directory as your Python script to use this with the sprite manipulation functions.

License Information

© 2004 – 2017 Yost Labs
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Reference to PScreen Functions

Function ClassFunction NameUsage
General FunctionsLoadScreenLoadScreen(resolution=(800, 600), fullscreen=False, selectedBackend=”pygame”): Initialize the window. The possible choices for selectedBackend are “pygame-basic”, “pygame”, and “pyglet”.
ClearScreenClearScreen(color=(255, 255, 255, 255)): Fill the entire screen with the specified color. Should be placed at the top of the game loop.
UpdateScreenUpdateScreen(): Update the contents of the window. Should be placed at the end of the game loop.
UnloadScreenUnloadScreen(): Unload the screen and all associated resources.
Drawing FunctionsPixelSetPixelSet(x, y, color=(255, 255, 255, 255)): Color in the pixel at the specified position.
PixelGetPixelGet(x, y): Return a tuple describing the color at the specified position.
LineLine(x1, y1, x2, y2, color=(255, 255, 255, 255), linewidth=1): Draw a line from (x1, y1) to (x2, y2).
RectangleRectangle(x1, y1, x2, y2, color=(255, 255, 255, 255), linewidth=1): Draw a rectangle using (x1, y1) and (x2, y2) as two corners. If linewidth is zero, the rectangle will be filled.
TriangleTriangle(x1, y1, x2, y2, x3, y3, color=(255, 255, 255, 255), linewidth=1): Draw a triangle using (x1, y1), (x2, y2) and (x3, y3) as the corners. If linewidth is zero, the triangle will be filled.
CircleCircle(x, y, r, color=(255, 255, 255, 255), linewidth=1): Draw a circle at position (x, y) with radius r. If linewidth is zero, the circle will be filled.
EllipseEllipse(x, y, w, h, color=(255, 255, 255, 255), linewidth=1): Draw an ellipse at position (x, y) with width w and height h. If linewidth is zero, the ellipse will be filled.
Keyboard FunctionsKeyIsPressedKeyIsPressed(key): Returns true if this key is currently pressed. key can be a string; for example, “a”, “return”, and “escape” are all valid.
KeyIsNotPressedKeyIsNotPressed(key): Returns true if this key is NOT currently pressed.
KeyGetPressedListKeyGetPressedList(): Return a list of currently pressed keys.
Mouse FunctionsMouseGetButtonLMouseGetButtonL(): Returns True if the left mouse button is held down.
MouseGetButtonRMouseGetButtonR(): Returns True if the right mouse button is held down.
MouseGetButtonMMouseGetButtonM(): Returns True if the middle mouse button is held down.
MouseGetXMouseGetX(): Returns the x position of the mouse.
MouseGetYMouseGetY(): Returns the y position of the mouse.
MouseGetPositionMouseGetPosition(): Returns a tuple containing the x and y positions of the mouse.
MouseGetButtonsMouseGetButtons(): Returns a 3-element tuple describing the state of each mouse button, such as (left, middle, right). Each element will be True or False.
Font FunctionsFontSelectFontSelect(fontName=”Arial”, fontSize=”24″): Set the current font. Must be done prior to rendering text.
FontWriteFontWrite(x, y, text, color=(255, 255, 255, 255)): Draw text at the specified position. Currently, the alpha value (the last color parameter) is not supported in pygame.
Music FunctionsMusicLoadMusicLoad(filename): Load filename as the current background music. Multiple formats are supported, including .mp3, .wav, and .ogg.
MusicPlayMusicPlay(): Play the currently loaded background music.
MusicPauseMusicPause(): Pause the currently playing background music.
MusicUnPauseMusicUnPause(): Unpause the currently loaded background music.
MusicFadeMusicFade(seconds): Fade out the currently playing background music over the given time.
MusicSetVolumeMusicSetVolume(volumePercent=40): Set the volume of the currently loaded background music.
MusicGetVolumeMusicGetVolume(): Return the volume of the currently loaded background music.
MusicStopMusicStop(): Stop the currently playing background music.
Sound FunctionsSoundLoadSoundLoad(filename, slot): Load the specified sound into one of 256 slots (slot should be 0 – 255).
SoundPlaySoundPlay(slot): Play the sound stored in the given slot.
SoundStopSoundStop(slot): Stop the sound stored in the given slot.
SoundSetVolumeSoundSetVolume(slot, volumePercent): Set the volume of the sound in the given slot.
Sprite FunctionsSpriteLoadSpriteLoad(filename, slot): Load the specified sprite into one of 256 slots (slot should be 0 – 255).
SpriteRenderSpriteRender(x, y, slot, rotation=0, scale=1, flipH=False, flipV=False, alpha=255): Render the sprite in the specified slot at the specified position. Rotation specifies a counterclockwise rotation in angles; scale specifies a scaling factor in both dimensions; flipH and flipV flip the sprite horizontally and vertically, respectively. The alpha parameter is not currently supported in pygame.
SpriteSimpleRenderSpriteSimpleRender(x, y, slot): A simpler, quicker method of rendering a sprite.
SpriteWidthSpriteWidth(slot): Return the width of the sprite in the specified slot.
SpriteHeightSpriteHeight(slot): Return the height of the sprite in the specified slot.
Frame Rate FunctionsFrameGetLimitFrameGetLimit(): Returns the current frames per second.
FrameSetLimitFrameSetLimit(fps): Cap the framerate at the specified frames per second.
FrameDelayFrameDelay(): Ticks the internal clock object; this should be called during every iteration of the game loop. The function returns a value that indicates the amount of time elapsed since the last update.