EasyX 相关问题可以去其官网问,有问必答~
easyx吧
全部回复
仅看楼主
level 8
KrissiZH 楼主
EasyX 相关问题可以去其官网的 “有问必答”提问,有问必答嗯呐~
----------------------------------
2021年02月22日 01点02分 1
level 1
如何删除画好的graphics。h图形
2021年12月22日 11点12分 2
level 7
为何输出数字变成乱码
2022年01月11日 12点01分 3
输出数字那里写成to_wstring(数字).c_str()
2022年07月26日 04点07分
level 1
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<time.h>
//画圆,遇到障碍物,按键后垂直跳起来
int main() {
/*******初始化*******/
//系统变量
float width = 800, height = 600;//主界面的宽度,高度
float g = 1;//加速度
//小球变量
float radius = 20;//小球的半径
float x = width / 4, y = height - radius;//小球的坐标位置
float vy = 0;//小球y方向的初始速度
//障碍物的变量
float rect_left_x= width/10;
float rect_bottom_y=height;
float rect_width=40;
float rect_height=60;
float rect_vx = -3;//障碍物X方向的速度
/*******绘制主界面*********/
initgraph(width, height);
/****************/
/*******主程序*********/
while (1)
{
setfillcolor(RED);
fillcircle(x, y, radius);//1.绘制小球
//2.绘制障碍物
setfillcolor(GREEN);
fillrectangle(rect_left_x, rect_bottom_y - rect_height, rect_left_x + rect_width, rect_bottom_y);
/*******碰撞检测*********/
//同时满足三个条件:1.小球右边缘x>=障碍物左边缘x
// 2.小球左边缘x<=障碍物左边缘x
//3.小球下边缘y>=障碍物上边缘y
if ((x + radius >= rect_left_x) &&
(y + radius >= rect_bottom_y - rect_height) &&
(x - radius <= rect_left_x + rect_width))
{
//printf("产生碰撞!");
Sleep(400);
}
//2.判断当发生“按键事件”时,才响应
if (_kbhit())
{
char ch = _getch();
if (ch == ' ')
{
vy = -30; //3.设置小球初速度(向上为负)
}
}
vy += g;//4.设置小球下一刻的速度,受到重力影响,
y = y + vy;//5.设置小球下一刻的位置,受速度影响
if (y >= height - radius)
{//6.判断小球位置是否在地面上(如果在vy=0;y=height-radius)
y = height - radius;
vy = 0;
}
if (y < radius)
{
y = radius;
}
rect_left_x += rect_vx;//位置更新
//当右移出屏幕后,又从左边进入屏幕
if (rect_left_x <= 0)
{
srand(time(0));
int rand_num = rand();
rect_height = rand_num % int(height / 4) + height / 4;
rect_width = rand_num % int(width / 20) + width / 40;
rect_vx = rand_num % 7 - 8;
rect_left_x = width;
}
Sleep(10);
cleardevice();
}
closegraph();
return 0;
}
请问这个障碍物为什么不停地闪烁呢?
2022年06月15日 07点06分 4
加上批量绘图试试
2023年02月01日 12点02分
level 1
[滑稽]
2022年12月18日 11点12分 5
level 1
请问官网怎么打不开了
2023年03月02日 08点03分 6
同问[太开心]
2023年03月02日 13点03分
level 1
大神,这是怎么回事,谢谢啦!!!
2023年10月18日 06点10分 7
level 1
编译显示找不到easyX.exe怎么办

2023年11月05日 05点11分 8
level 2
2024年03月14日 10点03分 9
level 2
安装了easyx.h,运行c++2022时编译报错,无法找到文件,怎么回事?头文件一加就出问题#include<easyx.h>
2024年03月14日 10点03分 10
level 1
为啥官网打不开了
2024年04月19日 06点04分 11
level 7
小球跳起来
2024年12月21日 05点12分 12
level 1
官网打不开该怎么办
2025年09月02日 09点09分 13
1