Commit d9131627 by BellCodeEditor

save project

parent 16f0d60e
Showing with 93 additions and 6 deletions
...@@ -6,27 +6,60 @@ pygame.init() ...@@ -6,27 +6,60 @@ pygame.init()
# 创建一个窗口 # 创建一个窗口
screen = pygame.display.set_mode((660, 480)) screen = pygame.display.set_mode((660, 480))
FPSCLOCK=pygame.time.Clock()
# 背景 # 背景
background = pygame.image.load('bg.png') background = pygame.image.load('bg.png')
right = pygame.image.load('right.png') right = pygame.image.load('right.png')
food = pygame.image.load('apple.png') food = pygame.image.load('apple.png')
body = pygame.image.load('body.png') body = pygame.image.load('body.png')
left = pygame.image.loud("left.png")
up = pygame.image.loud("up.png")
down = pygame.image.loud("down.png")
x,y=240,120
position = [(180,90),(180,120),(210,120),(x,y)]
while True: while True:
for event in pygame.event.get(): for event in pygame.event.get():
if event.type == locals.QUIT: if event.type == locals.QUIT:
# 接收到退出事件后退出程序 # 接收到退出事件后退出程序
exit() exit()
elif eyent.type == locals.KEYDOWN:
if event.key==locals.K_RIGHT and setheading !="left":
setheading="right"
snake_head= right
if event.key==locals.K_RIGHT and setheading !="right":
setheading="right"
snake_head= right
if event.key==locals.K_RIGHT and setheading !="down":
setheading="up"
snake_head= up
if event.key==locals.K_RIGHT and setheading !="up":
setheading="down"
snake_head= down
if setheading=="right":
x+=30
elif setheading=="left":
x-=30
elif setheading=="up":
y-=30
else:
y+=30
position.append((x,y))
position.pop(0)
# 将背景图画上去 # 将背景图画上去
screen.blit(background, (0, 0)) screen.blit(background, (0, 0))
# 将贪吃蛇画上去 # 将贪吃蛇画上去
screen.blit(right, (240, 120)) screen.blit(right, (x, y))
# 将贪吃蛇的身体画上去 # 将贪吃蛇的身体画上去
screen.blit(body, (210, 120)) for i in range(len(position)-1):
screen.blit(body, (180, 120)) screen.blit(body,position[i])
screen.blit(body, (180, 90))
# 将果实画上去 # 将果实画上去
screen.blit(food, (360, 300)) screen.blit(food, (360, 300))
# 刷新画面 # 刷新画面
pygame.display.update() pygame.display.update()
\ No newline at end of file FPSCLOCK.tick(3)
\ No newline at end of file
!DOCTYPE html><html><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="google" value="notranslate">
<meta itemprop="name" content="&#x5A03;&#x7684;&#x7F16;&#x7A0B;&#x73A9;&#x5F97;&#x8FD9;&#x4E48;&#x6E9C;&#xFF0C;&#x6211;&#x4ECA;&#x5929;&#x624D;&#x77E5;&#x9053;">
<meta itemprop="image" content="https://learning-report.bellcode.com/icon_share.png">
<meta name="description" itemprop="description" content="&#x5B69;&#x5B50;&#x4EA4;&#x7ED9;&#x8D1D;&#x5C14;&#x7F16;&#x7A0B;&#xFF0C;&#x8F7B;&#x677E;&#x953B;&#x70BC;&#x903B;&#x8F91;&#x601D;&#x7EF4;&#xFF01;">
<link rel="shortcut icon" href="static/favicon.ico">
<title>Code Share</title>
<script>((bellcodeGlobalSettings, env, version, env_rc) => {
if (!window.bellcodeGlobalSettings) {
window.bellcodeGlobalSettings = {};
}
window.bellcodeGlobalSettings = {...window.bellcodeGlobalSettings, ...bellcodeGlobalSettings};
window.__VERSION__ = `${env}-${version}`;
window.__bellcode_env__ = env;
window.onload = () => {
//// 如果是灰度环境则加入标记
if (env === env_rc) {
const tagEl = document.createElement("div");
tagEl.innerText = "新";
const styles = {
width: "50px",
height: "50px",
background: "#000",
position: "fixed",
zIndex: "30002",
borderRadius: "50px",
top: "30px",
left: "10px",
cursor: "pointer",
textAlign: "center",
lineHeight: "50px",
color: "#fff"
};
for (let property in styles) {
tagEl.style[property] = styles[property];
}
// window.document.body.append(tagEl);
}
}
})({"settingsOrigins":{"baseDomain":"makcoocode.com","cookieDomain":"makcoocode.com","apiOrigin":"//api.bellcode.com/","homeOrigin":"https://www.makcoocode.com/","ideOrigin":"https://ide.makcoocode.com/","tcOrigin":"https://tc.makcoocode.com/","guiOrigin":"https://gui.makcoocode.com/","lrOrigin":"https://learning-report.makcoocode.com/","paymentOrigin":"https://h5.makcoocode.com/payment/","liveBellCodeHost":"live.bellcode.com","H5Origin":"https://h5.makcoocode.com/","bellplanetIndexURL":"//bg-stage.makcoocode.com/index.html","offcialOrigin":"http://official.bellcode.com/","bellplanetEnv":"release","evaluateReportURL":"https://learning-report.makcoocode.com/index.html"},"hostWhiteList":["codingmonkey.com.cn","wkcoding.com","bellcode.cn","bellcode.com","makcoocode.com","icodee.com","wukonglab.cn","icodeworld.cn"]},"pro","cm_gui/pro/2022031001","rc"); (function(){})();</script></head>
<body>
<script type="text/javascript" src="//other.wkcoding.com/cm_gui/pro/2022031001/lib.min-294a00c1.js"></script><script type="text/javascript" src="//other.wkcoding.com/cm_gui/pro/2022031001/chunks/addition-25115cef.js"></script><script type="text/javascript" src="//other.wkcoding.com/cm_gui/pro/2022031001/chunks/gui-9faa1f0d.js"></script>
</body></html>
\ 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