當前位置:首頁 » 編程語言 » 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)即可。