Added description and usage to readme
This commit is contained in:
33
README.md
33
README.md
@@ -1,2 +1,33 @@
|
||||
# PyStudio
|
||||
# PyCanvas
|
||||
|
||||
PyCanvas is a Skulpt library for creating 2D games. It is based on litecanvas, and uses the HTML Canvas API. The demo editor is available at [PyStudio](https://pystudio.haaxman.co.uk/) and provides a nice online editor for writing code.
|
||||
|
||||
## Usage
|
||||
|
||||
To use PyCanvas, you can add the following to the top of your skulpt builtInRead() function:
|
||||
|
||||
```javascript
|
||||
if (x === 'screen' || x === './screen.js') {
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "path/to/screen.js", false);
|
||||
xhr.send();
|
||||
if (xhr.status === 200) return xhr.responseText;
|
||||
else throw "Could not load screen.js";
|
||||
}
|
||||
```
|
||||
|
||||
Then you can use it in your code like this:
|
||||
|
||||
```python
|
||||
import screen as s
|
||||
|
||||
def draw():
|
||||
s.cls(0)
|
||||
s.text(20, 20, "Hello World!", 3)
|
||||
|
||||
s.start({
|
||||
"loop":{
|
||||
"draw":draw
|
||||
}
|
||||
})
|
||||
```
|
||||
Reference in New Issue
Block a user