おお! なんとか画像を動かすことができた!
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pyglet
window = pyglet.window.Window(width=600, height=240, caption='Sprite animation')
usa_image = pyglet.resource.image('usa.png')
usa_image.anchor_x = usa_image.width / 2
usa_image.anchor_y = usa_image.height / 2
usa_sprite = pyglet.sprite.Sprite(img=usa_image, x=30, y=90)
@window.event
def on_draw():
window.clear()
usa_sprite.draw()
def update(dt):
usa_sprite.rotation += dt * 360
usa_sprite.x += dt * 70
pyglet.clock.schedule_interval(update, 0.03)
pyglet.app.run()
これを実行すると
こんな感じになった
キーイベントに抱き合わせればキャラクターを動かせるかも....
もう少し調べてみよう!
#!/usr/bin/python
# -*- coding: utf-8 -*-
import pyglet
window = pyglet.window.Window(width=600, height=240, caption='Sprite animation')
usa_image = pyglet.resource.image('usa.png')
usa_image.anchor_x = usa_image.width / 2
usa_image.anchor_y = usa_image.height / 2
usa_sprite = pyglet.sprite.Sprite(img=usa_image, x=30, y=90)
@window.event
def on_draw():
window.clear()
usa_sprite.draw()
def update(dt):
usa_sprite.rotation += dt * 360
usa_sprite.x += dt * 70
pyglet.clock.schedule_interval(update, 0.03)
pyglet.app.run()
これを実行すると
こんな感じになった
キーイベントに抱き合わせればキャラクターを動かせるかも....
もう少し調べてみよう!
0 件のコメント:
コメントを投稿