日本語 / English
This is a game library that makes it easy to create browser games in Python.
- Can be written in Python.
- Compatible with PC and both Android/iOS.
- Easily display images and play sounds.
- Transparently handles keyboard, mouse, and screen touch.
It uses Brython, a transpiler that converts Python code written in the browser into JavaScript.
A sample game actually made with this library is available below. Keyboard, mouse, and screen touch are all supported.
Please download and use yanesdk.py from this GitHub.
You can load brython from cdn as follows, and execute brython() in onload of body. you can load another file written in python called sample.py and import yanesdk at the beginning of it.
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/[email protected]/brython.min.js">
</script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/[email protected]/brython_stdlib.js">
</script>
</head>
<body onload="brython()">
<canvas id="canvas" width="800" height="400" style="cursor:none"></canvas>
<script type="text/python" src="sample.py">
</body>
</html>
# sample.py
from yanesdk import *
Canvas canvas
canvas.clear()
canvas.draw_rect(Vector2D(100,100),Vector2D(200,200),"white")
We have not prepared any documentation for this library, but you should be able to understand it by looking at the source code of a sample game.
The sample program above specifies sample.py as an external script, but since this part is loaded using Ajax, it may cause a security error in a local environment. (For example, Chrome 97 or later) In that case, you need to embed it in the html file instead of loading it from an external file.
If you are using VSCode, it is recommended to set up a local server with the Live Server extension.
When developing with VS Code, writing Python code directly on html is troublesome because input completion does not work.
This is because the browser you are importing from yanesdk.py is a library provided by Brython and Pylance cannot access it. If you place a dummy browser.py in the same folder instead, the warnings will not appear.
- The MIT License also applies to the sample source code.
- The image materials in the samples are resized from materials from Irastoya. Redistribution itself is not a problem, but the copyright of this image belongs to Irastoya.
- The audio material in the sample is processed from free material. Redistribution itself is not a problem, but the copyright itself is not renounced in this case either.
coming soon..
This is a live video of the process of making the above sample game while producing this SDK. The video includes the process of making this SDK itself, so some of the content is rather technical, but I think it will be helpful when actually making the game.
The 3rd and 4th editions are in preparation.