当前位置 博文首页 > ice_elephant的博客:用c/c++加上easyx图形库制作一个表白小程序
最近有我同学特意找到我让我给能不能给他女朋友做一个表白小程序,
我也是特意的学习了这个内容,用c/c++写了这个表白小程序。
现在我将这 个程序分享给需要的小伙伴们!写一个这样的程序需要准备一个
easyx图形库与之相应的vs版本。
exe程序的网盘地址: https://pan.baidu.com/s/1lgotVFD6iAwYVjRCgKRarw
提取码:4uvb
好的话不多说直接上代码:
#include<stdio.h>
#include<time.h>
#include<conio.h>
#include<graphics.h>//easyx图形库头文件
#include<math.h>
#include<string.h>
#include<iostream>
using namespace std;
#include <mmsystem.h>
#pragma comment(lib, "winmm.lib")
static time_t tt; //静态计时器
#define NUM 13
/*
程序里面用数据类型表示
*/
struct Jet {
int x, y; //烟花弹的坐标 当前的坐标
int hx, hy; //最高点坐标
bool shoot; //表示烟花弹的状态是否发射的状态
DWORD t1, t2, dt; //控制烟花弹的速度 //dt = d1-d2;
IMAGE img[2]; //定义两张图片 img[0]暗色img[1]亮色
byte n : 1; //微段 n是一个变量 n占一个位 也就是1/位
//img[n++]效果紧张内存奇怪的知识又增加了
}Jet[NUM];
struct HAPPY // 储存 Happy Birthday 艺术字图片
{
int x, y; // 每个字的图片的左上角坐标
IMAGE img; // 储存单个字图片
static int num; // 字母序号
}Happy[NUM];
int HAPPY::num = 0;
struct Fire {
int x, y; //烟花在窗口里面的坐标
int r; //烟花当前半径
int max_r; //烟花爆炸最大半径
int cent_x, cent_y;//在图片坐标系中心位置
int xy[240][240]; //240*240的像素点
bool show; //表示这个烟花是否开始爆炸
bool draw; //开始绘制
DWORD t1, t2, dt; //t2-t1=dt 单位时间控制爆炸速度
}Fire[NUM];
IMAGE flower, steping;
static int Count = 0;
void LoadSound() {
mciSendString(_T("open bk.mp3"), 0, 0, 0);
mciSendString(_T("open bomb.wav"), 0, 0, 0);
}
void style(time_t &t1) {
time_t t2;
setbkmode(TRANSPARENT);
COLORREF color = RGB(224, 255, 255);
//设置文本样式、
settextcolor(color);
settextstyle(100, 0, _T("黑体"));//字体的宽+字体的高+字体的风格
//输出文本信息
outtextxy(300, 50, _T("情书一封"));//文本坐标+文本内容
//设置文本颜色
settextcolor(WHITE);
//设置文本样式
settextstyle(50, 0, _T("微软雅黑"));//字体的宽+字体的高+字体的风格
//输出文本信息
time(&t2);
if (t2 - t1 == 2 && Count == 0) {
//cleardevice();
Count++;
}
if (t2 - t1 == 4 && Count == 1) {
//cleardevice();
Count++;
}
if (t2 - t1 == 6 && Count == 2) {
//cleardevice();
Count++;
}
if (t2 - t1 == 8 && Count == 3) {
//cleardevice();
Count++;
}
if (t2 - t1 == 8&& Count == 4) {
// cleardevice();
Count = 0;
}
if ((t2 - t1) < 2) {
//outtextxy(300, 50, _T("情书一封"));
outtextxy(250, 200, _T("我 听 见 雨 滴 落 在 青 青 草 地"));//本坐标+文本内容
outtextxy(250, 300, _T("我 听 见 远 方 下 课 钟 声 响 起"));
outtextxy(250, 400, _T("可 是 我 没 有 听 见 你 的 声 音"));//文//本坐标+文本内容
outtextxy(250, 500, _T("认 真 呼 唤 我 姓 名"));//文本坐标+文本内容
outtextxy(250, 600, _T("爱 上 你 的 时 候 还 不 懂 感 情"));//文本坐标+文本内容
}
else if ((t2 - t1) >= 6 && (t2 - t1) < 10) {
//outtextxy(300, 50, _T("情书一封"));
outtextxy(250, 300, _T("离 别 了 才 觉 得 刻 骨 铭 心"));//文本坐标+文本内容
outtextxy(250, 400, _T("为 什 么 没 有 发 现 遇 见 了 你"));
outtextxy(250, 500, _T("是 生 命 最 好 的 事 情"));//文本坐标+文本内容
outtextxy(250, 600, _T("也 许 当 时 忙 着 微 笑 和 哭 泣"));//文本坐标+文本内容
}
else if ((t2 - t1) >= 14 && (t2 - t1) < 18) {
//outtextxy(300, 50, _T("情书一封"));
outtextxy(250, 300, _T("忙 着 追 逐 天 空 中 的 流 星"));//文本坐标+文本内容
outtextxy(250, 400, _T("人 理 所 当 然 的 忘 记"));//文本坐标+文本内容
outtextxy(250, 500, _T("是 谁 风 里 雨 里 一 直 默 默 守 护 在 原 地"));//文本坐标+文本内容
outtextxy(250, 600, _T("原 来 你 是 我 最 想 留 住 的 幸 运"));//文本坐标+文本内容
}
else if ((t2 - t1) >= 22&&(t2-t1)<26) {
//outtextxy(300, 50, _T("情书一封"));
outtextxy(250, 300, _T("那 为 我 对 抗 世 界 的 决 定"));//文本坐标+文本内
outtextxy(250, 400, _T("那 陪 我 淋 的 雨"));//文本坐标+文本内容
outtextxy(250, 500, _T("一 幕 幕 都 是 你 一 尘 不 染 的 真 心"));//文本坐标+
outtextxy(250, 600, _T("与 你 相 遇 好 幸 运"));//文本坐标+
}
else if ((t2 - t1) >= 30 && (t2 - t1) < 34) {
settextstyle(125, 0, _T("黑体"));//字体的宽+字体的高+字体的风格
outtextxy(100, 400, _T("Hello Friends!"));//文本坐标+文本内
}
if (t2 - t1 >= 34) {
time(&t1);
}
}
//选择 出现! 一点时间间隔