python编程制作接金币游戏,闪电侠接金币的FlashMan类
python the Flash man catch coin gif animation
閃電俠是美劇,這里是一個小游戲,操作閃電俠接不斷冒出來的金幣。本模塊定義了FlashMan類。這個模塊能單獨運行,運行后用鼠標操作閃電俠移動即可。
以下是部分代碼預覽:
"""
FlashMan類,本程序實現閃電俠類
"""
import math
import time
import pygame
from pygame.locals import *
class FlashMan(pygame.sprite.Sprite):
"""閃電俠類,生成后可由鼠標"""
def __init__(self,rms,lms):
"""
rms:向右造型序列
lms:向左造型序列
"""
self.shapes_right = rms
self.shapes_left = lms
def setshape(self):
"""設置造型"""
def update(self):
"""更新坐標"""
if __name__ == "__main__":
screen = pygame.display.set_mode((960,720))
pygame.display.set_caption("閃電俠接金幣的FlashMan類")
images = [f"im1/flash{i}.png" for i in range(1,4)]
images = [pygame.image.load(im) for im in images]
# 向右造型序列
images_right = [pygame.transform.rotozoom(im,0,0.4) for im in images]
# 向左造型序列
images_left = [pygame.transform.flip(im,True,False) for im in images_right]
bg = pygame.image.load("space.png")
man = FlashMan(images_right,images_left)
clock = pygame.time.Clock()
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:running=False
man.update()
screen.blit(bg,(0,0))
screen.blit(man.image,man.rect)
pygame.display.update()
pygame.quit()
如需要查看完整源代碼,請掃碼付款:
VIP免費查看
當前隱藏內容需要支付
68元
已有3人支付
立即購買
總結
以上是生活随笔為你收集整理的python编程制作接金币游戏,闪电侠接金币的FlashMan类的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么百度统计里面的广告那么多_里面东西
- 下一篇: springboot listener_