c语言爱心图片表白程序源代码
程序员文章站
2022-04-07 20:15:46
...
c语言爱心图片表白程序源代码
可用来表白哟,更多表白程序源代码可关注我私信我发源代码和压缩文件哟
想要更多可关注我,运行成品如下
#include "stdlib.h"
#include "time.h"
#include "stdio.h"
#include "graphics.h"
#include "mmsystem.h"//多媒体音频接口
#pragma comment(lib,"winmm.lib")
struct Point
{
int x;
int y;
};
IMAGE img[14],img_Big[14];//存储14张片
//加载图片
void InitImg() {
char buf[128] = { 0 };//图片的路径
for (int i = 0; i < 14; i++) {
//格式转换 i:0到0 +1 1-10
sprintf(buf, "自己\\%d.jpg", i + 1);
loadimage(&img[i], buf, 40,30);
loadimage(&img_Big[i] ,buf, 300, 200);//中间闪烁图片 &表示引用的意思
}
}
int main()
{
initgraph(800, 800);//创建窗口,宽高,像素
Point arr[46] = {
{395,268},
{406,222},
{416,193},
{441,162},
{468,133},
{500,117},
{537,105},
{557,107},
{617,120},
{649,146},
{666,173},
{680,211},
{683,247},
{680,293},
{675,338},
{660,385},
{640,440},
{616,484},
{588,529},
{557,573},
{530,610},
{493,645},
{460,675},
{422,696},
{381,676},
{350,654},
{320,626},
{292,606},
{257,570},
{230,540},
{200,500},
{180,470},
{160,430},
{140,390},
{126,342},
{117,293},
{120,250},
{133,203},
{160,170},
{200,140},
{240,130},
{280,135},
{312,146},
{340,170},
{360,195},
{375,230},
};
InitImg();
for (int i = 0; i < 46; i++)
{
//1、打开我的音频文件,open ~
mciSendString("open 123.mp3", 0, 0, 0);
//2、播放音频文件play ~
mciSendString("play 123.mp3", 0, 0, 0);
srand((unsigned)time(NULL));
//设置 文本 颜色 settextcolor(YELLOW)
//settextcolor(RGB(rand() % 256, rand() % 256, rand() % 256));
//outtextxy(arr[i].x, arr[i].y, buff[i]);//outtextxy(arr[i].x, arr[i].y, "wo ai ni ");就是打印wo ai ni 成一个爱心
putimage(arr[i].x, arr[i].y, &img[i % 14]);
Sleep(30);//缓缓延迟的输出
};
int add = 0;
while (1) {
cleardevice();
for (int i = 0; i < 46; i++) {
//设置文本颜色 settextcolor
//settextcolor(RGB(rand() % 256, rand() % 256, rand() % 256));
//outtextxy(arr[i].x, arr[i].y, buff[(i + add) % 46]);
putimage(arr[i].x, arr[i].y, &img[(i + add) % 14]);
}
putimage(250,300,&img_Big[add%14]);//加载大图片的
add++;
Sleep(1000);
}
system("pause");
return 0;
}