Commit 32555455 by BellCodeEditor

save project

parent 126cfcb6
Showing with 1727 additions and 22 deletions
#!/usr/bin/env python
import pygame,sys,time,random import pygame,sys,time,random
from pygame.locals import * from pygame.locals import *
# 定义颜色变量 # 定义颜色变量
...@@ -100,7 +100,7 @@ def main(): ...@@ -100,7 +100,7 @@ def main():
if snakePosition[0] == snakeBody[0] and snakePosition[1] == snakeBody[1]: if snakePosition[0] == snakeBody[0] and snakePosition[1] == snakeBody[1]:
gameOver(playSurface) gameOver(playSurface)
# 控制游戏速度 # 控制游戏速度
fpsClock.tick(10) fpsClock.tick(7)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
import random import random
a=random(0.4) int a
a=random(0,4)
print(a) print(a)
\ No newline at end of file
import pygame import pygame
from pygame import locals
pygame.init()
screen=pygame.display.set_mode((660,480))
background=pygame.image.load('bg.png')
right=pygame.image.load('right.png')
food=pygame.image.load('apple.png')
body=pygame.image.load('body.png')
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
screen.bilt(background,(0,0))
screen.bilt(right,(240,120))
screen.bilt(body,(210,120))
screen.bilt(body,(180,120))
screen.bilt(body,(180,90))
screen.bilt(food,(360,300))
# 初始化pygame,为使用pygame做准备
pygame.init()
pygame.display.update() # 创建一个窗口
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment