python版羊了个羊

最近用python做了个羊了个羊,项目链接

项目源代码如下:

#导入头文件
import pygame
from pygame import *
pygame.init()
from sys import exit
from random import randint
from collections import Counter
import msvcrt

#定义开始界面
class Start():
    #初始化
    def __init__(self):
        #创建窗口
        self.startSurface=pygame.display.set_mode((300,500))
        #设置标题
        pygame.display.set_caption("weather game")
        #设置图标
        ico=pygame.image.load("ico\\0.ico")
        pygame.display.set_icon(ico)

        #显示背景
        self.bg=pygame.transform.scale(pygame.image.load("img\\bg\\bg.jpg"),(300,500))
        self.startSurface.blit(self.bg,(0,0))
        
        #导入字体文件
        self.font=pygame.font.Font("font\\VladimirScript.ttf",32)
        self.bigFont=pygame.font.Font("font\\VladimirScript.ttf",60)
        self.fontColor=pygame.Color((0,0,0))
        
        #创建文字对象
        weathergameText=self.bigFont.render("weather game",True,self.fontColor)
        #创建文字显示框
        weathergameTextRect=weathergameText.get_rect(center=(150,50))
        #显示文字
        self.startSurface.blit(weathergameText,weathergameTextRect)
        
        #显示开始游戏
        startText=self.font.render("Start the game",True,self.fontColor)
        startTextRect=startText.get_rect(center=(150,420))
        self.startSurface.blit(startText,startTextRect)
        #获取文字显示框坐标
        self.startTextX=startTextRect[0]
        self.startTextY=startTextRect[1]
        self.startTextX1=startTextRect[0]+startTextRect[2]
        self.startTextY1=startTextRect[1]+startTextRect[3]
        
        #显示结束游戏
        exitText=self.font.render("Exit",True,self.fontColor)
        exitTextRect=exitText.get_rect(center=(150,460))
        self.startSurface.blit(exitText,exitTextRect)
        self.exitTextX=exitTextRect[0]
        self.exitTextY=exitTextRect[1]
        self.exitTextX1=exitTextRect
  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值