Add Examples
57
Examples.md
Normal file
57
Examples.md
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# Examples
|
||||||
|
|
||||||
|
### Hello World!
|
||||||
|
```python
|
||||||
|
import screen as s
|
||||||
|
|
||||||
|
def draw():
|
||||||
|
s.cls(0)
|
||||||
|
s.text(20, 20, "Hello World!", 3)
|
||||||
|
|
||||||
|
s.start({
|
||||||
|
"loop":{
|
||||||
|
"draw":draw
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Falling ball
|
||||||
|
```python
|
||||||
|
import screen as s
|
||||||
|
|
||||||
|
bg = 0
|
||||||
|
color = 3
|
||||||
|
radius = 0
|
||||||
|
posx = 0
|
||||||
|
posy = 0
|
||||||
|
|
||||||
|
def init():
|
||||||
|
global radius, posx, posy
|
||||||
|
radius = s.W / 10
|
||||||
|
posx = s.W / 2
|
||||||
|
posy = s.H / 2
|
||||||
|
|
||||||
|
def tapped(x, y, id):
|
||||||
|
global posx, posy
|
||||||
|
posx = x
|
||||||
|
posy = y
|
||||||
|
|
||||||
|
def update():
|
||||||
|
global posy
|
||||||
|
posy += 200 * s.DT
|
||||||
|
|
||||||
|
def draw():
|
||||||
|
global radius, posx, posy, color, bg
|
||||||
|
s.cls(bg)
|
||||||
|
s.circfill(posx, posy, radius, color)
|
||||||
|
s.text(10, 10, 'Tap anywhere', 3)
|
||||||
|
|
||||||
|
s.start({
|
||||||
|
"loop":{
|
||||||
|
"init":init,
|
||||||
|
"draw":draw,
|
||||||
|
"tapped":tapped,
|
||||||
|
"update":update
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user