Python Text Based Graphics Module
This is a console based python3 graphics engine for simple Unicode games or animations.
circle.py are example programs using the module (Note:
> are used instead of arrow keys.), also see grit96's Physics Engine and my Tetris game, which use this module.
python3 setup.py install
Or install from PyPI: pypi.python.org/pypi/graphics.
Simple usage example:
import graphics as g # Create the canvas, 20x20 pixels (characters). screen = g.Canvas(size = (20, 20)) # Create a circle image, radius 5 pixels. circleImage = g.shapes.Circle(5) # Create a green sprite at position (7, 7) with the circle image. circleSprite = g.Sprite(circleImage, position = (7, 7), color = g.colors.GREEN) # Add the sprite to the canvas. screen.sprites.append(circleSprite) # Output the canvas to the terminal. print(screen) # Increase the circles radius by two. circleSprite.image.radius += 2 # Output the canvas to the terminal. print(screen)
This module was written and tested with python3 on Debian with gnome-terminal. It should work with most Linux terminals, but some things might be off.
- Colours should work if your terminal supports them, otherwise they won't cause any problems.
- The input module supports Windows, Mac and Unix. Linux works fine and testing is in progress for Windows.
- In the Windows CMD it doesn't centre properly, colours don't work, it was slow and input doesn't work.