AppGameKit for Python
A downloadable tool for Windows
Welcome to the world of game development using AppGameKit for Python!
AppGameKit for Python consists of a PYD file that allows Python 3 scripts to use AppGameKit commands and a PYI file to help IDEs, such as PyCharm, understand the command implementation and provide contextual help. The PYD is a complete, full-featured implementation of AppGameKit v2017.12.12. Since this PYD is free for use, AppGameKit is advertised by being mentioned in the window title bar and by the AppGameKit logo for a few seconds on start-up.
This is a trial project and we’re giving it 12 months (ending March 9, 2019) to see if it has traction. If it's liked and useful, we’ll issue a version that includes a way to compile an EXE to run scripts without the AppGameKit logo.
If you find this project useful, please buy AppGameKit (if you haven't already). You can also save 50% off AppGameKit and any of the bundles by using this promo code during checkout: AGKPYTHONDEAL50. Feel free to let The Game Creators know that you're liking AppGameKit for Python. :)
Under the current trial licence I can’t charge money for this project, but I am allowed to accept donations and they will be greatly appreciated.
AppGameKit for Python is Windows x86 only with no plans of supporting other operating systems during its trial period. Python 3.3 or greater for Windows x86 is required in order to use the PYD.
Thanks for using AppGameKit for Python! If you have any questions or problems, feel free to create a topic in the community forum.
(Currently this trial period expires on February 28th, 2019 at which point the project will be reviewed and may be removed from distribution on this site.)
Installation and Usage
Using the PYD file is as easy as placing the file in the same folder as your script and importing it. If you use an IDE such as PyCharm, the PYI file can be placed in the folder as well so the IDE can better understand the implementation of the PYD.
Once that is done, you're on your way to developing great games with AppGameKit for Python!
import appgamekit as agk with agk.Application(): while True: agk.print_value("Hello, World!") agk.sync() if agk.get_raw_key_pressed(27): break
The AppGameKit asset downloadable content packs will work with the Python version and are worth checking out:
Differences from AppGameKit Tiers 1 and 2
Method names have been changed so that they follow the PEP 8 style guide. The AppGameKit methods in Tiers 1 and 2 are TitleCased, but for this they are lowercase_with_underscores. ie: The LoadImage method is called load_image here.
The Print method was renamed to print_value so that it wouldn't be confused with Python's builtin print command.
The argument order for some methods had to be changed to compensate for the fact that Python doesn't have method overloading like other languages. An example of method overloading can be seen with the LoadImage command which has four method overloads:
LoadImage( ID, sImageFilename ) LoadImage( ID, sImageFilename, bBlackToAlpha ) integer LoadImage( sImageFilename, bBlackToAlpha ) integer LoadImage( sImageFilename )
The first two take an arbitrary ID that you provide as the first argument and the last two return the ID that AppGameKit assigns internally instead. There's also a bBlackToAlpha argument appearing in two of the overloads. Arguments that do not appear in every method overload were made optional which Python dictates must be placed after all required arguments.
As a additional rule, the id parameter will always be the last argument for methods like LoadImage that can accept an arbitrary ID passed to it or return the ID AppGameKit assigns internally. Note that this does not apply when the ID is required, such as for add_virtual_button.
Under these rules, the argument order for load_image becomes: filename, black_to_alpha, id.
And the AppGameKit Tiers 1 and 2 code for:
becomes this in AppGameKit for Python:
AppGameKit builds its internal "read" path based upon the main process executable name. For Python scripts, the read path for every script is based on the Python interpreter which means every script has the same read path.
This obviously is not desirable, so AppGameKit for Python monitors all methods requesting to open files and changes paths that are relative to the read path so that they are absolute ("raw") paths based upon where the main script is being executed.
This change allows you to be able to use a folder structure like that of AppGameKit Tiers 1 and 2 in that the "media" subfolder will be located in the same folder as your main script file.
AppGameKit for Python supports loading Tier 1 plugins with its import_plugin method.
plugin = import_plugin("ExamplePlugin") print(plugin.AddFloat(5, 7)) # prints 12.0
In order to use a plugin, its folder will need to be copied into a subfolder called "Plugins" where your main script is located. The resulting file structure will be something like this:
main.py appgamekit.pyd Plugins / ExamplePlugin / Commands.txt Windows.dll
Unlike with Tier 1, the Commands.txt file for the plugin also needs to be in the plugin folder and distributed with your game. Plugin method names will have the same character casing specified in the Commands.txt file.
Multiple command definitions with the same command name in the Commands.txt file will be loaded, however only the last definition processed will be available. In order to have access to all command definitions, the Commands.txt file will need to be changed such that each command definition has a unique name.
The Application class encapsulates the creation and destruction of the AppGameKit window. It is recommended that developers instantiate an Application object using a with block and put all game code inside the with block.
The enable_debug_log() method has been added to turn on log() method output. Without calling this first, log() calls do nothing. This allows one to enable the log() method calls during development and leave them disabled for release easily with a single command call.
The PYD also contains several constants (such as key codes, alignment settings, etc) that can be used. They are listed at the top of the PYI file.
- Any method listed as being deprecated or not functioning on the AppGameKit help site. This includes the non-OGG music methods.
- PrintC was merged into the print_value method as the newline argument. When newline is True, the default, Print is used internally. When newline is False, PrintC is used instead.
- Str, Bin, Hex, Val, ValFloat, Left, Right, Mid, Asc, Len, Chr, Upper, Lower, Spaces, Round, Abs, Mod, and Pow. Python already includes these functions in some form.
- The Log math method creates ambiguity with the Log debug command. Use math.log() instead.
- GetFileCount, GetFolderCount, GetFirstFolder, GetNextFolder, GetFirstFile, and GetNextFile. Due to how AppGameKit builds its read path and the fact that the read path cannot be overridden, these commands will not search the correct path when using a mode that tells them to include the read path.
- The PYD can be used with PyInstaller in both "one file" and "one folder" bundles. The read path will be based upon the application location.
- It is not possible to change the taskbar icon when using the PYD. Windows uses the icon from the executable for the taskbar which in this case is the Python interpreter. If you use PyInstaller, it allows you to set the EXE icon and this will change the taskbar icon used.
- The print_value() and log() methods can handle any Python object. They use the __str__ representation of the object for the text they output.
End User License Agreement
In addition to AppGameKit's EULA:
- The end user agrees not to try to circumvent the AppGameKit advertising in the PYD. This includes, but is not limited to, the window title bar stating "Made with AppGameKit" and the AppGameKit logo displayed at startup.
- The end user is permitted to create any type of project with this PYD, freeware or commercial, even in the event that the trial period expires and this project is removed from distribution.
- The end user agrees not to distribute the PYD or PYI except when distributing the PYD as part of their game's distribution package.
Copyright and License
AppGameKit and the AppGameKit Logo are copyright The Game Creators Ltd. All Rights Reserved.
This Python version of AppGameKit is officially licensed by The Game Creators Ltd to Adam Biser.
Windows, Mac, and Linux versions of AppGameKit are available from The Game Creators HERE.
The Python logo is a trademark of the Python Software Foundation.
Click download now to get access to the following files: