Python pygame.Surface() Examples

The following are 30 code examples of pygame.Surface(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pygame , or try the search function .
Example #1
Source File: polygon.py    From kvae with MIT License 9 votes vote down vote up
def __init__(self, dt=0.2, res=(32, 32), init_pos=(3, 3), init_std=0, wall=None):
        pygame.init()

        self.dt = dt
        self.res = res
        if os.environ.get('SDL_VIDEODRIVER', '') == 'dummy':
            pygame.display.set_mode(res, 0, 24)
            self.screen = pygame.Surface(res, pygame.SRCCOLORKEY, 24)
            pygame.draw.rect(self.screen, (0, 0, 0), (0, 0, res[0], res[1]), 0)
        else:
            self.screen = pygame.display.set_mode(res, 0, 24)
        self.gravity = (0.0, 0.0)
        self.initial_position = init_pos
        self.initial_std = init_std
        self.space = pymunk.Space()
        self.space.gravity = self.gravity
        self.draw_options = pymunk.pygame_util.DrawOptions(self.screen)
        self.clock = pygame.time.Clock()
        self.wall = wall
        self.static_lines = None

        self.dd = 2 
Example #2
Source File: no_rendering_mode.py    From scenario_runner with MIT License 7 votes vote down vote up
def __init__(self):
        def make_surface(tl):
            w = 40
            surface = pygame.Surface((w, 3 * w), pygame.SRCALPHA)
            surface.fill(COLOR_ALUMINIUM_5 if tl != 'h' else COLOR_ORANGE_2)
            if tl != 'h':
                hw = int(w / 2)
                off = COLOR_ALUMINIUM_4
                red = COLOR_SCARLET_RED_0
                yellow = COLOR_BUTTER_0
                green = COLOR_CHAMELEON_0
                pygame.draw.circle(surface, red if tl == tls.Red else off, (hw, hw), int(0.4 * w))
                pygame.draw.circle(surface, yellow if tl == tls.Yellow else off, (hw, w + hw), int(0.4 * w))
                pygame.draw.circle(surface, green if tl == tls.Green else off, (hw, 2 * w + hw), int(0.4 * w))
            return pygame.transform.smoothscale(surface, (15, 45) if tl != 'h' else (19, 49))
        self._original_surfaces = {
            'h': make_surface('h'),
            tls.Red: make_surface(tls.Red),
            tls.Yellow: make_surface(tls.Yellow),
            tls.Green: make_surface(tls.Green),
            tls.Off: make_surface(tls.Off),
            tls.Unknown: make_surface(tls.Unknown)
        }
        self.surfaces = dict(self._original_surfaces) 
Example #3
Source File: box.py    From kvae with MIT License 7 votes vote down vote up
def __init__(self, dt=0.2, res=(32, 32), init_pos=(3, 3), init_std=0, wall=None, gravity=(0.0, 0.0)):
        pygame.init()

        self.dt = dt
        self.res = res
        if os.environ.get('SDL_VIDEODRIVER', '') == 'dummy':
            pygame.display.set_mode(res, 0, 24)
            self.screen = pygame.Surface(res, pygame.SRCCOLORKEY, 24)
            pygame.draw.rect(self.screen, (0, 0, 0), (0, 0, res[0], res[1]), 0)
        else:
            self.screen = pygame.display.set_mode(res, 0, 24)
        self.gravity = gravity
        self.initial_position = init_pos
        self.initial_std = init_std
        self.space = pymunk.Space()
        self.space.gravity = self.gravity
        self.draw_options = pymunk.pygame_util.DrawOptions(self.screen)
        self.clock = pygame.time.Clock()
        self.wall = wall
        self.static_lines = None

        self.dd = 2 
Example #4
Source File: Game12.py    From Games with MIT License 6 votes vote down vote up
def loadLevel(self, game_level):
		with open(os.path.join(self.levels_path, game_level), 'r') as f:
			lines = f.readlines()
		# 游戏地图
		self.game_map = gameMap(max([len(line) for line in lines]) - 1, len(lines))
		# 游戏surface
		height = Config.get('block_size') * self.game_map.num_rows
		width = Config.get('block_size') * self.game_map.num_cols
		self.game_surface = pygame.Surface((width, height))
		self.game_surface.fill(Config.get('bg_color'))
		self.game_surface_blank = self.game_surface.copy()
		for row, elems in enumerate(lines):
			for col, elem in enumerate(elems):
				if elem == 'p':
					self.player = pusherSprite(col, row)
				elif elem == '*':
					self.game_map.addElement('wall', col, row)
				elif elem == '#':
					self.game_map.addElement('box', col, row)
				elif elem == 'o':
					self.game_map.addElement('target', col, row) 
Example #5
Source File: CHOICE.py    From Games with MIT License 6 votes vote down vote up
def __init__(self, position=(400, 300)):
		pygame.sprite.Sprite.__init__(self)
		self.img_1 = pygame.Surface((285, 100))
		self.img_1_front = pygame.Surface((281, 96))
		self.img_1.fill((255, 255, 255))
		self.img_1_front.fill((0, 0, 0))
		self.img_1.blit(self.img_1_front, (2, 2))
		self.img_2 = pygame.Surface((285, 100))
		self.img_2_front = pygame.Surface((281, 96))
		self.img_2.fill((255, 255, 255))
		self.img_2_front.fill((24, 30, 196))
		self.img_2.blit(self.img_2_front, (2, 2))
		self.text = 'medium'
		self.font = pygame.font.Font('./resource/fonts/m04.ttf', 42)
		self.textRender = self.font.render(self.text, 1, (255, 255, 255))
		self.img_1.blit(self.textRender, (15, 29))
		self.img_2.blit(self.textRender, (15, 29))
		self.image = self.img_1
		self.rect = self.image.get_rect()
		self.rect.center = position 
Example #6
Source File: CHOICE.py    From Games with MIT License 6 votes vote down vote up
def __init__(self, position=(400, 150)):
		pygame.sprite.Sprite.__init__(self)
		self.img_1 = pygame.Surface((285, 100))
		self.img_1_front = pygame.Surface((281, 96))
		self.img_1.fill((255, 255, 255))
		self.img_1_front.fill((0, 0, 0))
		self.img_1.blit(self.img_1_front, (2, 2))
		self.img_2 = pygame.Surface((285, 100))
		self.img_2_front = pygame.Surface((281, 96))
		self.img_2.fill((255, 255, 255))
		self.img_2_front.fill((24, 196, 40))
		self.img_2.blit(self.img_2_front, (2, 2))
		self.text = 'easy'
		self.font = pygame.font.Font('./resource/fonts/m04.ttf', 42)
		self.textRender = self.font.render(self.text, 1, (255, 255, 255))
		self.img_1.blit(self.textRender, (60, 29))
		self.img_2.blit(self.textRender, (60, 29))
		self.image = self.img_1
		self.rect = self.image.get_rect()
		self.rect.center = position 
Example #7
Source File: scene.py    From Games with MIT License 6 votes vote down vote up
def __init__(self, imagepath, position, size=(11, 13), is_highest=False, bg_color=None, **kwargs):
		pygame.sprite.Sprite.__init__(self)
		# 导入图片
		self.images = []
		image = pygame.image.load(imagepath)
		for i in range(12):
			self.images.append(pygame.transform.scale(image.subsurface((i*20, 0), (20, 24)), size))
		if is_highest:
			self.image = pygame.Surface((size[0]*8, size[1]))
		else:
			self.image = pygame.Surface((size[0]*5, size[1]))
		self.rect = self.image.get_rect()
		self.rect.left, self.rect.top = position
		# 一些必要的变量
		self.is_highest = is_highest
		self.bg_color = bg_color
		self.score = '00000' 
Example #8
Source File: pyrpg27.py    From pygame with MIT License 5 votes vote down vote up
def __init__(self):
        pygame.init()
        # フルスクリーン化 + Hardware Surface使用
        self.screen = pygame.display.set_mode(SCR_RECT.size, DOUBLEBUF|HWSURFACE|FULLSCREEN)
        pygame.display.set_caption(u"PyRPG 27 戦闘画面")
        # サウンドをロード
        self.load_sounds("data", "sound.dat")
        # キャラクターチップをロード
        self.load_charachips("data", "charachip.dat")
        # マップチップをロード
        self.load_mapchips("data", "mapchip.dat")
        # パーティの作成
        self.party = Party()
        player1 = Player("swordman_female", (3,5), DOWN, True, self.party)
        player2 = Player("elf_female2", (3,4), DOWN, False, self.party)
        player3 = Player("priestess", (3,3), DOWN, False, self.party)
        player4 = Player("magician_female", (3,2), DOWN, False, self.party)
        self.party.add(player1)
        self.party.add(player2)
        self.party.add(player3)
        self.party.add(player4)
        # マップの作成
        self.map = Map("field", self.party)
        # メッセージエンジン
        self.msg_engine = MessageEngine()
        # メッセージウィンドウ
        self.msgwnd = MessageWindow(Rect(140,334,360,140), self.msg_engine)
        # コマンドウィンドウ
        self.cmdwnd = CommandWindow(Rect(16,16,216,160), self.msg_engine)
        # タイトル画面
        self.title = Title(self.msg_engine)
        # 戦闘画面
        self.battle = Battle(self.msgwnd, self.msg_engine)
        # メインループを起動
        global game_state
        game_state = TITLE
        self.mainloop() 
Example #9
Source File: core.py    From gaige with MIT License 5 votes vote down vote up
def __init__(self, points, color = (0, 0, 0), linewidth = 4, sprite = None):
		Obstacle.__init__(self)
		minpt = ( min(map(lambda p: p[0], points)), min(map(lambda p: p[1], points)) )
		maxpt = ( max(map(lambda p: p[0], points)), max(map(lambda p: p[1], points)) )
		# create surface
		s = pygame.Surface((maxpt[0]+linewidth, maxpt[1]+linewidth), pygame.SRCALPHA, 32)
		s = s.convert_alpha()
		pygame.draw.lines(s, color, True, points, linewidth)
		self.surface = s
		self.rect = s.get_rect()
		#transpoints = []
		#for p in points:
		#	transpoints.append((p[0] + self.pos[0], p[1] + self.pos[1]))
		#self.points = transpoints
		self.points = points
		# compute lines
		lines = []
		last = None
		for p in points:
			if last != None:
				lines.append((last, p))
			last = p
		lines.append((points[len(points)-1], points[0]))
		self.lines = lines
		# Decorations
		self.decorations = []
		self.sprites = pygame.sprite.RenderPlain()
		if sprite is not None:
			dec = Decoration(sprite, (0, 0))
			pos = (0, 0)
			for x in xrange((self.rect.width*2)/dec.rect.width):
				for y in xrange((self.rect.height*2)/dec.rect.height):
					pos = (((x/2)*dec.rect.width)+corerandom.uniform(0, dec.rect.width/5.0), ((y/2)*dec.rect.height)+corerandom.uniform(0, dec.rect.height/5.0))
					orient = corerandom.uniform(0, 360.0)
					if pointInsidePolygonPoints((pos[0]+dec.rect.width/2.0, pos[1]+dec.rect.height/2.0), points):
						d = Decoration(sprite, pos, orient)
						self.decorations.append(d)
						self.sprites.add(d)

	### Draw me 
Example #10
Source File: pyrpg24.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #11
Source File: pyrpg18.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #12
Source File: load_map.py    From pygame with MIT License 5 votes vote down vote up
def __init__(self, filename):
        # スプライトグループの登録
        self.all = pygame.sprite.RenderUpdates()
        self.blocks = pygame.sprite.Group()
        Python.containers = self.all
        Block.containers = self.all, self.blocks
        
        # プレイヤーの作成
        self.python = Python((300,200), self.blocks)
        
        # マップをロードしてマップ内スプライトの作成
        self.load(filename)
        
        # マップサーフェイスを作成
        self.surface = pygame.Surface((self.col*self.GS, self.row*self.GS)).convert() 
Example #13
Source File: invader06.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image, n):
    """横に長いイメージを同じ大きさのn枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    image_list = []
    w = image.get_width()
    h = image.get_height()
    w1 = w / n
    for i in range(0, w, w1):
        surface = pygame.Surface((w1,h))
        surface.blit(image, (0,0), (i,0,w1,h))
        surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
        surface.convert()
        image_list.append(surface)
    return image_list 
Example #14
Source File: invader04.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image, n):
    """横に長いイメージを同じ大きさのn枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    image_list = []
    w = image.get_width()
    h = image.get_height()
    w1 = w / n
    for i in range(0, w, w1):
        surface = pygame.Surface((w1,h))
        surface.blit(image, (0,0), (i,0,w1,h))
        surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
        surface.convert()
        image_list.append(surface)
    return image_list 
Example #15
Source File: dirty_rect.py    From pygame with MIT License 5 votes vote down vote up
def main():
    pygame.init()
    screen = pygame.display.set_mode(SCR_RECT.size)
    pygame.display.set_caption(u"スプライトグループの使い方2")
    
    # スプライトグループを作成してスプライトクラスに割り当て
    group = pygame.sprite.RenderUpdates()
    MySprite.containers = group
    
    # スプライトを作成
    python1 = MySprite("python.png", 0, 0, 2, 2)
    python2 = MySprite("python.png", 10, 10, 5, 5)
    python3 = MySprite("python.png", 320, 240, -2, 3)
    
    clock = pygame.time.Clock()
    
    # 背景の作成と描画(背景は最初に1回だけ描画)
    background = pygame.Surface(SCR_RECT.size)
    background.fill((0,0,255))
    screen.blit(background, (0,0))
    pygame.display.update()
    
    while True:
        clock.tick(60)  # 60fps
        # 背景の全体描画はしない!
        # screen上のSpriteを背景で消去
        group.clear(screen, background)
        # スプライトグループを更新
        group.update()
        # スプライトグループを描画
        # RenderUpdateのdraw()は変化があった部分の矩形(dirty rect)を返す
        dirty_rects = group.draw(screen)
        # updateにdirty rectを渡すとその部分だけ更新するので効率よい
        pygame.display.update(dirty_rects)
        for event in pygame.event.get():
            if event.type == QUIT:
                sys.exit() 
Example #16
Source File: chara_anime.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """32x128のキャラクターイメージを32x32の4枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, 32):
        surface = pygame.Surface((32,32))
        surface.blit(image, (0,0), (i,0,32,32))
        surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
        surface.convert()
        imageList.append(surface)
    return imageList 
Example #17
Source File: core.py    From gaige with MIT License 5 votes vote down vote up
def __init__(self, points, color = (0, 0, 0), linewidth = 4, sprite = None):
		Obstacle.__init__(self)
		minpt = ( min(map(lambda p: p[0], points)), min(map(lambda p: p[1], points)) )
		maxpt = ( max(map(lambda p: p[0], points)), max(map(lambda p: p[1], points)) )
		# create surface
		s = pygame.Surface((maxpt[0]+linewidth, maxpt[1]+linewidth), pygame.SRCALPHA, 32)
		s = s.convert_alpha()
		pygame.draw.lines(s, color, True, points, linewidth)
		self.surface = s
		self.rect = s.get_rect()
		#transpoints = []
		#for p in points:
		#	transpoints.append((p[0] + self.pos[0], p[1] + self.pos[1]))
		#self.points = transpoints
		self.points = points
		# compute lines
		lines = []
		last = None
		for p in points:
			if last != None:
				lines.append((last, p))
			last = p
		lines.append((points[len(points)-1], points[0]))
		self.lines = lines
		# Decorations
		self.decorations = []
		self.sprites = pygame.sprite.RenderPlain()
		if sprite is not None:
			dec = Decoration(sprite, (0, 0))
			pos = (0, 0)
			for x in xrange((self.rect.width*2)/dec.rect.width):
				for y in xrange((self.rect.height*2)/dec.rect.height):
					pos = (((x/2)*dec.rect.width)+corerandom.uniform(0, dec.rect.width/5.0), ((y/2)*dec.rect.height)+corerandom.uniform(0, dec.rect.height/5.0))
					orient = corerandom.uniform(0, 360.0)
					if pointInsidePolygonPoints((pos[0]+dec.rect.width/2.0, pos[1]+dec.rect.height/2.0), points):
						d = Decoration(sprite, pos, orient)
						self.decorations.append(d)
						self.sprites.add(d)

	### Draw me 
Example #18
Source File: pyrpg20.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #19
Source File: pyrpg27.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #20
Source File: pyrpg19.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #21
Source File: pyrpg26.py    From pygame with MIT License 5 votes vote down vote up
def __init__(self):
        pygame.init()
        # フルスクリーン化 + Hardware Surface使用
        self.screen = pygame.display.set_mode(SCR_RECT.size, DOUBLEBUF|HWSURFACE|FULLSCREEN)
        pygame.display.set_caption(u"PyRPG 26 ゲーム状態の導入")
        # サウンドをロード
        self.load_sounds("data", "sound.dat")
        # キャラクターチップをロード
        self.load_charachips("data", "charachip.dat")
        # マップチップをロード
        self.load_mapchips("data", "mapchip.dat")
        # パーティの作成
        self.party = Party()
        player1 = Player("swordman_female", (3,5), DOWN, True, self.party)
        player2 = Player("elf_female2", (3,4), DOWN, False, self.party)
        player3 = Player("priestess", (3,3), DOWN, False, self.party)
        player4 = Player("magician_female", (3,2), DOWN, False, self.party)
        self.party.add(player1)
        self.party.add(player2)
        self.party.add(player3)
        self.party.add(player4)
        # マップの作成
        self.map = Map("field", self.party)
        # メッセージエンジン
        self.msg_engine = MessageEngine()
        # メッセージウィンドウ
        self.msgwnd = MessageWindow(Rect(140,334,360,140), self.msg_engine)
        # コマンドウィンドウ
        self.cmdwnd = CommandWindow(Rect(16,16,216,160), self.msg_engine)
        # タイトル画面
        self.title = Title(self.msg_engine)
        # メインループを起動
        self.game_state = TITLE
        self.mainloop() 
Example #22
Source File: pyrpg26.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #23
Source File: pyrpg08.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #24
Source File: pyrpg23.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #25
Source File: pyrpg17.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #26
Source File: pyrpg07.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #27
Source File: pyrpg06.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #28
Source File: pyrpg09.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #29
Source File: pyrpg10.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList 
Example #30
Source File: pyrpg22.py    From pygame with MIT License 5 votes vote down vote up
def split_image(image):
    """128x128のキャラクターイメージを32x32の16枚のイメージに分割
    分割したイメージを格納したリストを返す"""
    imageList = []
    for i in range(0, 128, GS):
        for j in range(0, 128, GS):
            surface = pygame.Surface((GS,GS))
            surface.blit(image, (0,0), (j,i,GS,GS))
            surface.set_colorkey(surface.get_at((0,0)), RLEACCEL)
            surface.convert()
            imageList.append(surface)
    return imageList