コード例 #1
0
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
0
ファイル: spritetools.py プロジェクト: mazerj/pype3
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'