particle習作(pygame)

proce55ingで作ろうとしましたが、画像のアルファがうまく出来なかったので、pygame

# -*- coding:sjis -*-
# http://sansa.s16.xrea.com/text/pygame_sample.html
# http://mail.unixuser.org/~euske/doc/pygame/ChimpLineByLine-j.html
import pygame, sys
from pygame.locals import *


class snow:
    def __init__(self, ax, ay, aimage):
        self.x = ax
        self.y = ay
        self.image = aimage
    def disp(self, screen):
        screen.blit(image, (self.x, self.y))

pygame.init()
screen = pygame.display.set_mode((640, 480))
clock = pygame.time.Clock()
image = pygame.image.load("light.png")        # 画像の読み込み
background = pygame.Surface(screen.get_size())
background = background.convert()
sn = []
for i in range(10):
    sn.append(snow(i*10, i*10, image))

while 1:
    clock.tick(60)

    for event in pygame.event.get():
        if event.type == QUIT:
            sys.exit()

    background.fill((0, 0, 0))
    for i in range(10):
        sn[i].disp(background)
    screen.blit(background, (0,0))        # 画面に画像をコピー
    pygame.display.flip()        # 画面への変更を反映
  • 結果