ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

8月4号 easyx学习笔记

2022-08-04 20:35:49  阅读:131  来源: 互联网

标签:case 200 int easyx 50 笔记 学习 printf break


#include<stdio.h>
#include<graphics.h>
#include<conio.h>//使用_getch()
#include<mmsystem.h>//包含多媒体设备接口头文件
#pragma comment(lib,"winmm.lib")//加载静态库
//int main()
//{
// //创建一个窗口,设置窗口大小
// initgraph(800, 800,SHOWCONSOLE);
// //initgraph(680, 480,SHOWCONSOLE|NOCLOSE|NOMINIMIZE);
//
//
// //setbkcolor(WHITE);//设置背景颜色
// //cleardevice();//清屏
// //setlinestyle(PS_SOLID,1);
// //setfillcolor(YELLOW);//设置填充颜色
// //setlinecolor(BLUE);//设置线条颜色
// //circle(50, 50, 50);
// //fillcircle(50, 150, 50);
// //solidcircle(50, 250, 50);
// ////设置文字颜色
// //settextcolor(RED);
// ////设置文字样式 大小,字体
// //settextstyle(20, 0, "楷体");
// ////设置背景模式 TRANSPARENT透明的
// //setbkmode(TRANSPARENT);
// //settextcolor(RGB(0, 128, 99));//设置文字颜色
// ////绘制文字(字符串的三种解决方案)L TEXT() 项目、属性、字符集、多字节字符集
// //outtextxy(50, 50, "你好,easyx");
//
// ////文字居中
// //fillrectangle(200, 50, 500, 150);
// //char array[] = "文字居中";
// //int width = 300/2-textwidth(array)/2;
// //int height = 100 / 2 - textheight(array) / 2;
// //outtextxy(200+width, 50+height, array);
//
// //输出图片
// IMAGE img;//定义一个(变量)对象
// loadimage(&img,"./1.jpg",800,800);
// putimage(0,0 , &img);
// getchar();
// //关闭窗口
// closegraph();
// return 0;
//}
void button(int x, int y, int w, int h, const char* text) {
setbkmode(TRANSPARENT);
setfillcolor(BROWN);
fillroundrect(x, y, x + w, y + h,10,10);
settextstyle(30, 0, "楷体");
int tx = x + (w - textwidth(text))/2;
int ty = y + (y - textheight(text))/2;
outtextxy(tx, ty, text);
}
void BGM() {
int a, b;
//打开音乐,播放音乐,alias取别名 repeat重复播放
/*mciSendString("open ./music2.mp3", 0, 0, 0);
mciSendString("play ./music2.mp3", 0, 0, 0);*/
a=mciSendString("open ./music3(V0).mp3 alias BGM ", 0, 0, 0);
b=mciSendString("play BGM ", 0, 0, 0);
printf("%d %d", a, b);
if (0) {
mciSendString("close BGM", 0, 0, 0);//关闭音乐
}
}void change() {
//获取窗口句柄
HWND hnd = GetHWnd();
//设置窗口标题
SetWindowText(hnd, "C语言easyx");
//弹出窗口,提示用户操作
//MessageBox(NULL,"Hello World!","Hello",MB_OKCANCEL);
int isok=MessageBox(hnd,"Hello World!","Hello",MB_OKCANCEL);
printf("%d\n", isok);
if (isok == IDOK) {
printf("你点击了OK\n");
}
else if (isok == IDCANCEL) {
printf("你点击了取消\n");
}
}
int main()
{
initgraph(800, 800, EW_SHOWCONSOLE);
// BGM();
// button(200, 50, 200, 50, "按钮");
change();
ExMessage msg;
int x = 0, y = 0;
while(true)
{
BeginBatchDraw();//开始批量绘图
cleardevice();
button(200, 50, 200, 50, "按钮");
setfillcolor(BROWN);
fillcircle(x,y,20);
EndBatchDraw();//结束批量绘图
//键盘操作
if (GetAsyncKeyState(VK_UP)) {
printf("上键\n");
y -= 1;
}
if (GetAsyncKeyState(VK_DOWN)) {
printf("下键\n");
y += 1;
}
if (GetAsyncKeyState(VK_LEFT)) {
printf("左键\n");
x -= 1;
}
if (GetAsyncKeyState(VK_RIGHT)) {
printf("右键\n");
x += 1;
}
/*if (_kbhit()) {//判断有没有键盘按下
char key = _getch();
switch (key)
{
case 72:
case 'w':
printf("上键\n");
y -= 5;
break;
case 80:
case 's':
printf("下键\n");
y += 5;
break;
case 75:
case 'a':
printf("左键\n");
x -= 5;
break;
case 77:
case 'd':
printf("右键\n");
x += 5;
break;
}
}*/
//鼠标消息
if (peekmessage(&msg, EM_MOUSE)) {
switch (msg.message)
{
case WM_LBUTTONDOWN:
if (msg.x >= 200 && msg.x <= 400 && msg.y >= 50 && msg.y <= 100) {
printf("按钮被点击了一下\n");
}
break;
default:
break;
}
}
}
getchar();
closegraph();
return 0;
}

搜索

复制

标签:case,200,int,easyx,50,笔记,学习,printf,break
来源: https://www.cnblogs.com/Xiao-Lan/p/16552211.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有