本文整理汇总了Python中sprite.Sprite.blit方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.blit方法的具体用法?Python Sprite.blit怎么用?Python Sprite.blit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sprite.Sprite
的用法示例。
在下文中一共展示了Sprite.blit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: first_scene
# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import blit [as 别名]
class first_scene(Scene):
raspberry_sprite = None
def load(self):
self.raspberry_sprite = Sprite("art/raspberry35.png")
def cleanup(self):
pass
def do_event(self, event):
pass
def update(self):
self.raspberry_sprite.x = 100
self.raspberry_sprite.y = 100
return
max_x = self.s.size[0] - self.raspberry_sprite.width()
x = random.randint(0, max_x)
max_y = self.s.size[0] - self.raspberry_sprite.height()
y = random.randint(0, max_y)
self.raspberry_sprite.x = x
self.raspberry_sprite.y = y
def draw(self):
self.s.screen.fill((0,0,0))
self.raspberry_sprite.blit(self.s)
示例2: benchmark
# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import blit [as 别名]
def benchmark(fb):
import time
from sprite import Sprite
s = Sprite(250, 250, 0, 0, fb=fb, on=1)
s2 = Sprite(250, 250, 0, 0, fb=fb, on=1)
nmax = 100
t0 = time.time()
for n in range(nmax):
singrat(s, 10, 0.0, n, R=1.0, G=1.0, B=1.0,
meanlum=0.5, moddepth=1.0)
s.blit(flip=1)
time.time()
print 'all', float(nmax) / (time.time() - t0), 'fps'
t0 = time.time()
for n in range(nmax):
singrat(s, 10, 0.0, n, R=1.0, G=1.0, B=1.0,
meanlum=0.5, moddepth=1.0)
time.time()
print 'compute only', float(nmax) / (time.time() - t0), 'fps'
s2 = Sprite(250, 250, 0, 0, fb=fb, on=1)
singrat(s2, 10, 0.0, 0, R=1.0, G=1.0, B=1.0,
meanlum=0.5, moddepth=1.0)
foo = s2.array[::]
bar = s2.array[::]
t0 = time.time()
for n in range(nmax):
foo[::] = bar[::]
s.blit(flip=1)
time.time()
print 'copy+blit', float(nmax) / (time.time() - t0), 'fps'
t0 = time.time()
for n in range(nmax):
s.blit(flip=1)
time.time()
print 'blit only', float(nmax) / (time.time() - t0), 'fps'