A downloadable tool

This is a homemade Python function that works with Pygame. It prints the number of a variable to the screen. It's compatible with floats and negative numbers. 

I made this in a few hours while listening to New Divide by  Linkin Park on loop.

INSTALLATION

The tool comes with two files :

  • The "digit" folder that contains all the images for the digits that can be printed on screen. This folder must be put in a /img/ directory to be accessed properly. The /img/ directory must be in the same directory of your main python file (the one that will import Digit Engine).
  • The "digitEngine.py" file that will be imported with a simple import digitEngine command line. Keep in mind that you have to put the command after the creation of basic window parameters (especially resolution).

HOW TO USE

All you need now is a single command in the main Pygame loop :

digitEngine.printNum(win, num,  [(x, y), bool, scale, space])

What each arguments to :

  • win = The window on which you print the variable
  • num = The variable that you want to print
  • parameters
    • (x, y) = Self explanatory, that are the coordinates where the variable will be printed
    • bool = Is your variable a boolean ? If this argument is True, then your number will be rounded to the 2nd digit.
    • scale = How big do you want your number to be ? Each digit is normally 5x7px.
    • space = The space between each digits

This tool is Creative common 0, go wild.

Updated 19 hours ago
Published 1 day ago
StatusReleased
CategoryTool
AuthorRainbow Shards
Tagseasy-to-use, function, pygame, python, sourcecode
ContentNo generative AI was used

Download

Download
Digit Engine - Version 1 10 kB

Install instructions

  1. Put the "digits" folder in a /img/ directory. the /img/ directory must be positioned in the same directory where your main Python project file is.
  2. Put the "digitEngine" file in the same directory where your main python project file is.
  3. Import the file in your main python project file with the import digitEngine command. Put the command after the creation of your window.
  4. digitEngine.printNum() is the command you put in the main Pygame loop

Just saying, you can easily modify the "digitEngine.py" file to adapt it to your environment.

Leave a comment

Log in with itch.io to leave a comment.