C/C++项目——圣诞节快乐!

#include
#include//需要安装
#include
#include
#pragma comment(lib,"winmm.lib")
#include"tool.h"
//图片相关操作
IMAGE imgLand;//雪地
IMAGE imgTree[20];//圣诞树
IMAGE imgOldman[14];//老人
IMAGE imgsnow[50];//雪花
//加载资源
void loadResource() {
	//加载图片
	loadimage(&imgLand, "./Resource/xuedi/2.jpg", getwidth(), 360);
	for (int i = 0; i < 20; i++) {
	char imgFile[100] = {0};
		sprintf_s(imgFile,"./Resource/tree/%d.jpg",i+1);
		loadimage(imgTree + i, imgFile, 400, 300);
	}
	for (int i = 0; i <14; i++) {
		char imgFile[100] = { 0 };
		sprintf_s(imgFile, "./Resource/oldman/%d.jpg", i + 1);
		loadimage(imgOldman + i, imgFile, 400, 300);
	}
	for (int i = 0; i <22; i++) {
		//随机生成雪花坐标rand()
		char imgFile[50] = { 0 };
		sprintf_s(imgFile, "./Resource/xuehua/%d.jpg", i + 1);
		loadimage(imgsnow + i, imgFile,25, 28);
	}
}
//初始化
void init() {
	loadResource();
}
//绘制
void draw() {
	//输出图片
	putimage(0, 475, &imgLand);
	//圣诞老人滑雪动画
	static int i = 0;
	static int k = 650;
	static int j = 0;
	static int y = rand() % getheight();
		putimage(525, 400, imgTree + i, SRCAND);
		putimage(k, 475, imgOldman + i, SRCAND);
		i = (i + 1) % 14;
		putimage(525, 400, imgTree + i, SRCPAINT);
		putimage(k, 475, imgOldman + i, SRCPAINT);
		i = (i + 1) % 14;
		if (k + 200 < 0) {
			k = 1024;
		}
		k -= 20;
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCAND);
	j = (j + 1) % 22;
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	putimage(rand() % getwidth(), rand() % getheight(), imgsnow + j, SRCPAINT);
	j = (j + 1) % 22;
	if (y > 768) {
		y = 0;
	}
	Sleep(200);
}
int main() {
	//界面,绘图
	//创建窗口
	initgraph(1024, 768);
	init();
	BeginBatchDraw();
	while (1) {
		cleardevice();
		settextcolor(YELLOW);
		settextstyle(70, 0, "华文行楷");
		outtextxy(350, 50, "圣诞节快乐!");
		settextstyle(40, 0, "华文行楷");
		outtextxy(220, 180, "学以致用,将平时所学知识变现,用");
		outtextxy(220, 250, "图形化编程编写圣诞树代码,以祝愿");
		outtextxy(220, 320, "我的老师、同学,家人们圣诞节快乐!");
		draw();
		FlushBatchDraw();
		mciSendString("open music/music.mp3", NULL, 0, NULL);
		mciSendString("play music/music.mp3", NULL, 0, NULL);
	}
	while (1);
	EndBatchDraw();
	closegraph();
	return 0;
}

你可能感兴趣的:(C语言程序设计技术,C++面向对象程序设计技术,c++,c语言,开发语言,算法)