T34坦克大戰-001


 

import pygame
from pygame.locals import *
import sys

windows_width = 640
windows_height = 640

pygame.init()
screen = pygame.display.set_mode((windows_width,windows_height))
pygame.display.set_caption("坦克大戰(T-34)")
bg_img = pygame.image.load("./resources/images/tank-bg.jpg")
bg_img = pygame.transform.scale(bg_img,(windows_width,windows_height))
screen.blit(bg_img, (0, 0))

logo_img = pygame.image.load("./resources/images/tank-logo.png")
screen.blit(logo_img, (10, 10))


#設置首頁文本
title_font = pygame.font.Font("./resources/font/myfont.ttf",windows_width//4)
choice_font = pygame.font.Font("./resources/font/myfont.ttf",windows_width//10)
title = title_font.render(u"坦克大戰",True,(255,0,0))
content1 = choice_font.render(u"按1鍵進入單人遊戲",True,(205,10,30))
content2 = choice_font.render(u"按2鍵進入雙人遊戲",True,(205,10,30))

t_rect = title.get_rect()
t_rect.midtop = (windows_width/2, windows_height/4)
c1_rect = content1.get_rect()
c1_rect.midtop = (windows_width/2, windows_height/1.6)
c2_rect = content2.get_rect()
c2_rect.midtop = (windows_width/2, windows_height/1.3)

screen.blit(title,t_rect)
screen.blit(content1,c1_rect)
screen.blit(content2,c2_rect)
pygame.display.update()

#玩家
player_num = -1
while True:
    for event in pygame.event.get():
        if event.type == QUIT:
            pygame.quit()
            sys.exit()
        elif event.type == KEYDOWN:
            if event.key == K_ESCAPE:
                pygame.quit()
                sys.exit()
            elif event.key == K_1:
                player_num = 1
            elif event.key == K_2:
                player_num = 2

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章