当前位置:首页 » 编程语言 » C语言控制台特效
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

C语言控制台特效

发布时间: 2022-08-31 08:37:14

c语言实现控制台飞机大战游戏,有办法使用一个函数实现按一下空格发一颗子弹

给子弹也弄个结构体,存储pos,speed,length等信息,弄个更新(显示)子弹的函数,在主循环里不断调用这个函数

❷ 学C语言或者c++老是从控制台学起,那控制台到底是什么有什么作用

谓控制台应用程序,
就是指那些需要与传统
DOS
操作系统保持某种程序的兼容,
同时
又不需要为用户提供完善界面的程序。
简单地讲,
就是指在
Windows
环境下运行的
DOS
程序。
一旦控制台应用程序在
Windows
操作系统中运行后,就会弹出一个窗口。

也就是说控制台程序是一种基础的程序,刚刚开始学,当然是从基础的学起,难道还没学会走路就想跑了么??

❸ C语言如何实现控制台消息循环

消息依赖于窗口,在我的知识范围内是不可以这样的...
不过如果你的程序是这样的结构(伪代码):
int _tmain()
{
初始化窗口,显示窗口
消息循环()
{
//...
}
结束程序
}
也就是说,使用控制台程序来创建一个窗口,想要让鼠标点击那个窗口以后,控制台窗口显示一句话的话
直接printf即可

如果想要通过点击控制台窗口来捕捉单击消息的话...可以考虑用上面的结构创建一个跟随控制台窗口移动的全透明的窗口

再或者自己实现一个控制台....(这个不作考虑)

❹ 用C语言 在控制台下画圆或者椭圆

①需要调用控制台的坐标设置函数 ②利用圆/椭圆/...的参数方程并将值代入即可

记得采纳啊

❺ c语言的一些特效

首先,延时用函数sleep(int);
清屏就可以沿用system了。

然后就是循环写入了。

❻ C语言 控制台程序

不想调用控制台入口换winmain
底层的编译,在编译成目标文件之后,不要链接成可执行文件,生成别的
二进制文件
或者。。像
Linux内核
一样,编译成可执行文件,装载入内存,然后用内存镜像拷贝出纯二进制文件。。等等方法
至于编译驱动有另外更加专业的方法咯。。

❼ 怎样用C语言编写闪电特效

示例程序:
#include<windows.h>
#include<stdio.h>
main()
{
HANDLE hStdout;
COORD fcoord,Cursor;
char *flag = "-|/\\";
char *ch = "Baid";
int i = 0, j = 0;

AllocConsole();

/* get standered handles */
fcoord.X = fcoord.Y = 0;
Cursor.X = -1;
Cursor.Y = 1;

hStdout = GetStdHandle(STD_OUTPUT_HANDLE);

while (TRUE)
{
Sleep(300);
SetConsoleCursorPosition(hStdout, fcoord);
printf("%c",flag[i++]);
if(i == 3)
{
i = 0;
Cursor.X += 1;
SetConsoleCursorPosition(hStdout, Cursor);
printf("%c",ch[j]);
j++;
}
if(j == 4)
break;
}
//getch();
}
说明:1.RT,那就别用清屏函数三;
2.一个一个字输出?用fopen()从文件读入就可以不从程序输入了;
3.示例程序ch字符串如果是汉字程序将失去效果,这个应该是Unicode的问题,解决方法我暂时还不知道,但是奇怪的是:
#include "stdio.h"
#include<windows.h>
int main()
{
char *s = "醉拳是天下第一拳";
int i;
for (i=0; s[i]!='\0';i++)
{
printf("%c",s[i]);
Sleep(150);
}
getch();

} 这个却可以;
4.不要试图用TC系列的编译器编译。

❽ 如何用C语言编写控制台小游戏

//C语言实例:推箱子小游戏
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
//行和列
#defineROW10
#defineCOL11
/*,system("pause")orinputloop*/
/**
*

*
*/
//地图
charmap[ROW][COL]={
"##########",//0
"#####",//1
"#####",//2
"##AX###",//3
"#####",//4
"######",//5
"###",//6
"#####",//7
"###",//8
"##########"//9
//A:人,X:箱子
};
//打印地图
voidshowMap();
//接收小人的方向
charenterDirection();

//小人向上移动的方法
voidmoveToUp();
//小人向下移动的方法
voidmoveToDown();
//小人向右移动的方法
voidmoveToRight();
//小人向左移动的方法
voidmoveToLeft();

//当前小人的坐标
intcurrentPersonRow=3;
intcurrentPersonCol=2;
//当前箱子的坐标
intcurrentBoxRow=3;
intcurrentBoxCol=3;intmain(intargc,char*argv[]){
//system("clear");
printf("点击回车键开始游戏^_^ ");
//1代表运行0停止
intflag=1;
while(flag==1){
//显示地图
showMap();
//接收小人的方向
chardir=enterDirection();
switch(dir){
//小人向上移动
case'w':
case'W':
moveToUp();
break;

//小人向下移动
case's':
case'S':
moveToDown();
break;
//小人向右移动
case'd':
case'D':
moveToRight();
break;
//小人向左移动
case'a':
case'A':
moveToLeft();
break;
//停止运行
case'q':
case'Q':
printf("你的智商真低!T_T ");
flag=0;
break;
}
showMap();
if(currentBoxRow==8&&currentBoxCol==9){
printf("你的智商真高^_^!!!");
flag=0;
}

}

}
/*
方法的实现
*/


//打印地图
voidshowMap(){
inti;
for(i=0;i<ROW;i++){
printf("%s ",map[i]);
}
printf(" ");
printf("W:上,S:下,A:左,D:右。Q:退出");
printf(" ");
}
//接收小人的方向
charenterDirection(){
//清除SCANF中的缓冲区
rewind(stdin);
chardir;
dir=getch();
//scanf("%c",&dir);
returndir;
}
//小人向上移动的方法
voidmoveToUp(){
//小人的下一个坐标
intnextPersonCol=currentPersonCol;
intnextPersonRow=currentPersonRow-1;
//箱子的下一个坐标
intnextBoxRow=currentBoxRow-1;
intnextBoxCol=currentBoxCol;

//如果小人的下一个坐标是路
if(map[nextPersonRow][nextPersonCol]==''){
map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';
currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
}
//如果小人的下一个坐标是墙
if(map[nextPersonRow][nextPersonCol]=='#'){
//什么也不做
}
//如果小人的下一个坐标是箱子
if(map[nextPersonRow][nextPersonCol]=='X'){
if(map[nextBoxRow][nextBoxCol]==''){

map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';

map[nextBoxRow][nextBoxCol]='X';
map[currentBoxRow][currentBoxCol]='A';


currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
currentBoxRow=nextBoxRow;
currentBoxCol=nextBoxCol;
}
}
}
//小人向下移动的方法
voidmoveToDown(){
//小人的下一个坐标
intnextPersonCol=currentPersonCol;
intnextPersonRow=currentPersonRow+1;
//箱子的下一个坐标
intnextBoxRow=currentBoxRow+1;
intnextBoxCol=currentBoxCol;

//如果小人的下一个坐标是路
if(map[nextPersonRow][nextPersonCol]==''){
map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';
currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
}
//如果小人的下一个坐标是墙
if(map[nextPersonRow][nextPersonCol]=='#'){
//什么也不做
}
//如果小人的下一个坐标是箱子
if(map[nextPersonRow][nextPersonCol]=='X'){
if(map[nextBoxRow][nextBoxCol]==''){

map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';

map[nextBoxRow][nextBoxCol]='X';
map[currentBoxRow][currentBoxCol]='A';

currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
currentBoxRow=nextBoxRow;
currentBoxCol=nextBoxCol;
}
}
}
//小人向右移动的方法
voidmoveToRight(){
//小人的下一个坐标
intnextPersonCol=currentPersonCol+1;
intnextPersonRow=currentPersonRow;
//箱子的下一个坐标
intnextBoxRow=currentBoxRow;
intnextBoxCol=currentBoxCol+1;

//如果小人的下一个坐标是路
if(map[nextPersonRow][nextPersonCol]==''){
map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';
currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
}
//如果小人的下一个坐标是墙
if(map[nextPersonRow][nextPersonCol]=='#'){
//什么也不做
}
//如果小人的下一个坐标是箱子
if(map[nextPersonRow][nextPersonCol]=='X'){
if(map[nextBoxRow][nextBoxCol]==''){

map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';

map[nextBoxRow][nextBoxCol]='X';
map[currentBoxRow][currentBoxCol]='A';

currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
currentBoxRow=nextBoxRow;
currentBoxCol=nextBoxCol;
}
}
}
//小人向左移动的方法
voidmoveToLeft(){
//小人的下一个坐标
intnextPersonCol=currentPersonCol-1;
intnextPersonRow=currentPersonRow;
//箱子的下一个坐标
intnextBoxRow=currentBoxRow;
intnextBoxCol=currentBoxCol-1;

//如果小人的下一个坐标是路
if(map[nextPersonRow][nextPersonCol]==''){
map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';
currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
}
//如果小人的下一个坐标是墙
if(map[nextPersonRow][nextPersonCol]=='#'){
//什么也不做
}
//如果小人的下一个坐标是箱子
if(map[nextPersonRow][nextPersonCol]=='X'){
if(map[nextBoxRow][nextBoxCol]==''){
map[nextPersonRow][nextPersonCol]='A';
map[currentPersonRow][currentPersonCol]='';

map[nextBoxRow][nextBoxCol]='X';
map[currentBoxRow][currentBoxCol]='A';

currentPersonRow=nextPersonRow;
currentPersonCol=nextPersonCol;
currentBoxRow=nextBoxRow;
currentBoxCol=nextBoxCol;
}
}
}

❾ 如何美化C语言执行界面

我知道的界面做的最好的应该是ghost,采用C语言编写
我们一般学习C语言旨在学习C语言的编程方法和算法,所以不要嫌弃C语言运行时的黑屏幕,更好的界面一般都是用C++等面向对象的语言去编写的。

❿ 用C语言编写控制台程序,如何实现在需要时隐藏和显示控制台

#include<stdio.h>
#include<stdlib.h>
main()
{
intyear;
scanf("%d",&year);
while(year!=0)
{
if(year%4==0&&year%100!=0||year%400==0)
printf("%d是闰年",year);
elseprintf("%d不是闰年",year);
system("pause");
scanf("%d",&year);
}
}
加一个while循环即可,当输入年份不为0时,可继续输入,输入0则结束
如果你想一直运行的话,加一个while(0)即可。