Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

Administrator / pygame_lesson3_diy3

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Commit 7d859852 authored a month ago by BellCodeEditor's avatar BellCodeEditor
Browse files
Options
  • Browse Files
  • Download
  • Email Patches
  • Plain Diff

save project

parent 4340fa23
Show whitespace changes
Inline Side-by-side
Showing with 53 additions and 1 deletions
  • .idea/.gitignore
  • .idea/inspectionProfiles/profiles_settings.xml
  • .idea/misc.xml
  • .idea/modules.xml
  • .idea/pygame_lesson3_diy3.iml
  • .idea/vcs.xml
  • snake.py
.idea/.gitignore 0 → 100644
View file @ 7d859852
# 默认忽略的文件
/shelf/
/workspace.xml
This diff is collapsed. Click to expand it.
.idea/inspectionProfiles/profiles_settings.xml 0 → 100644
View file @ 7d859852
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
This diff is collapsed. Click to expand it.
.idea/misc.xml 0 → 100644
View file @ 7d859852
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13 (pythonProject)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
This diff is collapsed. Click to expand it.
.idea/modules.xml 0 → 100644
View file @ 7d859852
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pygame_lesson3_diy3.iml" filepath="$PROJECT_DIR$/.idea/pygame_lesson3_diy3.iml" />
</modules>
</component>
</project>
\ No newline at end of file
This diff is collapsed. Click to expand it.
.idea/pygame_lesson3_diy3.iml 0 → 100644
View file @ 7d859852
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.13 (pythonProject)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
This diff is collapsed. Click to expand it.
.idea/vcs.xml 0 → 100644
View file @ 7d859852
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
This diff is collapsed. Click to expand it.
snake.py
View file @ 7d859852
import pygame
import random
from pygame import locals
# 初始化pygame,为使用硬件做准备
......@@ -19,6 +20,8 @@ down = pygame.image.load('down.png') # 头 朝下
x, y = 240, 120
position = [(180, 90), (180, 120), (210, 120), (x, y)]
apple_x = 360 #苹果横坐标
apple_y = 300 #苹果纵坐标
setheading = "right"
snake_head = right
......@@ -52,6 +55,13 @@ while True:
else:
y += 30
position.append((x, y))
#贪吃蛇吃到了苹果
if x == apple_x and y == apple_y:
num1 = random.randint(1, 22) #横排的几个格子
num2 = random.randint(1, 16) #纵排的几个格子
apple_x = 30*num1-30 #苹果的X坐标
apple_y = 30*num2-30 #苹果的Y坐标
else:
position.pop(0)
# 将背景图画上去
screen.blit(background, (0, 0))
......@@ -62,7 +72,8 @@ while True:
screen.blit(body, position[i])
# 将果实画上去
screen.blit(food, (360, 300))
screen.blit(food, (apple_x,apple_y))
# 刷新画面
pygame.display.update()
FPSCLOCK.tick(3)
\ No newline at end of file
This diff is collapsed. Click to expand it.
  • Write
  • Preview
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