猫史档案馆


【Python作品分享】超级马里奥程序

用户:大胆的蓝雀UC1S大胆的蓝雀UC1S查看:1 回复:1 评论:1 创建时间:2021-01-19T17:44:59


【作品展示】

center_image

 

【作品介绍】

hfsg

 

【作品源代码】

import pygame
import random
pygame.init()
SIZE=WIDTH,HEIGHT=600,406 
pygame.display.set_caption('超级马里奥升级版')
screen = pygame.display.set_mode(SIZE)
bg1=pygame.image.load('images/bg1.png')
bg2=pygame.image.load('images/bg2.png')
g1=pygame.image.load('images/g1.png')
g2=pygame.image.load('images/g2.png')
g3=pygame.image.load('images/g3.png')
m1=pygame.image.load('images/m1.png')
m2=pygame.image.load('images/m2.png')
over=pygame.image.load('images/over.png')
start=pygame.image.load('images/start.png')
class MyMap():
    def __init__(self,x,y,img):
        self.x=x
        self.y=y
        self.img=img
    def paint(self):
        screen.blit(self.img,(self.x,self.y))
    def map_rolling(self):
        if self.x<=-590:
            self.x=600
        else:
            self.x-=2
map1=MyMap(0,0,bg1)
map2=MyMap(600,0,bg2)
class Obstacle():
    def __init__(self):
        self.x=random.randint(600,1000)
        self.y=0
        self.width=50
        self.height=100
        self.img=g1
        n=random.randint(1,3)
        if n==1:
            self.y=260
            self.height=43
            self.img=g1
        elif n==2:
            self.y=240
            self.height=喵
            self.img=g2
        elif n==3:
            self.y=210
            self.height=96
            self.img=g3
    def paint(self):
        screen.blit(self.img,(self.x,self.y))
    def move(self):
        self.x-=2
        if self.x<=-50:
            self.x=random.randint(600, 1000)
            n = random.randint(1, 3)
            if n==1:
                self.y=260
                self.height=43
                self.img=g1
            elif n==2:
                self.y=240
                self.height=喵
                self.img=g2
            elif n == 3:
                self.y=210
                self.height=96
                self.img=g3
O1 = Obstacle()
O2=Obstacle()
O3=Obstacle()
class Marie():
    def __init__(self):
        self.x=
while True:
    map1.paint()
    map2.paint()
    map1.map_rolling()
    map2.map_rolling()
    O1.paint()
    O2.paint()
    O3.paint()
    O1.move()
    O2.move()
    O3.move()
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit()
    pygame.display.update()

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
JaMJaM

谁是因为封面进来的,举个手emotion_doge

点赞0


评论