用C++编写的小游戏源代码

作者&投稿:蛮狮 (若有异议请与网页底部的电邮联系)
用“vc”或“c++”编写的一个小游戏代码,源代码是什么?~

#include
#include
#include
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
int i,key;
int score=0;
int gamespeed=32000;
struct Food /*食物的结构体*/
{
int x; /*食物的横坐标*/
int y; /*食物的纵坐标*/
int yes; /*食物是否出现的变量*/
}food;
struct Snack /*蛇的结构体*/
{
int x[N];
int y[N];
int node; /*蛇的节数*/
int direction; /*蛇的方向*/
int life; /*蛇的生命,0活着,1死亡*/
}snake;
void Init(void); /*图形驱动*/
void Close(void); /*关闭游戏函数*/
void DrawK(void); /*画图函数*/
void GameOver(void);/*输出失败函数*/
void GamePlay(); /*游戏控制函数 主要程序*/
void PrScore(void); /*分数输出函数*/

DELAY(char ch)/*调节游戏速度*/
{
if(ch=='3')
{
delay(gamespeed); /*delay是延迟函数*/
delay(gamespeed);
}
else if(ch=='2')
{
delay(gamespeed);
}
}

Menu()/*游戏开始菜单*/
{
char ch;
printf("Please choose the gamespeed:
");
printf("1-Fast 2-Normal 3-Slow
");
printf("
Please Press The numbers..
");
do
{ch=getch();}
while(ch!='1'&&ch!='2'&&ch!='3');
clrscr();
return(ch);
}

/*主函数*/
void main(void)
{
int ch;
ch=Menu();
Init();
DrawK();
GamePlay(ch);
Close();
}

void Init(void)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\c");
cleardevice();
}

void DrawK(void)
{
setcolor(11);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
for(i=50;i<=600;i+=10)
{
rectangle(i,40,i+10,49); /*画出上边框*/
rectangle(i,451,i+10,460); /*画出下边框*/
}
for(i=40;i<=450;i+=10)
{
rectangle(50,i,59,i+10); /*画出左边框*/
rectangle(601,i,610,i+10); /*画出右边框*/
}
}

void GamePlay(char ch)
{
randomize(); /*随机数发生器*/
food.yes=1; /*1代表要出现食物,0表示以存在食物*/
snake.life=0;
snake.direction=1;
snake.x[0]=100;snake.y[0]=100;
snake.x[1]=110;snake.y[1]=100;
snake.node=2;
PrScore();
while(1) /*可以重复游戏*/
{
while(!kbhit()) /*在没有按键的情况下蛇自己移动*/
{
if(food.yes==1) /*需要食物*/
{
food.x=rand()%400+60;
food.y=rand()%350+60; /*使用rand函数随机产生食物坐标*/
while(food.x%10!=0)
food.x++;
while(food.y%10!=0)
food.y++; /*判断食物是否出现在整格里*/
food.yes=0; /*现在有食物了*/
}
if(food.yes==0) /*有食物了就要显示出来*/
{
setcolor(GREEN);
rectangle(food.x,food.y,food.x+10,food.y-10);
}
for(i=snake.node-1;i>0;i--) /*贪吃蛇的移动算法*/
{
snake.x[i]=snake.x[i-1];
snake.y[i]=snake.y[i-1]; /*贪吃蛇的身体移动算法*/
}

switch(snake.direction) /*贪吃蛇的头部移动算法,以此来控制移动*/
{
case 1:snake.x[0]+=10;break;
case 2:snake.x[0]-=10;break;
case 3:snake.y[0]-=10;break;
case 4:snake.y[0]+=10;break;
}
for(i=3;i<snake.node;i++) /*判断是否头部与身体相撞*/
{
if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])
{
GameOver();
snake.life=1;
break;
}
}
/*下面是判断是否撞到墙壁*/
if(snake.x[0]595||snake.y[0]455)
{
GameOver();
snake.life=1;
}
if(snake.life==1) /*如果死亡就退出循环*/
break;
if(snake.x[0]==food.x&&snake.y[0]==food.y) /*判断蛇是否吃到食物*/
{
setcolor(0);
rectangle(food.x,food.y,food.x+10,food.y-10); /*吃的食物后用黑色将食物擦去*/
snake.x[snake.node]=-20;snake.y[snake.node]=-20; /*现把增加的一节放到看不到的地方去*/

snake.node++;
food.yes=1;
score+=10;
PrScore();
}
setcolor(4); /*每次移动后将后面的身体擦去*/
for(i=0;i<snake.node;i++)
rectangle(snake.x[i],snake.y[i],snake.x[i]+10,snake.y[i]-10);
delay(gamespeed);
DELAY(ch);
setcolor(0);
rectangle(snake.x[snake.node-1],snake.y[snake.node-1],snake.x[snake.node-1]+10,snake.y[snake.node-1]-10);

}
if(snake.life==1)
break;
key=bioskey(0); /*接受按键*/
if(key==ESC)
break;
else
if(key==UP&&snake.direction!=4)/*判断是否改变方向*/
snake.direction=3;
else
if(key==RIGHT&&snake.direction!=2)
snake.direction=1;
else
if(key==LEFT&&snake.direction!=1)
snake.direction=2;
else
if(key==DOWN&&snake.direction!=3)
snake.direction=4;
}
}

void GameOver(void)
{
cleardevice();
setcolor(RED);
settextstyle(0,0,4);
outtextxy(200,200,"GAME OVER");
getch();
}

void PrScore(void)
{
char str[10];
setfillstyle(SOLID_FILL,YELLOW);
bar(50,15,220,35);
setcolor(6);
settextstyle(0,0,2);
sprintf(str,"scord:%d",score);
outtextxy(55,20,str);
}
void Close(void)
{
getch();
closegraph();
}

贪吃蛇

#include
#include
#include
#define LEFT 0x4b00
#define RIGHT 0x4d00
#define DOWN 0x5000
#define UP 0x4800
#define ESC 0x011b
int i,key;
int score=0;
int gamespeed=32000;
struct Food /*食物的结构体*/
{
int x; /*食物的横坐标*/
int y; /*食物的纵坐标*/
int yes; /*食物是否出现的变量*/
}food;
struct Snack /*蛇的结构体*/
{
int x[N];
int y[N];
int node; /*蛇的节数*/
int direction; /*蛇的方向*/
int life; /*蛇的生命,0活着,1死亡*/
}snake;
void Init(void); /*图形驱动*/
void Close(void); /*关闭游戏函数*/
void DrawK(void); /*画图函数*/
void GameOver(void);/*输出失败函数*/
void GamePlay(); /*游戏控制函数 主要程序*/
void PrScore(void); /*分数输出函数*/

DELAY(char ch)/*调节游戏速度*/
{
if(ch=='3')
{
delay(gamespeed); /*delay是延迟函数*/
delay(gamespeed);
}
else if(ch=='2')
{
delay(gamespeed);
}
}

Menu()/*游戏开始菜单*/
{
char ch;
printf("Please choose the gamespeed:
");
printf("1-Fast 2-Normal 3-Slow
");
printf("
Please Press The numbers..
");
do
{ch=getch();}
while(ch!='1'&&ch!='2'&&ch!='3');
clrscr();
return(ch);
}

/*主函数*/
void main(void)
{
int ch;
ch=Menu();
Init();
DrawK();
GamePlay(ch);
Close();
}

void Init(void)
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\c");
cleardevice();
}

void DrawK(void)
{
setcolor(11);
setlinestyle(SOLID_LINE,0,THICK_WIDTH);
for(i=50;i<=600;i+=10)
{
rectangle(i,40,i+10,49); /*画出上边框*/
rectangle(i,451,i+10,460); /*画出下边框*/
}
for(i=40;i<=450;i+=10)
{
rectangle(50,i,59,i+10); /*画出左边框*/
rectangle(601,i,610,i+10); /*画出右边框*/
}
}

void GamePlay(char ch)
{
randomize(); /*随机数发生器*/
food.yes=1; /*1代表要出现食物,0表示以存在食物*/
snake.life=0;
snake.direction=1;
snake.x[0]=100;snake.y[0]=100;
snake.x[1]=110;snake.y[1]=100;
snake.node=2;
PrScore();
while(1) /*可以重复游戏*/
{
while(!kbhit()) /*在没有按键的情况下蛇自己移动*/
{
if(food.yes==1) /*需要食物*/
{
food.x=rand()%400+60;
food.y=rand()%350+60; /*使用rand函数随机产生食物坐标*/
while(food.x%10!=0)
food.x++;
while(food.y%10!=0)
food.y++; /*判断食物是否出现在整格里*/
food.yes=0; /*现在有食物了*/
}
if(food.yes==0) /*有食物了就要显示出来*/
{
setcolor(GREEN);
rectangle(food.x,food.y,food.x+10,food.y-10);
}
for(i=snake.node-1;i>0;i--) /*贪吃蛇的移动算法*/
{
snake.x[i]=snake.x[i-1];
snake.y[i]=snake.y[i-1]; /*贪吃蛇的身体移动算法*/
}

switch(snake.direction) /*贪吃蛇的头部移动算法,以此来控制移动*/
{
case 1:snake.x[0]+=10;break;
case 2:snake.x[0]-=10;break;
case 3:snake.y[0]-=10;break;
case 4:snake.y[0]+=10;break;
}
for(i=3;i<snake.node;i++) /*判断是否头部与身体相撞*/
{
if(snake.x[i]==snake.x[0]&&snake.y[i]==snake.y[0])
{
GameOver();
snake.life=1;
break;
}
}
/*下面是判断是否撞到墙壁*/
if(snake.x[0]595||snake.y[0]455)
{
GameOver();
snake.life=1;
}
if(snake.life==1) /*如果死亡就退出循环*/
break;
if(snake.x[0]==food.x&&snake.y[0]==food.y) /*判断蛇是否吃到食物*/
{
setcolor(0);
rectangle(food.x,food.y,food.x+10,food.y-10); /*吃的食物后用黑色将食物擦去*/
snake.x[snake.node]=-20;snake.y[snake.node]=-20; /*现把增加的一节放到看不到的地方去*/

snake.node++;
food.yes=1;
score+=10;
PrScore();
}
setcolor(4); /*每次移动后将后面的身体擦去*/
for(i=0;i<snake.node;i++)
rectangle(snake.x[i],snake.y[i],snake.x[i]+10,snake.y[i]-10);
delay(gamespeed);
DELAY(ch);
setcolor(0);
rectangle(snake.x[snake.node-1],snake.y[snake.node-1],snake.x[snake.node-1]+10,snake.y[snake.node-1]-10);

}
if(snake.life==1)
break;
key=bioskey(0); /*接受按键*/
if(key==ESC)
break;
else
if(key==UP&&snake.direction!=4)/*判断是否改变方向*/
snake.direction=3;
else
if(key==RIGHT&&snake.direction!=2)
snake.direction=1;
else
if(key==LEFT&&snake.direction!=1)
snake.direction=2;
else
if(key==DOWN&&snake.direction!=3)
snake.direction=4;
}
}

void GameOver(void)
{
cleardevice();
setcolor(RED);
settextstyle(0,0,4);
outtextxy(200,200,"GAME OVER");
getch();
}

void PrScore(void)
{
char str[10];
setfillstyle(SOLID_FILL,YELLOW);
bar(50,15,220,35);
setcolor(6);
settextstyle(0,0,2);
sprintf(str,"scord:%d",score);
outtextxy(55,20,str);
}
void Close(void)
{
getch();
closegraph();
}

贪吃蛇

五子棋的代码:

#include<iostream>

#include<stdio.h>

#include<stdlib.h>

#include <time.h>

using namespace std;

const int N=15;                 //15*15的棋盘

const char ChessBoardflag = ' ';          //棋盘标志

const char flag1='o';              //玩家1或电脑的棋子标志

const char flag2='X';              //玩家2的棋子标志

typedef struct Coordinate          //坐标类

{   

int x;                         //代表行

int y;                         //代表列

}Coordinate;

class GoBang                    //五子棋类

public:

GoBang()                //初始化

{

InitChessBoard();

}

void Play()               //下棋

{

Coordinate Pos1;      // 玩家1或电脑

Coordinate Pos2;      //玩家2

int n = 0;

while (1)

{

int mode = ChoiceMode();

while (1)

{

if (mode == 1)       //电脑vs玩家

{

ComputerChess(Pos1,flag1);     // 电脑下棋

if (GetVictory(Pos1, 0, flag1) == 1)     //0表示电脑,真表示获胜

break;

PlayChess(Pos2, 2, flag2);     //玩家2下棋

if (GetVictory(Pos2, 2, flag2))     //2表示玩家2

break;

}

else            //玩家1vs玩家2

{

PlayChess(Pos1, 1, flag1);     // 玩家1下棋

if (GetVictory(Pos1, 1, flag1))      //1表示玩家1

break;

PlayChess(Pos2, 2, flag2);     //玩家2下棋

if (GetVictory(Pos2, 2, flag2))  //2表示玩家2

break;

}

}

cout << "***再来一局***" << endl;

cout << "y or n :";

char c = 'y';

cin >> c;

if (c == 'n')

break;

}       

}

protected:

int ChoiceMode()           //选择模式

{

int i = 0;

system("cls");        //系统调用,清屏

InitChessBoard();       //重新初始化棋盘

cout << "***0、退出  1、电脑vs玩家  2、玩家vs玩家***" << endl;

while (1)

{

cout << "请选择:";

cin >> i;

if (i == 0)         //选择0退出

exit(1);

if (i == 1 || i == 2)

return i;

cout << "输入不合法" << endl;

}

}

void InitChessBoard()      //初始化棋盘

{

for (int i = 0; i < N + 1; ++i)      

{

for (int j = 0; j < N + 1; ++j)

{

_ChessBoard[i][j] = ChessBoardflag;

}

}

}

void PrintChessBoard()    //打印棋盘,这个函数可以自己调整

{

system("cls");                //系统调用,清空屏幕

for (int i = 0; i < N+1; ++i)

{

for (int j = 0; j < N+1; ++j)

{

if (i == 0)                               //打印列数字

{

if (j!=0)

printf("%d  ", j);

else

printf("   ");

}

else if (j == 0)                //打印行数字

printf("%2d ", i);

else

{

if (i < N+1)

{

printf("%c |",_ChessBoard[i][j]);

}

}

}

cout << endl;

cout << "   ";

for (int m = 0; m < N; m++)

{

printf("--|");

}

cout << endl;

}

}

void PlayChess(Coordinate& pos, int player, int flag)       //玩家下棋

{

PrintChessBoard();         //打印棋盘

while (1)

{

printf("玩家%d输入坐标:", player);

cin >> pos.x >> pos.y;

if (JudgeValue(pos) == 1)          //坐标合法

break;

cout << "坐标不合法,重新输入" << endl;

}

_ChessBoard[pos.x][pos.y] = flag;

}

void ComputerChess(Coordinate& pos, char flag)       //电脑下棋

{

PrintChessBoard();         //打印棋盘

int x = 0;

int y = 0;

while (1)

{

x = (rand() % N) + 1;      //产生1~N的随机数

srand((unsigned int) time(NULL));

y = (rand() % N) + 1;     //产生1~N的随机数

srand((unsigned int) time(NULL));

if (_ChessBoard[x][y] == ChessBoardflag)      //如果这个位置是空的,也就是没有棋子

break;

}

pos.x = x;

pos.y = y;

_ChessBoard[pos.x][pos.y] = flag;

}

int JudgeValue(const Coordinate& pos)       //判断输入坐标是不是合法

{

if (pos.x > 0 && pos.x <= N&&pos.y > 0 && pos.y <= N)

{

if (_ChessBoard[pos.x][pos.y] == ChessBoardflag)

{

return 1;    //合法

}

}

return 0;        //非法

}

int JudgeVictory(Coordinate pos, char flag)           //判断有没有人胜负(底层判断)

{

int begin = 0;

int end = 0;

int begin1 = 0;

int end1 = 0;

//判断行是否满足条件

(pos.y - 4) > 0 ? begin = (pos.y - 4) : begin = 1;

(pos.y + 4) >N ? end = N : end = (pos.y + 4);

for (int i = pos.x, j = begin; j + 4 <= end; j++)

{

if (_ChessBoard[i][j] == flag&&_ChessBoard[i][j + 1] == flag&&

_ChessBoard[i][j + 2] == flag&&_ChessBoard[i][j + 3] == flag&&

_ChessBoard[i][j + 4] == flag)

return 1;

}

//判断列是否满足条件

(pos.x - 4) > 0 ? begin = (pos.x - 4) : begin = 1;

(pos.x + 4) > N ? end = N : end = (pos.x + 4);

for (int j = pos.y, i = begin; i + 4 <= end; i++)

{

if (_ChessBoard[i][j] == flag&&_ChessBoard[i + 1][j] == flag&&

_ChessBoard[i + 2][j] == flag&&_ChessBoard[i + 3][j] == flag&&

_ChessBoard[i + 4][j] == flag)

return 1;

}

int len = 0;

//判断主对角线是否满足条件

pos.x > pos.y ? len = pos.y - 1 : len = pos.x - 1;

if (len > 4)

len = 4;

begin = pos.x - len;       //横坐标的起始位置

begin1 = pos.y - len;      //纵坐标的起始位置

pos.x > pos.y ? len = (N - pos.x) : len = (N - pos.y);

if (len>4)

len = 4;

end = pos.x + len;       //横坐标的结束位置

end1 = pos.y + len;      //纵坐标的结束位置

for (int i = begin, j = begin1; (i + 4 <= end) && (j + 4 <= end1); ++i, ++j)

{

if (_ChessBoard[i][j] == flag&&_ChessBoard[i + 1][j + 1] == flag&&

_ChessBoard[i + 2][j + 2] == flag&&_ChessBoard[i + 3][j + 3] == flag&&

_ChessBoard[i + 4][j + 4] == flag)

return 1;

}

//判断副对角线是否满足条件

(pos.x - 1) >(N - pos.y) ? len = (N - pos.y) : len = pos.x - 1;

if (len > 4)

len = 4;

begin = pos.x - len;       //横坐标的起始位置

begin1 = pos.y + len;      //纵坐标的起始位置

(N - pos.x) > (pos.y - 1) ? len = (pos.y - 1) : len = (N - pos.x);

if (len>4)

len = 4;

end = pos.x + len;       //横坐标的结束位置

end1 = pos.y - len;      //纵坐标的结束位置

for (int i = begin, j = begin1; (i + 4 <= end) && (j - 4 >= end1); ++i, --j)

{

if (_ChessBoard[i][j] == flag&&_ChessBoard[i + 1][j - 1] == flag&&

_ChessBoard[i + 2][j - 2] == flag&&_ChessBoard[i + 3][j - 3] == flag&&

_ChessBoard[i + 4][j - 4] == flag)

return 1;

}

for (int i = 1; i < N + 1; ++i)           //棋盘有没有下满

{

for (int j =1; j < N + 1; ++j)

{

if (_ChessBoard[i][j] == ChessBoardflag)

return 0;                      //0表示棋盘没满

}

return -1;      //和棋

}

bool GetVictory(Coordinate& pos, int player, int flag)   //对JudgeVictory的一层封装,得到具体那个玩家获胜

{

int n = JudgeVictory(pos, flag);   //判断有没有人获胜

if (n != 0)                    //有人获胜,0表示没有人获胜

{

PrintChessBoard();

if (n == 1)                //有玩家赢棋

{

if (player == 0)     //0表示电脑获胜,1表示玩家1,2表示玩家2

printf("***电脑获胜***
");

else

printf("***恭喜玩家%d获胜***
", player);

}

else

printf("***双方和棋***
");

return true;      //已经有人获胜

}

return false;   //没有人获胜

}

private:

char _ChessBoard[N+1][N+1];      

};

扩展资料:

设计思路

1、进行问题分析与设计,计划实现的功能为,开局选择人机或双人对战,确定之后比赛开始。

2、比赛结束后初始化棋盘,询问是否继续比赛或退出,后续可加入复盘、悔棋等功能。

3、整个过程中,涉及到了棋子和棋盘两种对象,同时要加上人机对弈时的AI对象,即涉及到三个对象。



以下是贪吃蛇源代码:

#include<iostream.h>
#include<windows.h>
#include<time.h>
#include<stdlib.h>
#include<conio.h>
#define N 21
void gotoxy(int x,int y)//位置函数
{
COORD pos;
pos.X=2*x;
pos.Y=y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void color(int a)//颜色函数
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),a);
}
void init(int apple[2])//初始化函数(初始化围墙、显示信息、苹果)
{
int i,j;//初始化围墙
int wall[N+2][N+2]={{0}};
for(i=1;i<=N;i++)
{
for(j=1;j<=N;j++)
wall[i][j]=1;
}
color(11);
for(i=0;i<N+2;i++)
{
for(j=0;j<N+2;j++)
{
if(wall[i][j])
cout<<"■";
else cout<<"□" ;
}
cout<<endl;
}
gotoxy(N+3,1);//显示信息
color(20);
cout<<"按 W S A D 移动方向"<<endl;
gotoxy(N+3,2);
color(20);
cout<<"按任意键暂停"<<endl;
gotoxy(N+3,3);
color(20);
cout<<"得分:"<<endl;
apple[0]=rand()%N+1;//苹果
apple[1]=rand()%N+1;
gotoxy(apple[0],apple[1]);
color(12);
cout<<"●"<<endl;
}
int main()
{
int i,j;
int** snake=NULL;
int apple[2];
int score=0;
int tail[2];
int len=3;
char ch='p';
srand((unsigned)time(NULL));
init(apple);
snake=(int**)realloc(snake,sizeof(int*)*len);
for(i=0;i<len;i++)
snake[i]=(int*)malloc(sizeof(int)*2);
for(i=0;i<len;i++)
{
snake[i][0]=N/2;
snake[i][1]=N/2+i;
gotoxy(snake[i][0],snake[i][1]);
color(14);
cout<<"★"<<endl;
}
while(1)//进入消息循环
{
tail[0]=snake[len-1][0];
tail[1]=snake[len-1][1];
gotoxy(tail[0],tail[1]);
color(11);
cout<<"■"<<endl;
for(i=len-1;i>0;i--)
{
snake[i][0]=snake[i-1][0];
snake[i][1]=snake[i-1][1];
gotoxy(snake[i][0],snake[i][1]);
color(14);
cout<<"★"<<endl;
}
if(kbhit())
{
gotoxy(0,N+2);
ch=getche();
}
switch(ch)
{
case 'w':snake[0][1]--;break;
case 's':snake[0][1]++;break;
case 'a':snake[0][0]--;break;
case 'd':snake[0][0]++;break;
default: break;
}
gotoxy(snake[0][0],snake[0][1]);
color(14);
cout<<"★"<<endl;
Sleep(abs(200-0.5*score));
if(snake[0][0]==apple[0]&&snake[0][1]==apple[1])//吃掉苹果后蛇分数加1,蛇长加1
{
score++;
len++;
snake=(int**)realloc(snake,sizeof(int*)*len);
snake[len-1]=(int*)malloc(sizeof(int)*2);
apple[0]=rand()%N+1;
apple[1]=rand()%N+1;
gotoxy(apple[0],apple[1]);
color(12);
cout<<"●"<<endl;
gotoxy(N+5,3);
color(20);
cout<<score<<endl;
}
if(snake[0][1]==0||snake[0][1]==N||snake[0][0]==0||snake[0][0]==N)//撞到围墙后失败
{
gotoxy(N/2,N/2);
color(30);
cout<<"失败!!!"<<endl;
for(i=0;i<len;i++)
free(snake[i]);
Sleep(INFINITE);
exit(0);
}
}
return 0;
}参考资料:从C++吧看来的

像素射击:int anim abc_fade_in 0x7f010001
int anim abc_fade_out 0x7f010002
int anim abc_grow_fade_in_from_bottom 0x7f010003
int anim abc_popup_enter 0x7f010004
int anim abc_popup_exit 0x7f010005
int anim abc_shrink_fade_out_from_bottom 0x7f010006
int anim abc_slide_in_bottom 0x7f010007
int anim abc_slide_in_top 0x7f010008
int anim abc_slide_out_bottom 0x7f010009
int anim abc_slide_out_top 0x7f01000a
int anim abc_tooltip_enter 0x7f01000b
int anim abc_tooltip_exit 0x7f01000c
int attr actionBarDivider 0x7f040001
int attr actionBarItemBackground 0x7f040002
int attr actionBarPopupTheme 0x7f040003
int attr actionBarSize 0x7f040004
int attr actionBarSplitStyle 0x7f040005
int attr actionBarStyle 0x7f040006
int attr actionBarTabBarStyle 0x7f040007
int attr actionBarTabStyle 0x7f040008
int attr actionBarTabTextStyle 0x7f040009
int attr actionBarTheme 0x7f04000a
int attr actionBarWidgetTheme 0x7f04000b
int attr actionButtonStyle 0x7f04000c
int attr actionDropDownStyle 0x7f04000d
int attr actionLayout 0x7f04000e
int attr actionMenuTextAppearance 0x7f04000f
int attr actionMenuTextColor 0x7f040010
int attr actionModeBackground 0x7f040011
int attr actionModeCloseButtonStyle 0x7f040012
int attr actionModeCloseDrawable 0x7f040013
int attr actionModeCopyDrawable 0x7f040014
int attr actionModeCutDrawable 0x7f040015
int attr actionModeFindDrawable 0x7f040016
int attr actionModePasteDrawable 0x7f040017
int attr actionModePopupWindowStyle 0x7f040018
int attr actionModeSelectAllDrawable 0x7f040019
int attr actionModeShareDrawable 0x7f04001a
int attr actionModeSplitBackground 0x7f04001b
int attr actionModeStyle 0x7f04001c
int attr actionModeWebSearchDrawable 0x7f04001d
int attr actionOverflowButtonStyle 0x7f04001e
int attr actionOverflowMenuStyle 0x7f04001f
int attr actionProviderClass 0x7f040020
int attr actionViewClass 0x7f040021
int attr activityChooserViewStyle 0x7f040022
int attr alertDialogButtonGroupStyle 0x7f040023
int attr alertDialogCenterButtons 0x7f040024
int attr alertDialogStyle 0x7f040025
int attr alertDialogTheme 0x7f040026
int attr allowStacking 0x7f040027
int attr alpha 0x7f040028
int attr alphabeticModifiers 0x7f040029
int attr arrowHeadLength 0x7f04002a
int attr arrowShaftLength 0x7f04002b
int attr autoCompleteTextViewStyle 0x7f04002c
int attr autoSizeMaxTextSize 0x7f04002d
int attr autoSizeMinTextSize 0x7f04002e
int attr autoSizePresetSizes 0x7f04002f
int attr autoSizeStepGranularity 0x7f040030
int attr autoSizeTextType 0x7f040031
int attr background 0x7f040032
int attr backgroundSplit 0x7f040033
int attr backgroundStacked 0x7f040034
int attr backgroundTint 0x7f040035
int attr backgroundTintMode 0x7f040036
int attr barLength 0x7f040037
int attr borderlessButtonStyle 0x7f040038
int attr buttonBarButtonStyle 0x7f040039
int attr buttonBarNegativeButtonStyle 0x7f04003a
int attr buttonBarNeutralButtonStyle 0x7f04003b
int attr buttonBarPositiveButtonStyle 0x7f04003c
int attr buttonBarStyle 0x7f04003d
int attr buttonGravity 0x7f04003e
int attr buttonIconDimen 0x7f04003f
int attr buttonPanelSideLayout 0x7f040040
int attr buttonStyle 0x7f040041
int attr buttonStyleSmall 0x7f040042
int attr buttonTint 0x7f040043
int attr buttonTintMode 0x7f040044
int attr checkboxStyle 0x7f040045
int attr checkedTextViewStyle 0x7f040046
int attr closeIcon 0x7f040047
int attr closeItemLayout 0x7f040048
int attr collapseContentDescription 0x7f040049
int attr collapseIcon 0x7f04004a
int attr color 0x7f04004b
int attr colorAccent 0x7f04004c
int attr colorBackgroundFloating 0x7f04004d
int attr colorButtonNormal 0x7f04004e
int attr colorControlActivated 0x7f04004f
int attr colorControlHighlight 0x7f040050
int attr colorControlNormal 0x7f040051
int attr colorError 0x7f040052
int attr colorPrimary 0x7f040053
int attr colorPrimaryDark 0x7f040054
int attr colorSwitchThumbNormal 0x7f040055
int attr commitIcon 0x7f040056
int attr contentDescription 0x7f040057
int attr contentInsetEnd 0x7f040058
int attr contentInsetEndWithActions 0x7f040059
int attr contentInsetLeft 0x7f04005a
int attr contentInsetRight 0x7f04005b
int attr contentInsetStart 0x7f04005c
int attr contentInsetStartWithNavigation 0x7f04005d
int attr controlBackground 0x7f04005e
int attr coordinatorLayoutStyle 0x7f04005f
int attr customNavigationLayout 0x7f040060
int attr defaultQueryHint 0x7f040061
int attr dialogCornerRadius 0x7f040062
int attr dialogPreferredPadding 0x7f040063
int attr dialogTheme 0x7f040064
int attr displayOptions 0x7f040065
int attr divider 0x7f040066
int attr dividerHorizontal 0x7f040067
int attr dividerPadding 0x7f040068
int attr dividerVertical 0x7f040069
int attr drawableSize 0x7f04006a
int attr drawerArrowStyle 0x7f04006b
int attr dropDownListViewStyle 0x7f04006c
int attr dropdownListPreferredItemHeight 0x7f04006d
int attr editTextBackground 0x7f04006e
int attr editTextColor 0x7f04006f
int attr editTextStyle 0x7f040070
int attr elevation 0x7f040071
int attr expandActivityOverflowButtonDrawable 0x7f040072
int attr firstBaselineToTopHeight 0x7f040073
int attr font 0x7f040074
int attr fontFamily 0x7f040075
int attr fontProviderAuthority 0x7f040076
int attr fontProviderCerts 0x7f040077
int attr fontProviderFetchStrategy 0x7f040078
int attr fontProviderFetchTimeout 0x7f040079
int attr fontProviderPackage 0x7f04007a
int attr fontProviderQuery 0x7f04007b
int attr fontStyle 0x7f04007c
int attr fontVariationSettings 0x7f04007d
int attr fontWeight 0x7f04007e
int attr gapBetweenBars 0x7f04007f
int attr goIcon 0x7f040080
int attr height 0x7f040081
int attr hideOnContentScroll 0x7f040082
int attr homeAsUpIndicator 0x7f040083
int attr homeLayout 0x7f040084
int attr icon 0x7f040085
int attr iconTint 0x7f040086
int attr iconTintMode 0x7f040087
int attr iconifiedByDefault 0x7f040088
int attr imageButtonStyle 0x7f040089
int attr indeterminateProgressStyle 0x7f04008a
int attr initialActivityCount 0x7f04008b
int attr isLightTheme 0x7f04008c
int attr itemPadding 0x7f04008d
int attr keylines 0x7f04008e
int attr lastBaselineToBottomHeight 0x7f04008f
int attr layout 0x7f040090
int attr layout_anchor 0x7f040091
int attr layout_anchorGravity 0x7f040092
int attr layout_behavior 0x7f040093
int attr layout_dodgeInsetEdges 0x7f040094
int attr layout_insetEdge 0x7f040095
int attr layout_keyline 0x7f040096
int attr lineHeight 0x7f040097
int attr listChoiceBackgroundIndicator 0x7f040098
int attr listDividerAlertDialog 0x7f040099
int attr listItemLayout 0x7f04009a
int attr listLayout 0x7f04009b
int attr listMenuViewStyle 0x7f04009c
int attr listPopupWindowStyle 0x7f04009d
int attr listPreferredItemHeight 0x7f04009e
int attr listPreferredItemHeightLarge 0x7f04009f
int attr listPreferredItemHeightSmall 0x7f0400a0
int attr listPreferredItemPaddingLeft 0x7f0400a1
int attr listPreferredItemPaddingRight 0x7f0400a2
int attr logo 0x7f0400a3
int attr logoDescription 0x7f0400a4
int attr maxButtonHeight 0x7f0400a5
int attr measureWithLargestChild 0x7f0400a6
int attr multiChoiceItemLayout 0x7f0400a7
int attr navigationContentDescription 0x7f0400a8
int attr navigationIcon 0x7f0400a9
int attr navigationMode 0x7f0400aa
int attr numericModifiers 0x7f0400ab
int attr overlapAnchor 0x7f0400ac
int attr paddingBottomNoButtons 0x7f0400ad
int attr paddingEnd 0x7f0400ae
int attr paddingStart 0x7f0400af
int attr paddingTopNoTitle 0x7f0400b0
int attr panelBackground 0x7f0400b1
int attr panelMenuListTheme 0x7f0400b2
int attr panelMenuListWidth 0x7f0400b3
int attr popupMenuStyle 0x7f0400b4
int attr popupTheme 0x7f0400b5
int attr popupWindowStyle 0x7f0400b6
int attr preserveIconSpacing 0x7f0400b7
int attr progressBarPadding 0x7f0400b8
int attr progressBarStyle 0x7f0400b9
int attr queryBackground 0x7f0400ba
int attr queryHint 0x7f0400bb
int attr radioButtonStyle 0x7f0400bc
int attr ratingBarStyle 0x7f0400bd
int attr ratingBarStyleIndicator 0x7f0400be
int attr ratingBarStyleSmall 0x7f0400bf
int attr searchHintIcon 0x7f0400c0
int attr searchIcon 0x7f0400c1
int attr searchViewStyle 0x7f0400c2
int attr seekBarStyle 0x7f0400c3
int attr selectableItemBackground 0x7f0400c4
int attr selectableItemBackgroundBorderless 0x7f0400c5
int attr showAsAction 0x7f0400c6
int attr showDividers 0x7f0400c7
int attr showText 0x7f0400c8
int attr showTitle 0x7f0400c9
int attr singleChoiceItemLayout 0x7f0400ca
int attr spinBars 0x7f0400cb
int attr spinnerDropDownItemStyle 0x7f0400cc
int attr spinnerStyle 0x7f0400cd
int attr splitTrack 0x7f0400ce
int attr srcCompat 0x7f0400cf
int attr state_above_anchor 0x7f0400d0
int attr statusBarBackground 0x7f0400d1
int attr subMenuArrow 0x7f0400d2
int attr submitBackground 0x7f0400d3
int attr subtitle 0x7f0400d4
int attr subtitleTextAppearance 0x7f0400d5
int attr subtitleTextColor 0x7f0400d6
int attr subtitleTextStyle 0x7f0400d7
int attr suggestionRowLayout 0x7f0400d8
int attr switchMinWidth 0x7f0400d9
int attr switchPadding 0x7f0400da
int attr switchStyle 0x7f0400db
int attr switchTextAppearance 0x7f0400dc
int attr textAllCaps 0x7f0400dd
int attr textAppearanceLargePopupMenu 0x7f0400de
int attr textAppearanceListItem 0x7f0400df
int attr textAppearanceListItemSecondary 0x7f0400e0
int attr textAppearanceListItemSmall 0x7f0400e1
int attr textAppearancePopupMenuHeader 0x7f0400e2
int attr textAppearanceSearchResultSubtitle 0x7f0400e3
int attr textAppearanceSearchResultTitle 0x7f0400e4
int attr textAppearanceSmallPopupMenu 0x7f0400e5
int attr textColorAlertDialogListItem 0x7f0400e6
int attr textColorSearchUrl 0x7f0400e7
int attr theme 0x7f0400e8
int attr thickness 0x7f0400e9
int attr thumbTextPadding 0x7f0400ea
int attr thumbTint 0x7f0400eb
int attr thumbTintMode 0x7f0400ec
int attr tickMark 0x7f0400ed
int attr tickMarkTint 0x7f0400ee
int attr tickMarkTintMode 0x7f0400ef
int attr tint 0x7f0400f0
int attr tintMode 0x7f0400f1
int attr title 0x7f0400f2
int attr titleMargin 0x7f0400f3
int attr titleMarginBottom 0x7f0400f4
int attr titleMarginEnd 0x7f0400f5
int attr titleMarginStart 0x7f0400f6
int attr titleMarginTop 0x7f0400f7
int attr titleMargins 0x7f0400f8
int attr titleTextAppearance 0x7f0400f9
int attr titleTextColor 0x7f

想用这种c语言编写一个小游戏可以实现,但是非语言编写出的游戏一般的话都是比较大的,占内存比较短。

使用语言:C++使用工具:vs2019




小游戏的C++代码
\/*一个火柴人游戏,亲自验证,可运行*\/ \/*在编译时添加如下命令:-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;cons...

如何用c语言编写一个小游戏?
一、数学知识:长方形的面积S=a*b 长方形周长L=2*(a+b)其中a b分别为长方形的宽和高。二、算法分析:长方形面积及周长均依赖于宽和高,所以先要输入宽高值,然后根据公式计算,输出结果即可。三、参考代码:include <stdio.h>void main(){ double a,b; double L,S; scanf("%l...

急求C语言编译的小游戏(如扫雷),附带源代码和注释。
急求C语言编译的小游戏.EXE(如扫雷),附带源代码和注释.TXT。TXT文件最好不超过10KB。采纳最佳答案后追加200分,多谢了!... 急求C语言编译的小游戏.EXE(如扫雷),附带源代码和注释.TXT。TXT文件最好不超过10KB。采纳最佳答案后追加200分,多谢了! 展开  我来答 3个回答 #热议# 该不该让孩子很早学习人...

求助,用C语言做一个小游戏(不要太复杂),最最最基础的C语言就可以,并赋 ...
猜数字 超简单 去掉说明文字,也就十几行 简单说明见注释 include <stdio.h> include <stdlib.h> include int main(){ int i;int a;int t;printf("欢迎玩猜数字小游戏!\\n");printf("玩法介绍:\\n");printf("每次游戏会设置一个数字(1-100),请输入你猜的数字\\n");printf("系统会提示...

用C语言设计小游戏的程序??急!!!
用C语言设计小游戏的程序??急!!! 1,如贪吃蛇,五子棋等游戏!2,要用C++的程序设计!把程序写详细点谢谢!!... 1,如贪吃蛇,五子棋等游戏! 2,要用C++的程序设计!把程序写详细点 谢谢!! 展开  我来答 3个回答 #热议# 已婚女性就应该承担家里大部分家务吗? 尕蚂蚁 2009-03-04 · TA获得超过...

谁有能在vc++6.0上运行的c语言小游戏代码???
void start( ) \/\/开始游戏 { int r, c; \/\/存储人的下标 for (int i = 0; i < 9; i++) { for (int j = 0; j < 11; j++) {if (map[m].a[i][j] == 5||map[m].a[i][j]==8) { r = i; c = j; } } \/\/i j 人的下标 } char key; key = getch( ); switch ...

求助用C或者C++语言实现一个迷宫小游戏代码
include<bits\/stdc++.h> include<windows.h> include<conio.h> using namespace std;int main(){ int i123;cout<<" ."<<endl;cout<<" . ."<<endl;cout<<" . . ."<<endl;cout<<" . ."<<endl;cout<<" ."<<endl;cout<<" T M";for(i123=500;i123<=1000;i123+...

用C语言编一个小游戏,注明编码,(简单易懂的游戏,不要复杂)
\/\/C语言写的,一个玩石头、剪刀、布的小游戏。下面是源码。include<stdio.h> include<stdlib.h> int main(){ char cq[][10]={"石头","剪刀","布"};int guess=-1,r,youwin=0,mewin=0,daping=0,total=0;srand(time(NULL));while(1){ r=(int)((rand()\/(RAND_MAX+1.0))*3)...

求C语言 小游戏设计
2011-12-29 求一个用C语言编写的小游戏代码 2013-08-28 怎样用C语言编写一个小游戏? 2015-01-15 求C语言写一个简单的小游戏 2008-01-08 求C语言小游戏源程序 2012-12-03 求c语言设计的小游戏 2009-04-24 用C语言编写小游戏 2013-11-16 教你如何使用C语言编写简单小游戏 2013-12-09 C语言...

c语言可以设计小游戏吗? 怎么设计
void newgame(); \/\/新游戏 void vdisplay(); \/\/浏览记录界面 void vxuanze(); \/\/浏览选择函数 void help(); \/\/帮助说明 void vsys(int a); \/\/浏览操作函数 void viewsorce(); \/\/按记录的顺序浏览 void viewname(); \/\/按记录的姓名浏览 void viewsname(); \/\/...

随州市18057049469: 求个用VC++C语言编写的小游戏 -
厉彼怡美: #include <bits/stdc++.h> #include <Windows.h> #include <conio.h>using namespace std; long long side[21][42],x=20,y=10,ans,xue=10;char chInput; int main(){srand((unsigned)time(NULL));for(int i=1;i<21;i++)for(int j=1;j<40;j++)side[i][j]=' ';side...

随州市18057049469: 跪求用VC++编写的简单点的小游戏程序源代码,谢谢 -
厉彼怡美: #include<graphics.h>#include<stdio.h>#include<math.h>#include<conio.h>#include<stdlib.h>#include<dos.h>#define PI 3.1415926#define x0 320#define y0 240 DrawClock(int x,int y,int color) { int r=150; setcolor(color); circle(x,y,r); circle(x,y,2); } ...

随州市18057049469: 使用C++编写模拟游戏的程序 -
厉彼怡美: #include <iostream> #include <queue> #include <time.h> #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <conio.h> using namespace std; //黑桃(Spade)(S)0-12 梅花(Club)(C)100-112 红...

随州市18057049469: 用C++编个猜数字的小游戏 -
厉彼怡美: #include #include const int max=100; void main() { srand((unsigned)time(NULL));//初始化随机数种子 int i = rand()%max; //产生一个随机数字, cout<<"请输入要猜的数字("<<<")以内:"; int number; cin>>number; while(number!=i) { if(number>i) cout<<"大了!"; else if(number cout<<"小了!"; cin>>number; } cout<<"对了!"; } 以上代码VC++6.0调试通过! 希望可以给你帮助!

随州市18057049469: 能发个C++编程的小游戏的源代码给我吗?比如俄罗斯方块贪食蛇之类的 谢谢 610935004@qq.com -
厉彼怡美: 贪吃蛇#define N 200#include <graphics.h>#include <stdlib.h>#include <dos.h>#define LEFT 0x4b00#define RIGHT 0x4d00#define DOWN 0x5000#define UP 0x4800#define ESC 0x011b int i,key; int score=0;/*得分*/ int gamespeed=50000;...

随州市18057049469: 求一个用c++编写的小游戏程序,如五子棋,贪吃蛇或者其他的也行... 留邮箱:jinxinyanhuo@qq.com -
厉彼怡美: #define N 200#include #include #include #define LEFT 0x4b00#define RIGHT 0x4d00#define DOWN 0x5000#define UP 0x4800#define ESC 0x011b int i,key; int score=0;/*得分*/ int gamespeed=50000;/*游戏速度自己调整*/ struct Food { int x...

随州市18057049469: 谁有c++的小游戏程序啊 ? -
厉彼怡美: 谁有c++的小游戏程序啊 Program Description=程序名称:game.c */ /*程序目的:打砖块游戏演示 */ /*written by :董大钿 *...

随州市18057049469: 最近新学c++,求一份用c++写成的贪吃蛇代码,希望可以输入游戏者姓名,和最高分模块.谢谢 -
厉彼怡美: C++编写 猜数字小游戏#include <iostream.h> #include <ctime> #include <cstdlib> void main(){ cout<<"猜数字游戏正式开始,请把握机会!"<<endl; int x,y; char z; do{ int i=1; srand(time(0)); y=rand()%1000; cout<<endl<<"系统已经随机生成0...

随州市18057049469: C++:趣味编程实现一个小游戏 -
厉彼怡美: #include"stdio.h"#define N 17 void main(){ int a,b,temp,i,j,k,l,m,n; int num[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17}; int *ptr; printf("开始元素序号:"); scanf("%d",&a); printf("报几出列:"); scanf("%d",&b); ptr=&num[a-1]; ...

随州市18057049469: 用C++编一个俄罗斯方块的小游戏 程序代码
厉彼怡美: 你到这个网站看看 http://wenwen.sogou.com/z/q661703674.htm http://www.gougou.com/search?search=C%23%20%E4%BF%84%E7%BD%97%E6%96%AF%E6%96%B9%E5%9D%97&id=1 我的好多资料都是在 狗狗 上面找的 如果愿意学.net,可以加我

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 星空见康网