C语言数字雨小项目
视频教程在B站“蒸汽小毛”
编译工具:vs2013、图形库easyX
该程序在VS2013上可完美运行。
项目源码:
#include<stdio.h>
#include<graphics.h> //图形库头文件
#include<Windows.h>
#define WIDTH 1615//960
#define HEIGTH 1006//640
#define STR_SIZE 20 //数字雨数组最大存储
#define STR_NUM 128 //数字雨的串数
#define STR_WIDTH 15 //字符串
struct Rain //雨的结构
{
int x; //数字雨横向位置
int y; //y坐标
int speed; //下降速度
char str[STR_SIZE]; //数字雨数组
}rain[STR_NUM];
char CreateCh()
{
char temp = 0;
int flag = rand() % 3;//0 1 2
if (flag == 0)
{
temp = rand() % 26 + 'a';
}
else if (flag == 1)
{
temp = rand() % 26 + 'A';
}
else
{
temp = rand() % 10 + '0';
}
return temp;
}
void GameInit()
{
//初始化基础数据
for (int i = 0; i < STR_NUM; i++)
{
rain[i].x = i*STR_WIDTH;
rain[i].y = rand() % HEIGTH;
r

4960

被折叠的 条评论
为什么被折叠?



