在 esp8266 上面开发一款 chrome 浏览器离线时可玩的那款恐龙跳仙人掌的游戏。
游戏的原型是 chrome 浏览器在离线时呈现的小恐龙跳仙人掌的游戏
视频演示地址: https://raw.githubusercontent.com/OpensourceBooks/chrome_offline_game_on_esp8266/master/demo.mp4
所需的元器件:
组装的效果图:
使用 excel 表格,绘制恐龙和仙人掌
用 1 和 0 进行填充,保存为 csv 文件,并用文本编辑器打开
写到代码里
player = {}
player["x"] = 10
player["y"] = 44
player["pixel"] = [
(0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0),
(0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,1,1),
(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1),
(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1),
(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1),
(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0),
(0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0),
(0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0),
(1,0,0,0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,0),
(1,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0),
(1,1,0,0,0,0,1,1,1,1,1,1,1,1,0,1,0,0,0,0),
(1,1,1,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0),
(1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0),
(0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0),
(0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0),
(0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0),
(0,0,0,0,1,1,1,1,0,1,1,0,0,0,0,0,0,0,0,0),
(0,0,0,0,0,1,1,0,0,0,1,0,0,0,0,0,0,0,0,0),
(0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0),
(0,0,0,0,0,1,1,0,0,0,1,1,0,0,0,0,0,0,0,0)
]
循环像素,显示小恐龙:
pixels = player["pixel"]
if(status["is_jump"]):
player["y"]-=3
if(player["y"]<15):
status["is_jump"]=False
else:
player["y"]+=3
if(player["y"]>=43):
player["y"]=43
status["is_jumpfinish"]=True
for i in range(0,len(pixels)):
for ii in range(0,len(pixels[i])):
oled.pixel(player["x"]+ii,player["y"]+i,pixels[i][ii])
这里提供一个绘制好的 excel 文件 https://raw.githubusercontent.com/OpensourceBooks/chrome_offline_game_on_esp8266/master/game.xls
最后,代码全部在本仓库里。项目地址 https://github.com/OpensourceBooks/chrome_offline_game_on_esp8266
视频演示地址: https://raw.githubusercontent.com/OpensourceBooks/chrome_offline_game_on_esp8266/master/demo.mp4
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.