forked from pi3d/pi3d_demos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinimal_2d.py
34 lines (32 loc) · 859 Bytes
/
Minimal_2d.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python
from __future__ import absolute_import, division, print_function, unicode_literals
""" Example showing what can be left out. ESC to quit"""
import demo
import pi3d
DISPLAY = pi3d.Display.create(x=50, y=50, frames_per_second=30, display_config=pi3d.DISPLAY_CONFIG_FULLSCREEN)
shader = pi3d.Shader("uv_flat")
CAMERA = pi3d.Camera(is_3d=False)
sprite = pi3d.ImageSprite("textures/PATRN.PNG", shader, w=100.0, h=100.0, z=5.0)
mykeys = pi3d.Keyboard()
xloc = 100.0
dx = 2.1
yloc = 100.0
dy = 1.13
while DISPLAY.loop_running():
sprite.draw()
sprite.rotateIncZ(1)
sprite.position(xloc, yloc, 5.0)
if xloc > 300.0:
dx = -2.1
elif xloc < -300.0:
dx = 2.1
if yloc > 300.0:
dy = -1.13
elif yloc < -300.0:
dy = 1.13
xloc += dx
yloc += dy
if mykeys.read() == 27:
mykeys.close()
DISPLAY.destroy()
break