好玩的代码大全(好玩的代码大全简单)

好玩的代码大全(好玩的代码大全简单)简单好玩的编程代码如下所示 gsh msgbox 已经准备好格式化 准备开始 vbyesno set s createobject wscript shell wscript sleep 1000 msgbox 开始格式化 哈哈 吓晕了吧 骗你的 wscript

大家好,我是讯享网,很高兴认识大家。



简单好玩的编程代码如下所示:

gsh=msgbox ("已经准备好格式化,准备开始。",vbyesno)

set s=createobject("wscript.shell")

wscript.sleep 1000

msgbox "开始格式化…… 哈哈!吓晕了吧,骗你的~"

wscript.sleep 1000

wscript.sleep 1000*100

msgbox "windows发现一重要更新,e68a57af433将自动下载。"

wscript.sleep 3000

msgbox "系统检测到WINDOWS更新中捆绑有不明插件SXS.exe,是否对其扫描?",vbyesno

wscript.sleep 1000

msgbox "文件名 SXS.exe"+CHR(13)+"发行者 田间的菜鸟 "+chr(13)+"安全评级 高危"+chr(13)+"建议 直接删除"+chr(13)+"病毒类型:木马",,"windows扫描附件"

msgbox "是否阻止其安装?",vbyesno

wscript.sleep 3000

msgbox "阻止失败!请检查防火墙是否开启!"

扩展资料

编程符号种类:

1、算术运算符

用于各类数值运算。包括加(+)、减(-)、乘(*)、除(/)、求余(或称模运算,%)、自增(++)、自减(--)共七种。

2、关系运算符

用于比较运算。包括大于()、小于()、等于(==)、 大于等于(=)、小于等于(=)和不等于(!=)六种。

3、逻辑运算符

用于逻辑运算。包括与()、或(||)、非(!)三种。

4、位操作运算符

参与运算的量,按二进制位进行运算。包括位与()、位或(|)、位非(~)、位异或(^)、左移()、右移()六种。

游戏编程代码大全(编程一个最简单游戏代码)
讯享网

/*一个火柴人游戏,亲自验证,可运行*/

/*在编译时添加如下命令:-std=c++11,否则会编译错误*/

#include cstdio

#include cstdlib

#include Windows.h

#include thread

#include conio.h

using namespace std;

const unsigned char CTRL_KEY = 0XE0;

const unsigned char LEFT = 0X4B;

const unsigned char RIGHT = 0X4D;

const unsigned char DOWN = 0X50;

const unsigned char UP = 0X48;

int men2[2] = {0,0};

int women2[2]={10,10};

int Game();

void gotoxy( int x, int y ) //光标移动到(x,y)位置

{

HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);

COORD pos;

pos.X = x;

pos.Y = y;

SetConsoleCursorPosition(handle,pos);

}

int clean( int mm, int nn )

{

gotoxy ( mm, nn );

printf ( " " );

gotoxy ( mm,nn+1);

printf ( " " );

gotoxy ( mm,nn+2);

printf (" ");

}

int men( int x, int y )

{

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_BLUE|FOREGROUND_GREEN);

gotoxy( x, y );

printf(" O");

gotoxy( x, y+1 );

printf("H");

gotoxy( x, y+2 );

printf("I I");

}

int women( int i, int j )

{

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);

gotoxy( i+1,j );

printf(" O");

gotoxy( i+1,j+1 );

printf("H");

gotoxy( i,j+2 );

printf("/I I\");

}

int m=10, n=10;

int x=0;int y=0;

int TorF()

{

if ( x == m y == n ) return 1;

else return 0;

}

int womenmove()

{

int turn;

int YNbreak=0;

while( YNbreak == 0 )

{

YNbreaak = TorF();

turn=rand()%3;

clean( m, n );

if( m x ) m++;

else m--;

if( m == x )

{

if( n y ) n++;

else n--;

}

if ( m 0 ) m = 0;

if ( m = 75 ) m = 75;

if ( n 0 ) n = 0;

if ( n = 22 ) n = 22;

women( m,n );

women2[0]=m;

women2[1]=n;

Sleep(100);

}

system ( "cls" );

gotoxy ( 28, 10 );

printf ( "You died!!! " );

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_BLUE);

system ( "pause" );

exit(0);

return 0;

}

int menmove()

{

system( "cls" );

while (1)

{

switch( getch())

{

case UP:y--;break;

case DOWN:y++;break;

case LEFT:x--;break;

case RIGHT:x++;break;

}

system( "cls" );

if ( x 0 ) x = 0;

if ( x 77 ) x = 77;

if ( y 0 ) y = 0;

if ( y 22 ) y = 22;

men( x, y );

men2[0] = x;

men2[1] = y;

}

}

int Game()

{

women( 10, 10 );

men( 0, 0 );

int t = 0;

thread ( womenmove );

menmove();

.join();

return 0;

}

int main()

{

system( "mode con cols=80 lines=25" );

printf ( "游戏开始后,随机按下一个键,唤醒你的蓝色小人.如果你被红色的老女人碰到了,那么你就死了 " );

printf ( "方向键操控小人 " );

system ( "pause" );

system ( "cls" );

Game();

return 0;

}

/*留下您的赞再拿走,谢谢!*/

下落的小鸟</p> 

讯享网

讯享网#includestdio.h</p> 

#includestdlib.h</p> 

讯享网#includeconio.h</p> 

#includetime.h</p> 

讯享网#includeWindows.h</p> 

int Grade = 1, Score = 0, Max_blank = 9, Distance = 18;</p> 

讯享网struct Birds{int x; int y;}; &nbsp;//定义一种Birds数据类型(含3个成员)</p> 

Birds *Bird = (Birds*)malloc(sizeof(Birds)); &nbsp;//定义Birds类型 指针变量Bird并赋初值</p> 

讯享网struct Bg{int x, y; int l_blank; Bg *pri; Bg *next;};&nbsp; //定义一种Bg数据类型(含5个成员)</p> 

Bg *Bg1 = (Bg*)malloc(sizeof(Bg));&nbsp; //定义Bg类型 指针变量Bg1并赋初值</p> 

讯享网void Position(int x, int y) &nbsp;//光标定位函数(用于指定位置输出)</p> 

{COORD pos = { x - 1, y - 1 };</p> 

讯享网HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);</p> 

SetConsoleCursorPosition(Out, pos);</p> 

讯享网}</p> 

void Csh( ) &nbsp;//初始化界面</p> 

讯享网{</p> 

printf(&quot;══════════════════════════════════════ 

&quot;);

讯享网printf(&quot; ■■ ■■ C语言版 Flappy Bird 

&quot;);

printf(&quot; ■■ ■■ 

&quot;);

讯享网printf(&quot; ■■ ■■ 

&quot;);

printf(&quot; ■■ ■■ 瞎搞人:yyposs原创 

&quot;);

讯享网printf(&quot; ■■ ■■ 瞎搞日期:2014.2 

&quot;);

printf(&quot; ■■ ■■ 

&quot;);

讯享网printf(&quot; ■■ ■■ 改编:鸣蝉百2021.7 

&quot;);

printf(&quot; ■■ ■■ 操作:按向上方向键让小鸟起飞 

&quot;);

讯享网printf(&quot; ■■ 

&quot;);

printf(&quot; ■■ 

&quot;);

讯享网printf(&quot; ■■ ■■ 

&quot;);

printf(&quot; ■■ ■■ 

&quot;);

讯享网printf(&quot; ■■ ■■ 

&quot;);

printf(&quot; ■■ ■■ 

&quot;);

讯享网printf(&quot; ■■ ■■ DEVc++运行通过 

&quot;);

printf(&quot;══════════════════════════════════════ 

&quot;);

讯享网printf(&quot;&nbsp; 按键继续&hellip;&quot;);</p> 

getch( );</p> 

讯享网system(&quot;cls&quot;);</p> 

}</p> 

讯享网void PrFK( ) &nbsp;//输出方框(游戏范围区)</p> 

{int i;</p> 

讯享网Position(1, 1); printf(&quot;╔&quot;);&nbsp; Position(79, 1); printf(&quot;╗&quot;);</p> 

Position(1, 24); printf(&quot;╚&quot;);&nbsp; Position(79, 24); printf(&quot;╝&quot;);</p> 

讯享网for (i = 3; i = 78; i += 2){Position(i, 1); printf(&quot;═&quot;); Position(i, 24); printf(&quot;═&quot;);}</p> 

for(i=2;i=23;i++)</p> 

讯享网{ Position(1,i); printf(&quot;║&quot;);if(i11)printf(&quot;0%d&quot;,i-1);else printf(&quot;%d&quot;,i-1);</p> 

Position(79,i); printf(&quot;║&quot;);</p> 

讯享网}</p> 

Position(4, 25); printf(&quot;小鸟即将出现,请准备按键起飞&hellip; &quot;);</p> 

讯享网getch( );</p> 

Position(4, 25); printf(&quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;);</p> 

讯享网}</p> 

void CreatBg( )&nbsp; //创建障碍物坐标(便于打印输出)</p> 

讯享网{Bg *Bg2 = (Bg*)malloc(sizeof(Bg));</p> 

Bg1-x = 90; Bg1-y = 8;&nbsp; //确定障碍物的一对基本坐标(此时值是在游戏框之外)</p> 

讯享网Bg2-x = Bg1-x + Distance; Bg2-y = 9;&nbsp; //下一障碍物的基本坐标x、y</p> 

Bg1-l_blank = Max_blank - Grade;&nbsp; //障碍物上下两部分之间的空白距离l_blank</p> 

讯享网Bg2-l_blank = Max_blank - Grade;</p> 

Bg1-next = Bg2; Bg1-pri = Bg2;</p> 

讯享网Bg2-next = Bg1; Bg2-pri = Bg1;</p> 

}</p> 

讯享网void InsertBg(Bg *p)&nbsp; //随机改变障碍物的y坐标,让空白通道有上下变化</p> 

{int temp;</p> 

讯享网Bg *Bgs = (Bg*)malloc(sizeof(Bg));</p> 

Bgs-x = p-pri-x + Distance;</p> 

讯享网Bgs-l_blank = Max_blank - Grade;</p> 

srand((int)time(0)); &nbsp;//启动随机数发生器</p> 

讯享网temp = rand( ); &nbsp;//产生一个随机数并赋值给temp</p> 

if (temp % 2 == 0)</p> 

讯享网{if ((temp % 4 + p-pri-y + Max_blank - Grade)21)</p> 

Bgs-y = p-pri-y + temp % 4;</p> 

讯享网else Bgs-y = p-pri-y;</p> 

}</p> 

讯享网else</p> 

{if ((p-pri-y - temp % 4)2)Bgs-y = p-pri-y - temp % 4;</p> 

讯享网else Bgs-y = p-pri-y;</p> 

}</p> 

讯享网Bgs-pri = p-pri; Bgs-next = p;</p> 

p-pri-next = Bgs; p-pri = Bgs;</p> 

讯享网}</p> 

void CreatBird( )&nbsp; //建立小鸟的坐标(初始打印输出小鸟的位置)</p> 

讯享网{Bird-x = 41; Bird-y = 10;}</p> 

int CheckYN(Bg *q)&nbsp; //判断游戏结束与否(值为0是要结束,为1没有要结束)</p> 

讯享网{Bg *p = q; int i = 0;</p> 

while (++i = 5)</p> 

讯享网{if (Bird-y23)return 0;</p> 

if (Bird-x == p-xBird-y = p-y)return 0;</p> 

讯享网if ((Bird-x == p-x || Bird-x == p-x + 1 || Bird-x == p-x + 2) Bird-y == p-y)return 0;</p> 

if (Bird-x == p-xBird-yp-y + p-l_blank)return 0;</p> 

讯享网if ((Bird-x == p-x || Bird-x == p-x + 1 || Bird-x == p-x + 2) Bird-y == p-y + p-l_blank)</p> 

return 0;</p> 

讯享网p = p-next;</p> 

}</p> 

讯享网return 1;</p> 

}</p> 

讯享网void Check_Bg(Bg *q)&nbsp; //核查开头的障碍物坐标是否在游戏区内</p> 

{Bg *p = q; int i = 0, temp;</p> 

讯享网while (++i = 5)</p> 

{if (p-x-4)p = p-next;</p> 

讯享网else</p> 

{srand((int)time(0)); &nbsp;temp = rand();</p> 

讯享网if (temp % 2 == 0)</p> 

{if ((temp % 4 + p-y + Max_blank - Grade)21)p-y = p-y + temp % 4;</p> 

讯享网else p-y = p-y; p-x = p-pri-x + Distance;</p> 

p-l_blank = Max_blank - Grade;</p> 

讯享网}</p> 

else</p> 

讯享网{if ((p-y - temp % 4)2)p-y = p-y - temp % 4;</p> 

else p-y = p-y; p-x = p-pri-x + Distance;</p> 

讯享网p-l_blank = Max_blank - Grade;</p> 

}</p> 

讯享网}</p> 

}</p> 

讯享网}</p> 

void Prt_Bg(Bg *q)&nbsp; //打印输出障碍物(依据其x、y坐标进行相应输出)</p> 

讯享网{Bg *p = q; int i = 0, k, j;</p> 

while (++i = 5)</p> 

讯享网{if (p-x0 p-x = 78)</p> 

{for (k = 2; kp-y; k++){Position(p-x + 1, k); printf(&quot;■&quot;); printf(&quot;■&quot;); printf(&quot; &quot;);}</p> 

讯享网Position(p-x, p-y);</p> 

printf(&quot;■&quot;); printf(&quot;■&quot;); printf(&quot;■&quot;); printf(&quot; &quot;);</p> 

讯享网Position(p-x, p-y + p-l_blank);</p> 

printf(&quot;■&quot;); printf(&quot;■&quot;); printf(&quot;■&quot;); printf(&quot; &quot;);</p> 

讯享网k = k + p-l_blank + 1;</p> 

for (k; k = 23; k++){Position(p-x + 1, k); printf(&quot;■&quot;); printf(&quot;■&quot;); printf(&quot; &quot;);}</p> 

讯享网}</p> 

p = p-next;</p> 

讯享网if (p-x == 0)</p> 

{for (j = 2; jp-y; j++){Position(p-x + 1, j); printf(&quot; &quot;); printf(&quot; &quot;);}</p> 

讯享网Position(p-x + 1, p-y);</p> 

printf(&quot; &quot;); printf(&quot; &quot;); printf(&quot; &quot;);</p> 

讯享网Position(p-x + 1, p-y + Max_blank - Grade);</p> 

printf(&quot; &quot;); printf(&quot; &quot;); printf(&quot; &quot;);</p> 

讯享网j = j + Max_blank - Grade + 1;</p> 

for (j; j = 22; j++){Position(p-x + 1, j); printf(&quot; &quot;); printf(&quot; &quot;);}</p> 

讯享网}</p> 

}</p> 

讯享网}</p> 

void PrtBird( )&nbsp; //打印输出小鸟</p> 

讯享网{Position(Bird-x, Bird-y - 1); printf(&quot; &quot;);</p> 

Position(Bird-x, Bird-y); printf(&quot;Ю&quot;);</p> 

讯享网Position(38, 2); printf(&quot;Score:%d&quot;, Score);</p> 

}</p> 

讯享网void Loop_Bg(Bg *q)&nbsp; //障碍物x坐标左移,并记录成绩</p> 

{Bg *p = q; int i = 0;</p> 

讯享网while (++i = 5)</p> 

{p-x = p-x - 1; p = p-next;</p> 

讯享网if (Bird-x == p-x)</p> 

{Score += 1;</p> 

讯享网if (Score % 4 == 0 Grade4)Grade++;</p> 

}</p> 

讯享网}</p> 

}</p> 

讯享网int main( )</p> 

{int i = 0; int t;</p> 

讯享网while (1)</p> 

{</p> 

讯享网Csh( );PrFK( );CreatBg( );</p> 

InsertBg(Bg1);InsertBg(Bg1);InsertBg(Bg1);</p> 

讯享网CreatBird( );</p> 

while (1)</p> 

讯享网{if (!CheckYN(Bg1))break;</p> 

Check_Bg(Bg1);Prt_Bg(Bg1);</p> 

讯享网PrtBird( );Loop_Bg(Bg1);</p> 

Bird-y = Bird-y + 1;</p> 

讯享网if (GetAsyncKeyState(VK_UP)) &nbsp;//按下了向上方向键</p> 

{Position(Bird-x, Bird-y - 1);printf(&quot; &quot;);</p> 

讯享网Bird-y = Bird-y - 4;</p> 

}</p> 

讯享网Sleep(200);&nbsp; //程序延时200毫秒(数值大小决定游戏速度快慢)</p> 

i = 0;</p> 

讯享网}</p> 

Position(6, 25);</p> 

讯享网printf(&quot;游戏结束!&nbsp; 请输入:0.退出&nbsp; 1.重玩&quot;);</p> 

scanf(&quot;%d&quot;,t);</p> 

讯享网if (t==0)break;</p> 

system(&quot;cls&quot;); Score = 0;</p> 

讯享网}</p> 

return 0;</p> 

讯享网}</p> 


小讯
上一篇 2025-05-13 12:06
下一篇 2025-04-29 08:13

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/148846.html