|
楼主 |
发表于 2016-11-14 00:14:33
|
显示全部楼层
有道 自动翻译了.... 尴尬...等下..
import pygame
import sys
from pygame.locals import *
from random import *
import traceback
pygame.init()
pygame.mixer.init()
color=(255,255,255)
#背景音乐 和 音效音乐
A = pygame.mixer.Sound("sound/A.wav")
A.set_volume(0.2)
B = pygame.mixer.Sound("sound/B.wav")
B.set_volume(0.2)
C = pygame.mixer.Sound("sound/C.wav")
C.set_volume(0.2)
D = pygame.mixer.Sound("sound/D.wav")
D.set_volume(0.2)
E = pygame.mixer.Sound("sound/E.wav")
E.set_volume(0.2)
F = pygame.mixer.Sound("sound/F.wav")
F.set_volume(0.2)
G = pygame.mixer.Sound("sound/G.wav")
G.set_volume(0.2)
#自己的牌组
Mycard1 = []
Mycard2 = []
Mycard3 = []
#计算机啊牌组
Comcard1 = []
Comcare2 = []
Comcard3 = []
#定义卡牌类
class gamecard():
attack = 0
num = 0
defense = 0
active = True
def __init__(self,attack,defense,num):
self.attack = attack
self.defense =defense
self.num = num
def end(self):
pass
def main():
bg_size = width,height = 1050, 812
screen = pygame.display.set_mode((bg_size))
pygame.display.set_caption("游戏王的游戏!!!~~~~")
background = pygame.image.load("images/background.png").convert()
running = True
while running:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == KEYDOWN:
if event.key == K_a:
A.play()
elif event.key == K_b:
B.play()
elif event.key == K_c:
C.play()
elif event.key == K_d:
D.play()
elif event.key == K_e:
E.play()
elif event.key == K_f:
F.play()
elif event.key == K_g:
G.play()
elif event.key == K_SPACE:
x,y=pygame.mouse.get_pos()
print(x)
print(',')
print(y)
print('\n')
elif event.type == MOUSEBUTTONDOWN:
if event.button==1:
x,y = pygame.mouse.get_pos()
screen.blit(background,(0,0))
pygame.draw.line(screen,color,(0,576),(1050,576),2)
pygame.draw.line(screen,color,(175,576),(175,812),2)
pygame.draw.line(screen,color,(350,576),(350,812),2)
pygame.draw.line(screen,color,(525,576),(525,812),2)
pygame.draw.line(screen,color,(700,576),(700,812),2)
pygame.draw.line(screen,color,(875,576),(875,812),2)
pygame.draw.line(screen,color,(1050,576),(1050,812),2)
pygame.display.flip()
if __name__ == "__main__":
try:
main()
except:
pass. |
|