
Lv.1
卧薪藏胆某人
签名:一边期盼吉吉喵给权限一边在不属于我的地图上写代码
在 我建议可以制作这种函数 中回复
那请你先去跟Python,C,C++,java,javascript……它们说说(scratch除外),函数功能就是跟他们学的。
2020-06-01T08:59:15 点赞:0
在 【作品分享】经典像素贪吃蛇 中回复
https://shequ.codemao.cn/work/48175547?entry=copy_work_url
2020-06-01T19:11:29 点赞:0
在 Python【编程小讲堂】第六期 easygui干货 中回复
爱因斯坦的弟子~
假如你一每秒200 000千米额速度直线匀速运动,你的一天等于我的几年?
答不上来,你就不是他的弟子哦~
2020-06-14T16:22:39 点赞:0
在 Python【编程小讲堂】第六期 easygui干货 中回复
integerbox怎么没任何效果!完全就是:
def integerbox(……):
while True:
pass
!
2020-06-14T20:13:19 点赞:0
在 【KittenV4.1.1版本更新】超有料!克隆可以按编号识别? 中回复
如果实在别的时候,我不允许技术喵掉一普朗克长度头发;但现在,我需要技术喵掉96 000 000 000光年头发,吧广播改回来!
2020-06-24T09:09:06 点赞:2
在 pygame经典贪吃蛇 中回复
2.0版本新出炉了!
import pygame, sys, time, random
from pygame.key import *
pygame.init()
sceen = pygame.display.set_mode((500, 500))
sce喵5, 255))
pygame.draw.rect(sceen, (0, 0, 0), (0, 0, 500, 500), 100)
pygame.display.flip()
pygame.display.set_caption('经典贪吃蛇游戏即将开始')
class draw:#用来画画的类 #20×20像素为一个格子
def hand(x, y, direction):#画头
pygame.draw.rect(sceen, (85, 85, 85), (x * 20 + 51, y * 20 + 51, 18, 18), 0)#画头
if direction == 'up':#画眼
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 55, y * 20 + 55, 3, 3))
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 62, y * 20 + 55, 3, 3))
elif direction == 'down':
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 55, y * 20 + 62, 3, 3))
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 62, y * 20 + 62, 3, 3))
elif direction == 'left':
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 55, y * 20 + 55, 3, 3))
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 55, y * 20 + 62, 3, 3))
elif direction == 'right':
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 62, y * 20 + 55, 3, 3))
pygame.draw.rect(sceen, (255, 255, 255), (x * 20 + 62, y * 20 + 62, 3, 3))
def body(x, y):#画蛇身
pygame.draw.rect(sceen, (170, 170, 170), (x * 20 + 51, y * 20 + 51, 18, 18), 0)
def food(x, y):#画食物
pygame.draw.circle(sceen, (170, 170, 170), (x * 20 + 60, y * 20 + 60), 8, 0)
def mobile(direction):#移动整条蛇
global snaks, revious#revious变量:用来存储那段“消失”的坐标,可以说是备份,或者电脑系统里的“回收站”
if direction == 'up':
snaks.insert(0, (snaks[0][0], snaks[0][1] - 1))
revious = snaks.pop()
elif direction == 'down':
snaks.insert(0, (snaks[0][0], snaks[0][1] + 1))
revious = snaks.pop()
elif direction == 'left':
snaks.insert(0, (snaks[0][0] - 1, snaks[0][1]))
revious = snaks.pop()
elif direction == 'right':
snaks.insert(0, (snaks[0][0] + 1, snaks[0][1]))
revious = snaks.pop()
snaks = [(10, 9)]#蛇的坐标们 #第一项是头,然后是身子们
food = (10, 9)#食物的坐标
while food in snaks:#避免食物和蛇重合
food = (random.randint(0, 19), random.randint(0, 19))
direction = 'left'#方向,用来画头和移动
score = 0#得分
time.sleep(1)
pygame.display.set_caption('3')
time.sleep(1)
pygame.display.set_caption('2')
time.sleep(1)
pygame.display.set_caption('1')
time.sleep(1)
pygame.display.set_caption('Go!')
time.sleep(1)
while True:
for event in pygame.event.get():
if event == pygame.QUIT:
sys.exit()
sce喵5, 255))
pygame.draw.rect(sceen, (0, 0, 0), (0, 0, 500, 500), 100)
mobile(direction)
if food == snaks[0]:
score += 1
snaks.append(revious)
while food in snaks:
food = (random.randint(0, 19), random.randint(0, 19))
draw.food(food[0], food[1])
draw.hand(snaks[0][0], snaks[0][1], direction)
for body in snaks[1:]:
draw.body(body[0], body[1])
pygame.display.flip()
if snaks[0] in snaks[1:]:
pygame.display.set_caption('你撞到了自己,失败了。')
time.sleep(1)
pygame.display.set_caption('本次游戏你得到了' + str(score) + '分。')
time.sleep(1)
sys.exit()
if snaks[0][0] < 0 or snaks[0][0] > 19 or snaks[0][1] < 0 or snaks[0][1] > 19:
pygame.display.set_caption('你撞到了墙,失败了。')
time.sleep(1)
pygame.display.set_caption('本次游戏你得到了' + str(score) + '分。')
time.sleep(1)
sys.exit()
if get_pressed()[pygame.K_UP]:
direction = 'up'
if get_pressed()[pygame.K_DOWN]:
direction = 'down'
if get_pressed()[pygame.K_LEFT]:
direction = 'left'
if get_pressed()[pygame.K_RIGHT]:
direction = 'right'
pygame.display.set_caption('得分:' + str(score))
time.sleep(0.2)
2020-07-05T10:26:59 点赞:0