今天我用python完成了一个小游戏,pie游戏是一个非常简单的小游戏,pie游戏使用Pygame模块绘制填充的饼块,用户按下与该饼块对应的数字键。然后使用Pygame的绘制函数来绘制饼块。当按下针对所有饼块的按键而没有犯错的时候,玩家就获胜了。如图所示:
话不多说,直接上代码吧!
import pygame
import math
import sys
from pygame.locals import *
pygame.init()
screen = pygame.display.set_mode((600, 500))
pygame.display.set_caption("The Pie Game - Press 1,2,3,4")
myfont = pygame.font.Font(None, 60)
color = 200, 80, 60
x = 300
y = 250
radius = 200
position = x-radius, y-radius, radius*2, radius*2
width =