当前位置: 首页 > news >正文

网站建设平台价格网站建设二级菜单

网站建设平台价格,网站建设二级菜单,吉林省吉林市地图,中国已封城市名单Xiao ESP32C3使用oled 0.96实现下雪的功能 雪花下落的时候, 随机生成半径和位置 sandR和sandX,sandY 保存雪花下落位置的时候, 将其周边一圈设置为-1, 标记为有雪花 其他雪花下落的时候, 其他雪花的一圈如果遇到-1, 则停止下落, 并重复2 #include oled.h void …Xiao ESP32C3使用oled 0.96实现下雪的功能 雪花下落的时候, 随机生成半径和位置 sandR和sandX,sandY 保存雪花下落位置的时候, 将其周边一圈设置为-1, 标记为有雪花 其他雪花下落的时候, 其他雪花的一圈如果遇到-1, 则停止下落, 并重复2 #include oled.h void setup() {// 串口初始化Serial.begin(115200);oled_init();randomSeed(micros());print_vulnerability_init(); } void run900msTasks() {oled.clearDisplay();playSnowing();oled.display(); // 这放到最后 }// oled.h #ifndef __OLED_H_ #define __OLED_H_ #include Adafruit_SSD1306.h#define SCREEN_WIDTH 128 #define SCREEN_HEIGHT 64static Adafruit_SSD1306 oled(SCREEN_WIDTH, SCREEN_HEIGHT, Wire); void oled_init() {// oled初始化if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3C for 128x32Serial.println(F(SSD1306 allocation failed));for (;;); // Dont proceed, loop forever}Serial.println(F(SSD1306 allocation success!!!));oled.display();delay(500); oled.setTextSize(1);oled.setTextColor(WHITE);oled.setRotation(0);oled.clearDisplay();delay(1000); }void oled_println(int16_t x, int16_t y, const char *msg) {oled.setCursor(x, y);oled.println(msg); }struct snow {// 定义落点个数int numPoints 10;int snows[SCREEN_WIDTH][SCREEN_HEIGHT];int sandX 0;int sandY 0; int sandR 1; // 半径void init() {for (int i0; iSCREEN_WIDTH; i) {for(int j0; jSCREEN_HEIGHT; j) {snows[i][j] 0;}}random_snow_pos(); }/*** 设置当前的雪花位置*/void setSnow(int x, int y, int r) {sandX x;sandY y;sandR r;}/*** 初始化随机点*/void random_snow_pos() {setSnow(0, random(0, SCREEN_HEIGHT), random(2, 5));}/*** 将下落的雪花放到数组中*/ void snowToSnows() {snows[sandX][sandY] sandR;}/*** 向右移动*/void move(int distance) {sandXdistance;}/*** 计算雪花点的周围一圈是否有雪花*/bool collideBorder() {if(sandX SCREEN_WIDTH || sandY SCREEN_HEIGHT) return true;for (int i 0; i numPoints; i) {float theta (float)i / numPoints * 2 * PI;int x sandX sandR * cos(theta);int y sandY sandR * sin(theta);// 不管是-1还是其他, 都算是触底了if(x0 y0 snows[x][y] ! 0) return true;}return false;}/*** 设置雪花周边都为-1*/void setSnowEdge() {for (int i 0; i numPoints; i) {float theta (float)i / numPoints * 2 * PI;int x sandX sandR * cos(theta);int y sandY sandR * sin(theta);snows[x][y] -1;}}} snow;void print_vulnerability_init() {for(int i0; iSCREEN_HEIGHT; i) {snow.snows[SCREEN_WIDTH-1][i] 1;}snow.snows[60][10] 1;snow.random_snow_pos(); }/*** 根据128*64的数组里面为1的点绘制○ */ void print_snow() {for (int i0; iSCREEN_WIDTH; i) {for(int j0; jSCREEN_HEIGHT; j) {if(snow.snows[i][j] 0) {continue;} else {oled.fillCircle(i, j, snow.snows[i][j], WHITE);} }} }/*** 模拟漏斗 */ void playSnowing() {int while_i 0;Serial.print(,);Serial.print(snow.sandX);Serial.print(,);Serial.println(snow.sandY);while(snow.collideBorder()) {snow.snowToSnows();snow.setSnowEdge();snow.random_snow_pos();while_i ;if(while_i 100) {snow.init();break;}}// 绘制沙子的点oled.fillCircle(snow.sandX, snow.sandY, snow.sandR, WHITE);// 沙子移动snow.move(1);print_snow(); }/*** 1. 雪花下落的时候, 随机生成半径和位置 sandR和sandX,sandY* 2. 保存雪花下落位置的时候, 将其周边一圈设置为-1, 标记为有雪花* 3. 其他雪花下落的时候, 其他雪花的一圈如果遇到-1, 则停止下落, 并重复2*/ #endif
http://www.hkea.cn/news/14533686/

相关文章:

  • 成都网站建设07fly网站开发周期表
  • 红河州建设局门户网站自适应wordpress博客
  • 自己做的网站怎么取sql数据青岛一点两区救治医院
  • 盐城网站建设app我的页面设计
  • 企业建设网站有什么作用软件开发图片
  • 安徽一方建设招标网站给企业做免费的推广
  • 中国铁路监理建设协会网站wordpress移动端加底部导航栏
  • 哈尔滨的网站建设公司网站建设方案总结语
  • 高碑店网站建设文化建设方面的建议
  • 国家职业技能培训平台企业网站建设与优化
  • 东营网站建设价钱表用爱奇艺会员做视频网站违法吗
  • 郑州 网站建设:微信网站制作系统
  • 一个网站的成功企业解决方案有哪些
  • 佛山免费建站找哪家公司网站定制
  • 网页网站的区别是什么免费的企业网站源码
  • 如何做返利网站外推广音乐网站整站程序
  • wordpress网站做h5分类企业网站 建设 外包
  • 网站设计公司苏州网站做专题
  • 做网站开发的有哪些公司好毕设做网站什么主题比较好
  • wordpress建站费用网站建设的步骤教程
  • 网站制作公司石家庄成都游戏网站建设
  • 网站建设合同副本如何做公司网络推广
  • 后端网站开发遇到的难题解决长沙市网站制作多少钱
  • 西安市政道桥建设公司网站xampp可以做网站吗
  • 河北婚庆网站建设定制怎么制作视频收费观看的网页
  • 公司门户网站什么意思wordpress没有权限
  • 网站备案去哪注销摄影基地设计
  • 建设介绍网站郑州论坛官网
  • 关键词优化除了做网站还有什么方法深圳大型网络科技公司
  • 网站系统建设架构wordpress数据库变量引用