OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 5236|回复: 0

黑客帝国 数字雨

[复制链接]

4

主题

6

帖子

0

精华

新手上路

积分
20
金钱
20
注册时间
2017-5-28
在线时间
2 小时
发表于 2017-6-25 12:58:23 | 显示全部楼层 |阅读模式
说明:本帖程序通过移植   http://blog.csdn.net/flx413/article/details/52014008   实现

linux有个cmatrix可以实现数字雨的效果,满满的黑客帝国既视感,我的开发板是阿波罗F7,7寸屏幕。但是通过修改一点点代码可以实现任意原子开发板移植。

首先在带屏幕驱动的工程里,加入下面头文件
[mw_shl_code=applescript,true]#include "stdlib.h"
#include "time.h"
#include "stdio.h"[/mw_shl_code]

[mw_shl_code=applescript,true]#define SCREEN_WIDTH 400
#define SCREEN_HEIGHT 600
#define DEF_RAIN_NUM 70 [/mw_shl_code]

SCREEN_WIDTH 和 SCREEN_HEIGHT  个人感觉改变的是数字雨密集程度,大家可以自己改改看
DEF_RAIN_NUM 是雨的列数,如果下载到开发板,屏幕不滚动,需要把这个值改小


下面就是大段的复制粘贴
[mw_shl_code=applescript,true]int g_nRainPos[DEF_RAIN_NUM] = { 0 };

char g_strRain[DEF_RAIN_NUM][10] = { 0 };

char CreateRandomNum()
{
        char nRandomNum = 0;
        while( 1 )
        {
                        nRandomNum = rand() % 123;
                        if( ( nRandomNum >= 65 && nRandomNum <= 90 ) || nRandomNum >= 97 )
                        {
                                        return nRandomNum;
                        }
        }
}

void InitPos()
{
        int i = 0;
    for( i = 0; i < DEF_RAIN_NUM; i++ )
        {
        g_nRainPos = rand() % SCREEN_HEIGHT;
    }
}

void InitNumRain()
{
        int i = 0,j = 0;
  for( i = 0; i < DEF_RAIN_NUM; i++ )
        {
    for( j = 0; j < 10; j++ )
                {
       g_strRain[j] = CreateRandomNum();
    }
  }
}

void ShowNumRain()
{
        int i = 0,j = 0;
        for( i = 0; i < DEF_RAIN_NUM; i++ )
        {
                POINT_COLOR=WHITE;
                for( j = 0; j < 10; j++ )
                {
                        LCD_ShowChar(i * 15,g_nRainPos - 15 * j,g_strRain[j],16,1);
                        POINT_COLOR=GREEN;
                }
        }

        for( i = 0; i < DEF_RAIN_NUM; i++ )
        {
                g_nRainPos += 15;
        }

        for( i = 0; i < DEF_RAIN_NUM; i++ )
        {
                if( g_nRainPos - 10 * 15 >= SCREEN_HEIGHT )
                {
                                g_nRainPos = 0;
                }
        }
}[/mw_shl_code]




main函数的while(1)
[mw_shl_code=applescript,true]InitNumRain();
LCD_Clear(BLACK);
ShowNumRain();
delay_ms(50);[/mw_shl_code]


正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-17 10:01

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表