1.开发工具: vs vc(任选一个)
2.准备材料 :
a.一首音乐 (注意:音乐要求重命名为 “x” )
b.20张图片(注意: 图片要求重命名为 “1” "2" ”3“ ......"19" "20")
3.重要的一项 : 将Unicode字符集 更改为 多字节字符集 (重中之重 千万注意)
4.先看效果
本来程序是图片循环转动的,但是截图出来就是这副鸟样子了,大家凑合先看着。
等下把程序自己做出来 慢慢体会程序呀的浪漫。
5. 话不多说咱们直接上代码
#include "graphics.h" //c++图形界面库
#include "stdio.h"
#include "time.h"
#include "mmsystem.h"
#pragma comment(lib,"winmm.lib")
//点
struct Point{
int x;//x坐标
int y;//y坐标
};
#include "stdio.h"
#include "time.h"
#include "mmsystem.h"
#pragma comment(lib,"winmm.lib")
//点
struct Point{
int x;//x坐标
int y;//y坐标
};
//1.定义 int x; //设x变量 IMAGE img;
IMAGE imgBig[20];
IMAGE imgSmall[20];
//加载图片
void InitImg(){
IMAGE imgBig[20];
IMAGE imgSmall[20];
//加载图片
void InitImg(){
char buf[128] = { 0 };//字符数组
//循环20次
for (int i = 0; i < 20; i++){//0-19 1-20
sprintf(buf, "images\\%d.jpg", i + 1);//格式转换
//2.加载 scanf("%d", &x);//加载的是整数 loadimage()
loadimage(&imgBig[i], buf, 300, 200);
loadimage(&imgSmall[i], buf, 30, 30);
}
//循环20次
for (int i = 0; i < 20; i++){//0-19 1-20
sprintf(buf, "images\\%d.jpg", i + 1);//格式转换
//2.加载 scanf("%d", &x);//加载的是整数 loadimage()
loadimage(&imgBig[i], buf, 300, 200);
loadimage(&imgSmall[i], buf, 30, 30);
}
}
void InitWindow(){
//1920*1080 获取 Get 设置Set
//使用api来获取当前窗口的宽 高
//创建一个窗口 宽 高 单位px 像素
initgraph(GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN));
//使用api来获取当前窗口的宽 高
//创建一个窗口 宽 高 单位px 像素
initgraph(GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN));
//获取当前窗口句柄
HWND hwnd = GetHWnd();
HWND hwnd = GetHWnd();
//设置窗口风格 减去窗口标题
SetWindowLong(hwnd, GWL_STYLE,
GetWindowLong(hwnd, GWL_STYLE) - WS_CAPTION);
SetWindowLong(hwnd, GWL_STYLE,
GetWindowLong(hwnd, GWL_STYLE) - WS_CAPTION);
//设置窗口的起始点 默认风格
SetWindowPos(hwnd, HWND_TOPMOST, 450, 150, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
SetWindowPos(hwnd, HWND_TOPMOST, 450, 150, GetSystemMetrics(SM_CXSCREEN),
GetSystemMetrics(SM_CYSCREEN), SWP_SHOWWINDOW);
//拿到我背面的窗口风格
LONG WindowLong = GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED;
LONG WindowLong = GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED;
//设置窗口风格
SetWindowLong(hwnd, GWL_EXSTYLE, WindowLong);
SetWindowLong(hwnd, GWL_EXSTYLE, WindowLong);
//把黑色的背景设置为透明
SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_COLORKEY);
SetLayeredWindowAttributes(hwnd, RGB(0, 0, 0), 0, LWA_COLORKEY);
}
int main(){
//创建一个窗口
//2个参数 宽 高
//initgraph(800,800);//单位px 像素
InitWindow();
//open 打开这首歌
mciSendString("open x.mp3", 0, 0, 0);
//play 播放音乐
mciSendString("play x.mp3", 0, 0, 0);
//创建结构体数组
Point arr[46] = {
{ 395, 268 },
{ 406, 222 },
{ 416, 193 },
{ 441, 162 },
{ 468, 133 },
{ 500, 117 },
{ 537, 105 },
{ 577, 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, 29