当前位置:   article > 正文

Pyglet 游戏制作跟随鼠标移动和旋转的精灵_pyglet 物体 固定位置 旋转

pyglet 物体 固定位置 旋转
  1. import pyglet
  2. from datetime import datetime
  3. WIDTH = 960
  4. HEIGHT = 720
  5. window = pyglet.window.Window(WIDTH,HEIGHT)
  6. background_pattern= pyglet.image.SolidColorImagePattern(color=(255,255,255,255))
  7. background_image = background_pattern.create_image(WIDTH,HEIGHT)
  8. pattern = pyglet.image.SolidColorImagePattern(color=(200,200,130,150))
  9. image = pattern.create_image(150,150)
  10. image.anchor_x = image.width//2
  11. image.anchor_y = image.height//2
  12. ball = pyglet.sprite.Sprite(image, x=100, y=200)
  13. ball.opacity= 200
  14. @window.event
  15. def on_draw():
  16. window.clear()
  17. background_image.blit(0,0)
  18. image.blit(0,0)
  19. ball.draw()
  20. @window.event
  21. def on_mouse_release(x,y,button,modifier):
  22. print(x,y,button,modifier)
  23. @window.event
  24. def on_mouse_motion(x,y,dx,dy):
  25. ball.x=x
  26. ball.y=y
  27. def callback(dt):
  28. #print(f"{dt} seconds since last callback")
  29. s = datetime.now().second
  30. ball.rotation += 1
  31. pyglet.clock.schedule_interval(callback,1/60)
  32. pyglet.app.run()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/585674
推荐阅读
相关标签
  

闽ICP备14008679号