猫史档案馆


【Python作品分享】石头剪刀布【作品秀】

用户:枪神枪神查看:0 回复:0 评论:0 创建时间:2019-11-08T21:31:46


【作品展示】

center_image

 

【作品介绍】

(x-1209)*20=677

 

【作品源代码】

import pygame,sys,random
from pygame.locals import *
class shitou(object):
    def __init__(self):
        self.st = pygame.image.load("1.png").convert_alpha()
        self.st_rect = self.st.get_rect()
        self.st_rect2 = self.st.get_rect()
        self.st_rect.left,self.st_rect.top = 6,454
        self.st_rect2.left, self.st_rect2.top = 6, 454
        self.s = 0
        self.s2 = False
class jd(object):
    def __init__(self):
        self.jd = pygame.image.load("2.png").convert_alpha()
        self.jd_rect = self.jd.get_rect()
        self.jd_rect2 = self.jd.get_rect()
        self.jd_rect.left,self.jd_rect.top = 150,454
        self.jd_rect2.left, self.jd_rect2.top = 150, 454
        self.j = 0
        self.j2 = False
class bu(object):
    def __init__(self):
        self.bu = pygame.image.load("3.png").convert_alpha()
        self.bu_rect = self.bu.get_rect()
        self.bu_rect2 = self.bu.get_rect()
        self.bu_rect.left, self.bu_rect.top = 290, 454
        self.bu_rect2.left, self.bu_rect2.top = 290, 454
        self.b = 0
        self.b2 = False
pygame.init()
screen = pygame.display.set_mode((540,喵0))
v= pygame.image.load("开始.png").convert_alpha()
vpos = v.get_rect()
vpos.left,vpos.top = 200,400
shitou  = shitou()
jd = jd()
bu = bu()
w=0
d = 0
play = False
while True:
    for e in pygame.event.get():
        if e.type == QUIT:
            sys.exit()
        pos = pygame.mouse.get_pos()
        if vpos.left < pos[0] < vpos.right and \
            vpos.top < pos[1] < vpos.bottom:
            if e.type ==MOUSEBUTTONDOWN:
                play = True

    screen.fill((255,255,255))
    if not play:
        screen.blit(v,(vpos.left,vpos.top))
    else:
        screen.blit(shitou.st,(shitou.st_rect.left,shitou.st_rect.top))
        screen.blit(jd.jd, (jd.jd_rect.left, jd.jd_rect.top))
        screen.blit(bu.bu, (bu.bu_rect.left, bu.bu_rect.top))
        screen.blit(shitou.st,(shitou.st_rect2.left,shitou.st_rect2.top-500))
        screen.blit(jd.jd, (jd.jd_rect2.left, jd.jd_rect2.top-500))
        screen.blit(bu.bu, (bu.bu_rect2.left, bu.bu_rect2.top-500))
        if shitou.st_rect.left < pos[0] < shitou.st_rect.right and \
            shitou.st_rect.top < pos[1] < shitou.st_rect.bottom:
            if e.type ==MOUSEBUTTONDOWN:
                shitou.s += 1
                pygame.time.wait(300)
        if jd.jd_rect.left < pos[0] < jd.jd_rect.right and \
            jd.jd_rect.top < pos[1] < jd.jd_rect.bottom:
            if e.type ==MOUSEBUTTONDOWN:
                jd.j += 1
                pygame.time.wait(300)
        if bu.bu_rect.left < pos[0] < bu.bu_rect.right and \
            bu.bu_rect.top < pos[1] < bu.bu_rect.bottom:
            if e.type ==MOUSEBUTTONDOWN:
                bu.b += 1
                pygame.time.wait(300)
        if shitou.s == 1:
            shitou.st_rect.top = 340
            if w == 0:
                d = random.randint(1,3)
                w = 1
            jd.j = 0
            bu.b = 0
            shitou.st_rect.top = 340
        if shitou.s == 2:
            shitou.s = 0
            shitou.st_rect.top = 454
            d = 0
        if jd.j == 1:
            jd.jd_rect.top = 340
            if w==0:
                d = random.randint(1,3)
                w=1
            shitou.s = 0
            bu.b = 0
        if jd.j == 2:
            jd.j = 0
            jd.jd_rect.top = 454
            d = 0
        if bu.b == 1:
            bu.bu_rect.top = 340
            if w == 0:
                d = random.randint(1, 3)
                w = 1
            jd.j = 0
            shitou.s = 0
        if bu.b == 2:
            bu.bu_rect.top = 454
            bu.b = 0
            d = 0
        if d == 1:
            shitou.s2 = True
        if d == 2:
            jd.j2 = True
        if d == 3:
            bu.b2 = True
        if d==0:
            bu.b2 = False
            jd.j2 = False
            w=0
            shitou.s2 = False
        if bu.b2:
            bu.bu_rect2.top = 600
        if jd.j2:
            jd.jd_rect2.top = 600
        if shitou.s2:
            shitou.st_rect2.top = 600
        if not bu.b2:
            bu.bu_rect2.top = 454
        if not jd.j2:
            jd.jd_rect2.top = 454
        if not shitou.s2:
            shitou.st_rect2.top = 454
    pygame.display.update()

 

【提示】

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

https://python.codemao.cn


回复

上一页1 页 / 共 0下一页