<= 5:a = a * -1if Y <= 5:b = b * -1if Y >= 48:if not (X > loc + 50 or X < loc - 10):b = b * -1if X > loc + 50 or X < loc - 10:staart_flag = FalseStart = FalseFMQ = Truefunc()while True:a1()a2()a3()a4()
X 实验图形编程
X 实验图形编程2
Mind+ 实验图形编程
弹球游戏(实验视频)
添加链接描述
2、简单连连看()
玩法说明
按A键左移动
按B键右移动
按金手指T或H来选择
#MicroPython动手做(35)——体验小游戏#简单连连看from mpython import *import random#--------------------------------------------------------#图片转换参考https://mpython.readthedocs.io/zh/master/tutorials/basics/oled.html#id3#图片定义#苹果apple = bytearray([\0XFF,0XFF,0XFF,0XFF,0X80,0X00,0X00,0X01,0X80,0X00,0X00,0X01,0X80,0X18,0X70,0X01,0X80,0X00,0X0C,0X01,0X80,0X00,0X03,0X01,0X84,0X01,0XC0,0X81,0X88,0X3F,0XF0,0X61,0X98,0X3F,0XF8,0X31,0X90,0X3F,0XFC,0X31,0XB0,0X3F,0XFC,0X19,0XB0,0X3F,0XFE,0X19,0XB0,0X0F,0XF6,0X19,0XB8,0X00,0X80,0X19,0XBC,0X00,0X00,0X19,0XBE,0X00,0X00,0X39,0XBF,0X80,0X00,0X79,0XBF,0XE0,0X07,0XF9,0X9F,0XFF,0XFF,0XF9,0X9F,0XFF,0XFF,0XF1,0X8F,0XFF,0XFF,0XF1,0X8F,0XFF,0XFF,0XE1,0X87,0XFF,0XFF,0XE1,0X83,0XFF,0XFF,0XC1,0X81,0XFF,0XFF,0X81,0X81,0XFF,0XFF,0X01,0X80,0XFF,0XFE,0X01,0X80,0X7F,0XFC,0X01,0X80,0X3F,0XF0,0X01,0X80,0X00,0X00,0X01,0X80,0X00,0X00,0X01,0XFF,0XFF,0XFF,0XFF,])#樱桃cherry = bytearray([\0XFF,0XFF,0XFF,0XFF,0X80,0XC0,0X00,0X01,0X81,0XC0,0X00,0X01,0X80,0XC0,0X00,0X01,0X80,0XC0,0X00,0X01,0X80,0XA0,0X00,0X01,0X80,0X10,0X00,0X01,0X80,0X90,0X00,0X01,0X80,0X88,0X00,0X01,0X80,0X8C,0X00,0X01,0X80,0X84,0X00,0X01,0X80,0X83,0X00,0X01,0X80,0X81,0X80,0X01,0X80,0X00,0XCF,0X21,0X80,0X40,0X7F,0X11,0X80,0X79,0XFF,0X19,0X87,0XFC,0XFF,0XF9,0X8F,0XFC,0X7F,0XF9,0X9F,0XF8,0X7F,0XFD,0XBF,0XF8,0X7F,0XFD,0XBF,0XF8,0X7F,0XFD,0XBF,0XF8,0X7F,0XFD,0XBF,0XFF,0XFF,0XFD,0XBF,0XFF,0XFF,0XF9,0XBF,0XFF,0XFF,0XF9,0XBF,0XFF,0XFF,0XF1,0XBF,0XFF,0XFF,0XF1,0X9F,0XFF,0XFF,0XE1,0X8F,0XFF,0X9F,0X81,0X87,0XFF,0X00,0X01,0X81,0XFC,0X00,0X01,0XFF,0XFF,0XFF,0XFF,])#桑葚mulberry = bytearray([\0XFF,0XFF,0XFF,0XFF,0X80,0X21,0X00,0X01,0X80,0X10,0X00,0X01,0X81,0X08,0X80,0X01,0X82,0X38,0X80,0X01,0X82,0X3F,0X80,0X01,0X82,0X3F,0XE0,0X01,0X86,0X3F,0XF0,0X01,0X86,0X3F,0XF8,0X01,0X83,0XFF,0XFC,0X01,0X83,0XFF,0XFE,0X01,0X87,0XFF,0XFF,0X01,0X8F,0XFF,0XFF,0X01,0X8F,0XFF,0XFF,0X01,0X8F,0XFF,0XFF,0X81,0X8F,0XFF,0XFF,0X81,0X8F,0XFF,0XFF,0X81,0X8F,0XFF,0XFF,0X81,0X8F,0XFF,0XFF,0X81,0X87,0XFF,0XFF,0X81,0X87,0XFF,0XFF,0X81,0X83,0XFF,0XFF,0XC1,0X81,0XFF,0XFF,0XC1,0X80,0XFF,0XFF,0XC1,0X80,0XFF,0XFF,0XC1,0X80,0X7F,0XFF,0XC1,0X80,0X3F,0XFF,0X81,0X80,0X1F,0XFF,0X81,0X80,0X0F,0XFF,0X81,0X80,0X03,0XFF,0X01,0X80,0X01,0XFC,0X01,0XFF,0XFF,0XFF,0XFF,])#草莓strawberry = bytearray([\0XFF,0XFF,0XFF,0XFF,0X80,0X00,0X00,0X01,0X80,0X00,0X00,0X01,0X80,0X00,0X00,0X01,0X80,0X00,0X00,0X01,0X80,0X00,0XC0,0X01,0X80,0X03,0XE8,0X01,0X80,0X0D,0XE4,0X01,0X80,0X1F,0XFE,0X01,0X80,0X3F,0XFF,0X01,0X80,0X7F,0XFF,0X01,0X80,0XFF,0XDF,0X81,0X81,0XFF,0XFF,0XF9,0X83,0XFF,0XFF,0XC1,0X83,0XFF,0XFF,0XC1,0X87,0XFF,0XFF,0XC1,0X8F,0XFF,0XFF,0XE1,0X9F,0X7F,0XFF,0XE1,0XBF,0XFF,0XFF,0XE1,0XBF,0XFF,0XFF,0XE1,0XBF,0XFE,0XFF,0XE1,0XBF,0XDF,0XFF,0XE1,0XBF,0XFF,0XFF,0XC1,0X9F,0XFF,0XFE,0XC1,0X9F,0XFF,0XBF,0X81,0X8F,0XFF,0XFF,0X01,0X81,0XFF,0XFC,0X01,0X80,0X07,0XF0,0X01,0X80,0X00,0X00,0X01,0X80,0X00,0X00,0X01,0X80,0X00,0X00,0X01,0XFF,0XFF,0XFF,0XFF,])#打勾tick = bytearray([\0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XC0,0X00,0X00,0X03,0XC0,0X00,0X00,0X03,0XC0,0X00,0X00,0X03,0XC0,0X00,0X00,0X63,0XC0,0X00,0X00,0XE3,0XC0,0X00,0X01,0XE3,0XC0,0X00,0X03,0XE3,0XC0,0X00,0X07,0XE3,0XC0,0X00,0X0F,0XE3,0XC0,0X00,0X1F,0XE3,0XC0,0X00,0X1F,0XF3,0XC0,0X00,0X3F,0XF3,0XC0,0X00,0X7F,0XC3,0XC0,0X00,0X7F,0X83,0XC0,0XC0,0XFF,0X03,0XC1,0XE0,0XFE,0X03,0XC7,0XE1,0XFC,0X03,0XCF,0XF1,0XF8,0X03,0XCF,0XF3,0XF0,0X03,0XC3,0XFB,0XE0,0X03,0XC1,0XFF,0XC0,0X03,0XC0,0X7F,0X80,0X03,0XC0,0X3F,0X80,0X03,0XC0,0X1F,0X00,0X03,0XC0,0X0E,0X00,0X03,0XC0,0X06,0X00,0X03,0XC0,0X04,0X00,0X03,0XC0,0X00,0X00,0X03,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,0XFF,])#--------------------------------------------------------#函数定义#生成8个随机水果下标#默认数组[0,1,2,3],循环2次,就有个8了,如何避免每次生成重复的呢,下面请看def getFruitRand():fruitsIndex=[0,1,2,3]fruitsIndex_random=[]for i in range(2):#对[0,1,2,3]循环2次加入到fruitsIndex_random中fruitsIndex_=fruitsIndex.copy()#这里不直接用fruitsIndex,因为下面有del删除,我们拷贝一份副本for j in range(4):#循环4次rand=random.randint(0,len(fruitsIndex_)-1) #随机0-3,因j从0开始最大为3,而len(fruitsIndex)返回的是4,所以-1randIndex=fruitsIndex_[rand]#取随机下标,范围在0-3中, fruitsIndex=[0,1,2,3]fruitsIndex_random.append(randIndex)#添加到fruitsIndex_random中del(fruitsIndex_[rand])#这里核心,添加完成后删除掉fruitsIndex中的内容#删除掉后,随机就肯定不会出现重复的了#比如每次都随机删除最后一个#循环第一次fruitsIndex_长度为[0,1,2,3]#循环第二次fruitsIndex_长度为[0,1,2]#循环第三次fruitsIndex_长度为[0,1]#循环第四次fruitsIndex_长度为[0]#这样随机肯定不会重复#返回得到的8位随机水果下标fruitsIndex_randomreturn fruitsIndex_random#显示8个水果图片#isShow主要控制是否最后oled.show(),因为我可能会再show()之前插入一些文字#fruitsIndex传输的8位随机水果下标,如[2,1,3,0,2,0,1,3]def showFruit(fruitsIndex,isShow=True):i=0for index in fruitsIndex:#遍历fruitsIndex下标,i计次,从0开始if i
- 常用函数干货 【Excel】函数之易踩坑系列
- 计算机数学专业,计算机数学专业求职信范文
- hrbust 1476 教主们毕业设计排版【dp】
- THUPC 清华大学学生程序设计竞赛暨高校邀请赛2023 - 初赛(待补题)
- 【附安装包】Lumion12.5安装教程
- 附例题 【LeetCode】一文吃透线段树
- 第十五章 SPSS Modeler 集成学习算法之同质集成
- html网页制作代码大全——大学生影视主题网页制作——图图影视影院5页HTML+
- 寄存器操作 8、stm32F103入门学习--点亮LED(向库函数操作迈进!)
- 一 【数据可视化】SVG