基础窗口
This commit is contained in:
1 parent
5c91fce9fd
commit
8fba77d1c0
1 file changed
+38
@@ -0,0 +1,38 @@
|
|||||||
|
import pygame
|
||||||
|
|
||||||
|
# 初始化
|
||||||
|
pygame.init()
|
||||||
|
|
||||||
|
# 设置窗口大小
|
||||||
|
window_size = (1920/2, 1080/2)
|
||||||
|
screen = pygame.display.set_mode(window_size)
|
||||||
|
|
||||||
|
# 设置标题
|
||||||
|
pygame.display.set_caption("Test Name")
|
||||||
|
|
||||||
|
rect = [10,20,30,40]
|
||||||
|
black = (0,0,0)
|
||||||
|
white = (255,255,255)
|
||||||
|
|
||||||
|
def update():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# 运行循环
|
||||||
|
running = True
|
||||||
|
while running:
|
||||||
|
# 事件处理
|
||||||
|
for event in pygame.event.get():
|
||||||
|
# 检查是否关闭
|
||||||
|
if event.type == pygame.QUIT:
|
||||||
|
running = False
|
||||||
|
|
||||||
|
screen.fill(black)
|
||||||
|
|
||||||
|
pygame.draw.rect(screen, white, rect)
|
||||||
|
|
||||||
|
# 更新显示
|
||||||
|
pygame.display.update()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in new issue
Block a user