-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercice5.py
More file actions
41 lines (26 loc) · 832 Bytes
/
Copy pathexercice5.py
File metadata and controls
41 lines (26 loc) · 832 Bytes
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
35
36
37
38
#!/usr/bin/env python3
from pyglet import window, app, image, sprite
win = window.Window()
logger = window.event.WindowEventLogger()
win.push_handlers(logger)
_image = image.load("assets/images/neon_version.png")
racket = sprite.Sprite(img=_image.get_region(57, 512-331, 147-57,331-302 ))
ball = sprite.Sprite(img = _image.get_region(64,512-143, 16,16))
ball.y = 29
@win.event
def on_mouse_motion(x,y,dx,dy):
print("mouse x=%d, y=%d, dx=%d, dy=%d" % (x, y, dx, dy))
racket.x = x
ball.x = racket.x + racket.width/2 - ball.width/2
@win.event
def on_mouse_press(x,y,button,modifiers):
if window.mouse.LEFT == button:
print("mouse.LEFT")
elif window.mouse.RIGHT == button:
print("mouse.RIGHT")
@win.event
def on_draw():
win.clear()
ball.draw()
racket.draw()
app.run()