国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

C語(yǔ)言經(jīng)典游戲代碼大全(珍藏版)

這篇具有很好參考價(jià)值的文章主要介紹了C語(yǔ)言經(jīng)典游戲代碼大全(珍藏版)。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

前言

發(fā)現(xiàn)很多朋友都想要一些小項(xiàng)目來(lái)練手,卻找不到從哪里尋找,給大家整理了游戲項(xiàng)目開(kāi)發(fā)源代碼匯總。

一、最經(jīng)典游戲之俄羅斯方塊

#include<iostream>
#include<math.h>
#include<Windows.h>
#include<conio.h>
#include<ctime>
using namespace std;

enum DIR
{
	UP,
	RIGHT,
	DOWN,
	LEFT
};

time_t start = 0, finish = 0;

int _x = 6, _y = 1;//圖形生成位置

int map[30][16] = { 0 };

int sharp[20][8] = {
	{0,0,0,0,0,0,0,0},
	//I形
	{0,0,0,1,0,2,0,3},
	{0,0,1,0,2,0,3,0},
	//■形
	{0,0,1,0,0,1,1,1},
	//L形
	{0,0,0,1,0,2,1,2},
	{0,0,0,1,1,0,2,0},
	{0,0,1,0,1,1,1,2},
	{0,1,1,1,2,0,2,1},
	//J形
	{0,2,1,0,1,1,1,2},
	{0,0,0,1,1,1,2,1},
	{0,0,0,1,0,2,1,0},
	{0,0,1,0,2,0,2,1},
	//Z形
	{0,0,1,0,1,1,2,1},
	{0,1,0,2,1,0,1,1},
	//S形
	{0,1,1,0,1,1,2,0},
	{0,0,0,1,1,1,1,2},
	//T形
	{0,1,1,0,1,1,2,1},
	{0,0,0,1,0,2,1,1},
	{0,0,1,0,1,1,2,0},
	{0,1,1,0,1,1,1,2}
};


class Game
{
public:
	int score;//游戲分?jǐn)?shù)
	int _id;//圖形編號(hào)
	int top;//最高點(diǎn)高度
	int speed;//下落速度

	Game();
	void showMenu();//顯示菜單
	void showGround();//顯示游戲界面
	void gameOver();//游戲結(jié)束界面
	void Run();//運(yùn)行游戲
	void sharpDraw(int id, bool show = false);//繪制圖形
	void keyControl();//鍵盤(pán)控制
	bool move(int dir, int id);//移動(dòng)判斷
	bool downSet(int id);//下落
	void Turn(int id);//旋轉(zhuǎn)
	void clean();//消行
};

void SetPos(int i, int j)//控制光標(biāo)位置, 列, 行
{
	COORD pos = { i,j };
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}

int main()
{
	CONSOLE_CURSOR_INFO cursor;
	GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor);
	cursor.bVisible = 0;	//這四行用來(lái)設(shè)置光標(biāo)不顯示
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor);

	srand((unsigned)time(NULL));

	Game game;
	game.showMenu();
	return 0;
}

Game::Game()
{
	score = 0;
	_id = 0;
	top = 58;
	speed = 1000;
}

void Game::showMenu()
{
	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 26; j++)
		{
			if ((i == 0 || i == 29) || (j == 0 || j == 25))
			{
				cout << "■";
			}
			else
			{
				cout << "  ";
			}
		}
		cout << endl;
	}

	SetPos(17, 8);
	cout << "俄 羅 斯 方 塊" << endl;
	SetPos(13, 12);
	cout << "↑旋轉(zhuǎn)方塊  ↓加速下滑" << endl;
	SetPos(12, 14);
	cout << "← →左右移動(dòng)  空格  暫停" << endl;
	SetPos(15, 20);
	cout << "0 退出  Enter 開(kāi)始" << endl;

	while (1)
	{
		int select = _getch();
		if (select == 13)
		{
			system("cls");
			this->Run();
		}
		else if (select = 48)
		{
			system("cls");
			exit(0);
		}
	}
}

void Game::showGround()
{
	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 26; j++)
		{
			if ((i == 0 || i == 29) || (j == 0 || j == 25 || j == 15))
			{
				cout << "■";
			}
			else if (i == 15 && j > 15)
			{
				cout << "■";
			}
			else
			{
				cout << "  ";
			}
		}
		cout << endl;
	}

	SetPos(31, 2);
	cout << "下 個(gè)圖形" << endl;
	SetPos(31, 17);
	cout << "當(dāng) 前得分" << endl;

	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < 16; j++)
		{
			if ((i == 0 || i == 29) || (j == 0 || j == 15))
			{
				map[i][j] = 1;
			}
			else
			{
				map[i][j] = 0;
			}
		}
	}
}

void Game::gameOver()
{
	for (int i = 5; i < 15; i++)
	{
		SetPos(1, i);
		cout << "                            " << endl;
	}

	SetPos(8, 7);
	cout << "G a m e   O v e r" << endl;

	SetPos(3, 10);
	cout << "0 退出   Enter 重新開(kāi)始" << endl;

	while (1)
	{
		int select = _getch();
		if (select == 13)
		{
			system("cls");
			this->Run();
		}
		else if (select == 48)
		{
			system("cls");
			exit(0);
		}
	}

}

void Game::Run()
{
	score = 0;
	_id = 0;
	top = 58;
	_x = 6;
	_y = 1;
	showGround();
	start = clock();
	int new_id = rand() % 19 + 1;

	while (1)
	{
		sharpDraw(_id);
		keyControl();

		if (downSet(_id))
		{
			sharpDraw(-new_id, 1);
			_id = new_id;
			new_id = rand() % 19 + 1;
			sharpDraw(new_id, 1);
			clean();
		}

		SetPos(34, 20);
		cout << score << endl;
	}
}

void Game::sharpDraw(int id, bool show)
{
	int x, y;

	if (show == true)
	{
		if (id > 0)
		{
			for (int i = 0; i < 4; i++)
			{
				x = 19 + sharp[id][2 * i];
				y = 6 + sharp[id][2 * i + 1];
				SetPos(2 * x, y);
				cout << "■";
			}
		}
		else
		{
			for (int i = 0; i < 4; i++)
			{
				x = 19 + sharp[-id][2 * i];
				y = 6 + sharp[-id][2 * i + 1];
				SetPos(2 * x, y);
				cout << "  ";
			}
		}
		return;
	}


	if (id > 0)
	{
		for (int i = 0; i < 4; i++)
		{
			x = _x + sharp[id][2 * i];
			y = _y + sharp[id][2 * i + 1];
			SetPos(2 * x, y);
			cout << "■";
		}
	}
	else
	{
		for (int i = 0; i < 4; i++)
		{
			x = _x + sharp[-id][2 * i];
			y = _y + sharp[-id][2 * i + 1];
			SetPos(2 * x, y);
			cout << "  ";
		}
	}
	return;

}

bool Game::downSet(int id)
{
	if (id == 0)
		return true;

	finish = clock();

	if (finish - start < speed)
	{
		return false;
	}

	start = clock();

	if (!move(DOWN, _id))
	{
		int x, y;
		for (int i = 0; i < 4; i++)
		{
			x = _x + sharp[id][2 * i];
			y = _y + sharp[id][2 * i + 1];
			map[y][x] = 1;

			if (y < top)
			{
				top = y;
			}
			if (top <= 1)
			{
				gameOver();
			}
		}
		_x = 6;
		_y = 1;
		return true;
	}

	sharpDraw(-id);
	_y++;
	sharpDraw(id);
	return false;
}

bool Game::move(int dir, int id)
{
	int x, y;
	switch (dir)
	{
	case UP:
		for (int i = 0; i < 4; i++)
		{
			x = _x + sharp[id][2 * i];
			y = _y + sharp[id][2 * i + 1];
			if (map[y][x] == 1)
			{
				return false;
			}
		}
		break;
	case DOWN:
	{
		for (int i = 0; i < 4; i++)
		{
			x = _x + sharp[id][2 * i];
			y = _y + sharp[id][2 * i + 1];
			if (map[y + 1][x] == 1)
			{
				return false;
			}
		}
	}
	break;
	case RIGHT:
	{
		for (int i = 0; i < 4; i++)
		{
			x = _x + sharp[id][2 * i];
			y = _y + sharp[id][2 * i + 1];
			if (map[y][x + 1] == 1)
			{
				return false;
			}
		}
	}
	break;
	case LEFT:
	{
		for (int i = 0; i < 4; i++)
		{
			x = _x + sharp[id][2 * i];
			y = _y + sharp[id][2 * i + 1];
			if (map[y][x - 1] == 1)
			{
				return false;
			}
		}
	}
	break;
	default:
		break;
	}
	return true;
}

void Game::Turn(int id)
{
	switch (id)
	{
	case 1:id++; break;
	case 2:id--; break;

	case 3: break;

	case 4:id++; break;
	case 5:id++; break;
	case 6:id++; break;
	case 7:id -= 3; break;

	case 8:id++; break;
	case 9:id++; break;
	case 10:id++; break;
	case 11:id -= 3; break;

	case 12:id++; break;
	case 13:id--; break;

	case 14:id++; break;
	case 15:id--; break;

	case 16:id++; break;
	case 17:id++; break;
	case 18:id++; break;
	case 19:id -= 3; break;

	default:
		break;
	}

	if (!move(UP, id))
	{
		return;
	}

	sharpDraw(-_id);
	_id = id;
}

void Game::keyControl()
{
	if (!_kbhit())
		return;

	int key = _getch();

	switch (key)
	{
	case 72:
		Turn(_id);
		break;
	case 80:
		if (move(DOWN, _id))
		{
			sharpDraw(-_id);
			_y++;
		}
		break;
	case 75:
		if (move(LEFT, _id))
		{
			sharpDraw(-_id);
			_x--;
		}
		break;
	case 77:
		if (move(RIGHT, _id))
		{
			sharpDraw(-_id);
			_x++;
		}
		break;
	case 32:
	{
		for (int i = 5; i < 15; i++)
		{
			SetPos(1, i);
			cout << "                            " << endl;
		}

		SetPos(10, 7);
		cout << "游 戲 暫 停" << endl;

		SetPos(3, 10);
		cout << "0 返回菜單  回車(chē) 繼續(xù)游戲" << endl;

		while (1)
		{
			int select = _getch();

			if (select == 13)
			{
				for (int i = 5; i < 15; i++)
				{
					SetPos(1, i);
					cout << "                            " << endl;
				}
				break;
			}
			else if (select == 48)
			{
				system("cls");
				showMenu();
			}
		}

	}
	default:
		break;
	}
}

void Game::clean()
{
	int n = -1;
	int line = -1;
	while (1)
	{
		for (int i = 28; i > 0; i--)
		{
			for (int j = 1; j < 15; j++)
			{
				line = i;
				if (map[i][j] == 0)
				{
					line = -1;
					break;
				}
			}
			if (line != -1)
				break;
		}

		if (line == -1)
			break;

		for (int i = line; i > 0; i--)
		{
			for (int j = 1; j < 15; j++)
			{
				if (i == 1)
					map[i][j] = 0;
				else
				{
					map[i][j] = map[i - 1][j];
					SetPos(2 * j, i);
					if (map[i][j] == 1)
						cout << "■";
					else
						cout << "  ";
				}
			}
		}
		top++;
		n++;
	}

	if (n >= 0)
	{
		score += n * n * 100 + 100;
		if (speed > 100)
			speed = 1000 - score / 10;
	}
}

二、雷霆戰(zhàn)機(jī)游戲源代碼

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<graphics.h>
#include<conio.h>
#include<time.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")
 
 
 
 
typedef struct Node
{
	int x;
	int y;
	struct Node *pnext;
}NODE;
 
#define WINDOW_WIDTH 1024
#define WINDOW_HEIGHT 680
#define WIDTH 480
 
//我機(jī)圖片尺寸
#define pw 86
#define ph 82
 
//敵機(jī)圖片尺寸
#define aw 70
#define ah 70
 
#define boss1w 192
#define boss1h 290
 
 
//敵機(jī)重出現(xiàn)的y坐標(biāo)
#define APStart -ah-20
 
 
 
 
 
NODE *p_bullet = NULL;
//MyPlane
NODE *p_MP = NULL;
//AttackPlane
NODE* p_AP = NULL;
//子彈時(shí)間差
NODE* p_AP2 = NULL;
DWORD b1, b2, b3, b4, b5, b6;
 
IMAGE i_MP,i_MPS,i_AP,i_APS;
IMAGE i_backeve, i_backxing, i_backduicheng, i_backguan,i_backcontrol,i_backgo;
IMAGE i_boss1_1, i_boss1_1S, i_boss1_2, i_boss1_2S;
 
//backxing的左右移動(dòng)
int left = (WINDOW_WIDTH / 2 - WIDTH / 2);
//分?jǐn)?shù)
int score = 0;
//擊毀敵機(jī)的數(shù)量
int kill = 0;
//boss是否出現(xiàn)
int boss1show = 0;
//boss1貼圖開(kāi)關(guān)
int boss1image = 0;
int boss1hp = 20;
 
int line1_x = WINDOW_WIDTH / 2 - 20;
int line1_y = boss1h;
int line2_x = WINDOW_WIDTH / 2 + 20;
int line2_y = boss1h;
 
//Beam只播放一次
int test = 1;
int MP_HP = 1;
 
 
 
void CreateList()
{
	p_MP = (NODE*)malloc(sizeof(NODE));
	p_MP->x = WINDOW_WIDTH / 2 - pw / 2;
	p_MP->y = WINDOW_HEIGHT-100;
	p_MP->pnext = NULL;
 
 
	p_bullet = (NODE*)malloc(sizeof(NODE));
	p_bullet->pnext = NULL;
	b1 = GetTickCount();
 
 
	p_AP = (NODE*)malloc(sizeof(NODE));
	srand((unsigned)time(NULL));
	p_AP->x = rand() % (WIDTH - aw) + (WINDOW_WIDTH / 2 - WIDTH / 2);
	p_AP->y = APStart;
	p_AP->pnext = NULL;
	b3 = GetTickCount();
 
	p_AP2 = (NODE*)malloc(sizeof(NODE));
	p_AP2->x = rand() % (WIDTH - aw) + (WINDOW_WIDTH / 2 - WIDTH / 2);
	p_AP2->y = -350;
	p_AP2->pnext = NULL;
	b5 = GetTickCount();
}
 
void GameBackInit()
{
	loadimage(&i_MP, L"mp.jpg");
	loadimage(&i_MPS, L"mpbit.jpg");
	loadimage(&i_backeve, L"backeve.jpg");
	loadimage(&i_backxing, L"backtaikong.jpg");
	loadimage(&i_AP, L"AP.jpg", aw, ah);
	loadimage(&i_APS, L"APS.jpg", aw, ah);
	loadimage(&i_backduicheng, L"backduicheng.jpg");
	loadimage(&i_backguan, L"backguan.jpg", WIDTH, WINDOW_HEIGHT);
	loadimage(&i_backcontrol, L"backcontrol.jpg",WINDOW_WIDTH,WINDOW_HEIGHT);
	loadimage(&i_boss1_1, L"boss1_1.jpg");
	loadimage(&i_boss1_1S, L"boss1_1S.jpg");
	loadimage(&i_boss1_2, L"boss1_2.jpg");
	loadimage(&i_boss1_2S, L"boss1_1S.jpg");
	loadimage(&i_backgo, L"Gameover.jpg", WINDOW_WIDTH, WINDOW_HEIGHT);
 
 
	putimage(0, 30, &i_backeve);
	Sleep(1000);
	PlaySound(L"baozou.wav", NULL, SND_FILENAME | SND_ASYNC);
 
	putimage(0, 0, &i_backcontrol);
	outtextxy(600, 540, L"【PRESS】 按任意鍵進(jìn)入游戲");
	system("pause");
 
	mciSendString(L"open bgmusic.mp3 alias bg", NULL, 0, NULL);
	mciSendString(L"play bg repeat", NULL, 0, NULL);
 
	putimage((WINDOW_WIDTH / 2 - WIDTH / 2), 0, WIDTH, WINDOW_HEIGHT, &i_backguan, 0, 0, SRCCOPY);
	putimage(0, 0, (WINDOW_WIDTH / 2 - WIDTH / 2), WINDOW_HEIGHT, &i_backduicheng, 0, 100, SRCCOPY);
	putimage((WINDOW_WIDTH / 2 + WIDTH / 2), 0, (WINDOW_WIDTH / 2 - WIDTH / 2), WINDOW_HEIGHT, &i_backduicheng, 1200 - (WINDOW_WIDTH / 2 - WIDTH / 2), 100, SRCCOPY);
	//字體出現(xiàn)的高度
	int text_h = WINDOW_HEIGHT/2;
	Sleep(300);
	BeginBatchDraw();
	for (int i = 0; i < text_h; i++)
	{
		clearrectangle((WINDOW_WIDTH / 2 - WIDTH / 2), 0, (WINDOW_WIDTH / 2 + WIDTH / 2), WINDOW_HEIGHT);
		putimage((WINDOW_WIDTH / 2 - WIDTH / 2), 0-i, WIDTH, text_h , &i_backguan, 0, 0, SRCCOPY);
		putimage((WINDOW_WIDTH / 2 - WIDTH / 2), text_h + i, WIDTH, WINDOW_HEIGHT - (text_h + i), &i_backguan, 0, text_h, SRCCOPY);
		putimage((WINDOW_WIDTH / 2 - WIDTH / 2), text_h - i, WIDTH, 2*i, &i_backxing, left, text_h-i, SRCCOPY);
		FlushBatchDraw();
		Sleep(5);
	}
	EndBatchDraw();
 
	
	Sleep(100);
 
 
}
 
 
void Boss1show()
{
	
	p_AP->y = WINDOW_HEIGHT + 100;
	p_AP2->y = WINDOW_HEIGHT + 100;
 
	if (boss1hp >14)
	{
		putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_1S, NOTSRCERASE);
		putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_1, SRCINVERT);
	}
	else if(boss1hp >= 9 && boss1hp <=14)
	{
		
		if (boss1hp % 2 == 0)
		{
			setlinecolor(0x996666);
			setlinestyle(PS_DOT, 3);
			line(line1_x, line1_y, line1_x, WINDOW_HEIGHT);
			line(line2_x, line2_y, line2_x, WINDOW_HEIGHT);
 
			putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_2S, NOTSRCERASE);
			putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_2, SRCINVERT);
			
		}
		else
		{
			setlinecolor(0xCC6666);
			setlinestyle(PS_DOT, 3);
			line(line1_x, line1_y, line1_x, WINDOW_HEIGHT);
			line(line2_x, line2_y, line2_x, WINDOW_HEIGHT);
 
			
			putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_1S, NOTSRCERASE);
			putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_1, SRCINVERT);
		}
		
		
	}
	else
	{
		
		if (test == 1)
		{
			PlaySound(L"Beam.wav", NULL, SND_FILENAME | SND_ASYNC);
			test++;
		}
		setlinecolor(0xFF6666);
		setlinestyle(PS_DASH, 5);
		line(line1_x, line1_y, line1_x, WINDOW_HEIGHT);
		line(line2_x, line2_y, line2_x, WINDOW_HEIGHT);
		line(WINDOW_WIDTH / 2 - boss1w / 2, boss1h -90, 482, boss1h + 50);
		line(WINDOW_WIDTH / 2 + boss1w / 2, boss1h - 90, 542, boss1h + 50);
		putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_2S, NOTSRCERASE);
		putimage(WINDOW_WIDTH / 2 - boss1w / 2, -boss1h + boss1image, &i_boss1_2, SRCINVERT);
		if ((boss1hp!=8)&&(p_MP->x - line1_x) > -pw && (p_MP->x - line2_x)<0&& (p_MP->y - line1_y)>-ph)			MP_HP = 0;
	}
 
	
	if(boss1image<=boss1h )	boss1image+=2;
 
}
 
void AddNode(int flag)
{
	//后插法,更新第二個(gè)位置
	if (flag == 0)
	{
		NODE* p_new = (NODE*)malloc(sizeof(NODE));
 
		p_new->x = p_MP->x + 35;
		p_new->y = p_MP->y - 45;
 
		p_new->pnext = p_bullet->pnext;
		p_bullet->pnext = p_new;
	}
}
 
 
 
int main()
{
	//create a window
	initgraph(WINDOW_WIDTH, WINDOW_HEIGHT);
 
	setfillcolor(0xFF9999);
 
	GameBackInit();
 
	char key;
	CreateList();
	//批量繪圖
	
	BeginBatchDraw();
	while (1)
	{	
		
		//清畫(huà)板,要不然就成重疊的殘影了
		cleardevice();
 
 
 
		putimage((WINDOW_WIDTH / 2 - WIDTH / 2), 0, WIDTH, WINDOW_HEIGHT, &i_backxing, left, 0, SRCCOPY);
		putimage(0, 0, (WINDOW_WIDTH / 2 - WIDTH / 2), WINDOW_HEIGHT, &i_backduicheng, 0, 100, SRCCOPY);
		putimage((WINDOW_WIDTH / 2 + WIDTH / 2), 0, (WINDOW_WIDTH / 2 - WIDTH / 2), WINDOW_HEIGHT, &i_backduicheng, 1200 - (WINDOW_WIDTH / 2 - WIDTH / 2), 100, SRCCOPY);
 
 
		putimage(p_MP->x, p_MP->y, &i_MPS, NOTSRCERASE);
		putimage(p_MP->x, p_MP->y, &i_MP, SRCINVERT);
		putimage(p_AP->x, p_AP->y, &i_APS, NOTSRCERASE);
		putimage(p_AP->x, p_AP->y, &i_AP, SRCINVERT);
		putimage(p_AP2->x, p_AP2->y, &i_APS, NOTSRCERASE);
		putimage(p_AP2->x, p_AP2->y, &i_AP, SRCINVERT);
		
		
 
		//MP單位時(shí)間發(fā)射子彈的數(shù)量
		b2 = GetTickCount();
		//不能等于,有偏差
		if (b2 - b1 >= 600)
		{
			AddNode(0);
			b1 = b2;
		}
 
 
 
 
		//我方戰(zhàn)機(jī)子彈遞增
		NODE* P = p_bullet->pnext;
 
 
		while (P != NULL)
		{
			if (boss1show == 0)
			{
 
				//確定敵機(jī)重生位置不是在原位置
				int mid;
				//10是子彈寬度,但半個(gè)子彈打中也算,要不然太難了,就右邊是-3,左邊是-7
				if ((P->y - p_AP->y) < ah && (P->y - p_AP->y) >= 0 && (P->x - p_AP->x) < aw -3 && (P->x - p_AP->x) >= -7)
				{
					P->y = APStart -100;
					P = P->pnext;
					p_AP->y = APStart;
					kill++;
 
					PlaySound(L"Bomb.wav", NULL, SND_FILENAME | SND_ASYNC);
					while (1)
					{
						mid = rand() % (WIDTH - aw) + (WINDOW_WIDTH / 2 - WIDTH / 2);
						if (abs(mid - p_AP->x) > aw)
						{
							p_AP->x = mid;
							break;
						}
					}
					
 
				}
				else if((P->y - p_AP2->y) < ah && (P->y - p_AP2->y) >= 0 && (P->x - p_AP2->x) < aw - 3 && (P->x - p_AP2->x) >= -7)
				{
					P->y = APStart -100;
					P = P->pnext;
					p_AP2->y = APStart;
					kill++;
 
					while (1)
					{
						mid = rand() % (WIDTH - aw) + (WINDOW_WIDTH / 2 - WIDTH / 2);
						if (abs(mid - p_AP2->x) > aw)
						{
							p_AP2->x = mid;
							break;
						}
					}
					PlaySound(L"Bomb.wav", NULL, SND_FILENAME | SND_ASYNC);
				}
				else
				{
					fillroundrect(P->x, P->y, P->x + 10, P->y + 35, 10, 30);
					P->y -= 5;
					P = P->pnext;
				}
			}
			else if (boss1show == 1)
			{
				if (boss1image > boss1h)
				{
					if ((P->y) < boss1h && (P->y) >= 0 && (P->x - (WINDOW_WIDTH / 2 - boss1w / 2)) < boss1w - 3 && (P->x - (WINDOW_WIDTH / 2 - boss1w / 2)) >= -7)
					{
						P->y = APStart -100;
						P = P->pnext;
						boss1hp--;
						if (boss1hp>9||boss1hp<7)	PlaySound(L"Bomb.wav", NULL, SND_FILENAME | SND_ASYNC);
					}
					else
					{
						fillroundrect(P->x, P->y, P->x + 10, P->y - 35, 10, 30);
						P->y -= 10;
						P = P->pnext;
					}
 
					TCHAR s_boss1hp[100];
					_stprintf(s_boss1hp, _T("【Boss】HP:%d"), boss1hp);
					outtextxy((WINDOW_WIDTH / 2 + WIDTH / 2) + 45, 200, s_boss1hp);
 
					if (boss1hp <= 0)
					{
						boss1show = 0;
						kill += 50;
					}
				}
				else
				{
					fillroundrect(P->x, P->y, P->x + 10, P->y + 35, 10, 30);
					P->y -= 5;
					P = P->pnext;
				}
			}
		}
 
 
 
 
 
		//AP飛行的速度
		b4 = GetTickCount();
		//不能等于,有偏差
		if (b4- b3 >= 50)
		{
			if (p_AP->y < WINDOW_HEIGHT)
			{
				p_AP->y += 3;
			}
			else
			{
				p_AP->y = 0;
				p_AP->x = rand() % (WIDTH - aw) + (WINDOW_WIDTH / 2 - WIDTH / 2);
			}
			b3 = b4;
		}
 
 
 
 
		//AP2飛行的速度
		b6 = GetTickCount();
		//不能等于,有偏差
		if (b6 - b5 >= 50)
		{
			if (p_AP2->y < WINDOW_HEIGHT)
			{
				p_AP2->y += 3;
			}
			else
			{
				p_AP2->y = 0;
				p_AP2->x = rand() % (WIDTH - aw) + (WINDOW_WIDTH / 2 - WIDTH / 2);
			}
			b5 = b6;
		}
		
		
 
 
 
		if (kill==10&& boss1hp > 0) boss1show = 1;
 
 
 
 
		if (boss1show==1)
		{
			Boss1show();
		}
 
 
 
 
		if ((p_MP->x - p_AP->x) > -pw && (p_MP->x - p_AP->x)<pw && (p_MP->y - p_AP->y)>-ph && (p_MP->y - p_AP->y)<ph )			MP_HP = 0;
		else if ((p_MP->x - p_AP2->x) > -pw && (p_MP->x - p_AP2->x)<pw && (p_MP->y - p_AP2->y)>-ph && (p_MP->y - p_AP2->y)<ph)	MP_HP = 0;
		else if (boss1show==1&&boss1image>boss1h&&(p_MP->x-(WINDOW_WIDTH / 2 - boss1w / 2)) >-pw && (p_MP->x-(WINDOW_WIDTH / 2 + boss1w / 2))<pw && p_MP->y<boss1h)		MP_HP = 0;
		
		if (MP_HP == 0)
		{
			mciSendString(L"close bg", NULL, 0, NULL);
			mciSendString(L"open bggo.mp3 alias bg", NULL, 0, NULL);
			mciSendString(L"play bg repeat", NULL, 0, NULL);
			putimage(0, 0, &i_backgo, SRCCOPY);
			outtextxy(430, 540, L"3秒后自動(dòng)退出");
			EndBatchDraw();
			Sleep(3000);
			closegraph();
			return 0;
		}
 
		
		TCHAR s_score[100];
		_stprintf(s_score, _T("你的分?jǐn)?shù):%d"), kill);
		outtextxy((WINDOW_WIDTH / 2 + WIDTH / 2) + 50, WINDOW_HEIGHT/2, s_score);
		
		
		
 
 
		FlushBatchDraw();
 
		
		//子彈飛行速度以及按鍵延遲等
		Sleep(15);
 
 
 
		if (kbhit())
		{
			key = getch();
			switch (key)
			{
			case 72://上
				p_MP->y -= 5;
				break;
			case 80://下
				p_MP->y += 5;
				break;
			case 75://左
				p_MP->x -= 5;
				left -= 5;
				break;
			case 77://右
				p_MP->x += 5;
				left += 5;
				break;
			}
		}
 
 
 
		if (p_MP->x<(WINDOW_WIDTH / 2 - WIDTH / 2)) 
			p_MP->x = (WINDOW_WIDTH / 2 - WIDTH / 2);
		if (p_MP->x>(WINDOW_WIDTH / 2 + WIDTH / 2 - pw))
			p_MP->x = (WINDOW_WIDTH / 2 + WIDTH / 2 - pw);
		if (p_MP->y<0 ) 
			p_MP->y = 0;
		if (p_MP->y>WINDOW_HEIGHT - ph) 
			p_MP->y = WINDOW_HEIGHT - ph;
 
 
		if (left < 0)
			left = 0;
		if (left>1280 - WIDTH)
			left = 1280 - WIDTH;
 
	}
	
	EndBatchDraw();
	closegraph();
	return 0;
}

三、五子棋經(jīng)典游戲源代碼

#define _CRT_SECURE_NO_WARNINGS
#define MAX_ROW 3
#define MAX_COL 3
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void init(char chessBoard[MAX_ROW][MAX_COL]) {
	for (int row = 0; row < MAX_ROW; row++) {
		for (int col = 0; col < MAX_COL; col++) {
			chessBoard[row][col] = ' ';
		}
	}
}
void print_chessBoard(char chessBoard[MAX_ROW][MAX_COL]) {
	printf("+---+---+---+\n");
	for (int row = 0; row < MAX_ROW; row++) {
		printf("| %c | %c | %c |\n", chessBoard[row][0],
			chessBoard[row][1], chessBoard[row][2]);
		printf("+---+---+---+\n");
	}
}
void playerMove(char chessBoard[MAX_ROW][MAX_COL]) {
	while (1) {
		int row = 0;
		int col = 0;
		printf("請(qǐng)輸入坐標(biāo)(row col):");
		scanf("%d %d", &row, &col);
		if (row < 0 || row >= MAX_ROW || col < 0 || col >= MAX_COL) {
			printf("您的坐標(biāo)不在合法范圍內(nèi) [0, 2],請(qǐng)重新輸入:\n");
			continue;
		}
		if (chessBoard[row][col] != ' ') {
			printf("您的坐標(biāo)位置已經(jīng)有子了!\n");
			continue;
		}
		chessBoard[row][col] = 'x';
		break;
	}
}
void computerMove(char chessBoard[MAX_ROW][MAX_COL]) {
	while (1) {
		int row = rand() % MAX_ROW;
		int col = rand() % MAX_COL;
		if (chessBoard[row][col] != ' ') {
			continue;
		}
		chessBoard[row][col] = 'o';
		break;
	}
}
int isFull(char chessBoard[MAX_ROW][MAX_COL]) {
	for (int row = 0; row < MAX_ROW; row++) {
		for (int col = 0; col < MAX_COL; col++) {
			if (chessBoard[row][col] == ' ') {
				return 0;
			}

		}
	}
	return 1;
}
char isWin(char chessBoard[MAX_ROW][MAX_COL]) {
	for (int row = 0; row < MAX_ROW; row++) {
		if (chessBoard[row][0] != ' '
			&& chessBoard[row][0] == chessBoard[row][1]
			&& chessBoard[row][0] == chessBoard[row][2]) {
			return chessBoard[row][0];
		}
	}
	for (int col = 0; col < MAX_COL; col++) {
		if (chessBoard[0][col] != ' '
			&& chessBoard[0][col] == chessBoard[1][col]
			&& chessBoard[0][col] == chessBoard[2][col]) {
			return chessBoard[0][col];
		}
	}
	if (chessBoard[0][0] != ' '
		&& chessBoard[0][0] == chessBoard[1][1]
		&& chessBoard[0][0] == chessBoard[2][2]) {
		return chessBoard[0][0];
	}
	if (chessBoard[2][0] != ' '
		&& chessBoard[2][0] == chessBoard[1][1]
		&& chessBoard[2][0] == chessBoard[0][2]) {
		return chessBoard[2][0];
	}
	if (isFull(chessBoard)) {
		return 'q';
	}
	return ' ';
}
void game() {
	char chessBoard[MAX_ROW][MAX_COL] = { 0 };
	init(chessBoard);
	char winner = ' ';
	while (1) {
		system("cls");
		print_chessBoard(chessBoard);
		playerMove(chessBoard);
		winner = isWin(chessBoard);
		if (winner != ' ') {
			break;
		}
		computerMove(chessBoard);
		winner = isWin(chessBoard);
		if (winner != ' ') {
			break;
		}
	}
	print_chessBoard(chessBoard);
	if (winner == 'x') {
		printf("恭喜您, 您贏了!\n");
	}
	else if (winner == 'o') {
		printf("哈哈,您連人工智障都下不過(guò)!\n");
	}
	else {
		printf("您只能和人工智障打平手!!\n");
	}
}

int menu() {
	printf("--------------------------\n");
	printf("--------1.開(kāi)始游戲--------\n");
	printf("--------0.退出游戲--------\n");
	printf("--------------------------\n");
	int choice = 0;
	printf("請(qǐng)輸入你的選擇:");
	scanf("%d", &choice);
	return choice;
}
int main()
{
	srand((unsigned int)time(0));
	while (1) {
		int choice = menu();
		if (choice == 1) {
			game();
		}
		else if (choice == 0) {
			printf("退出游戲,GOODBYE!!!!!\n");
			break;
		}
		else {
			printf("輸入錯(cuò)誤!請(qǐng)重新輸入!\n");
			continue;
		}
	}
	system("pause");
	return 0;
}

四、貪吃蛇完整版EN

// 必要的頭文件 
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <time.h>
#include <windows.h>
#include <string.h>


// 定義標(biāo)記上下左右的明示常量 
#define UP 1
#define DOWN 2
#define LEFT 3
#define RIGHT 4
#define ESC 5 
#define FOOD 10
// 定義表示位置的結(jié)構(gòu)體類(lèi)型
typedef struct snake{
	int x;
	int y;
	struct snake *next;
}snake;
// 定義全局變量 
int score = 0; // 當(dāng)前得分
int speed = 200; // 存儲(chǔ)當(dāng)前速度
int status;
snake *tail, *head; // 存儲(chǔ)蛇頭蛇尾 
snake *food, *q;// q用于遍歷鏈表 

HANDLE hOUT;
void gotoxy(int x, int y); // 設(shè)置光標(biāo)位置 
int choice(void); // 載入游戲界面
int color(int c); // 設(shè)置字體顏色 
void printGame(void); // 打印游戲界面 
void printSnake(void); // 打印蛇身
void printFood(void); // 打印食物
void printTips(void); // 打印提示
void snakeMove(void); // 主操作函數(shù) 
int biteSelf(void); // 判斷是否咬到了自己
int encounterWall(void); // 判斷是否撞墻 
void keyboardControl(void); // 獲取擊鍵 
void speedUp(void); // 加速
void speedDown(void); // 減速
int endGame(void); // 結(jié)束函數(shù); 
char *s_gets(char *st, int n); // 讀取字符
void frees(snake *); // 釋放內(nèi)存 

int main(int argc, char *argv[]){
	while (1)
	{
		if (choice() == 1)
			keyboardControl();
		else
		{
			gotoxy(5, 15);
			printf("按任意鍵返回");
			getchar(); // 去除前一個(gè)前導(dǎo)換行 
			while (1)
			{
				if (getchar())
				{
					system("cls");
					break;
				}
			}
		}
	}
	frees(head);

	return 0;
}

void gotoxy(int x, int y)
{
	COORD c;
	c.X = x;
	c.Y = y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}

int choice(void)
{
	int yourchoice;
	// 畫(huà)出界面 
	gotoxy(35, 5);
	color(11);
	printf("\t貪吃蛇大作戰(zhàn)\n");
	printf("\n\n");
	color(13);
	printf("\t\t★★★★★★★★  Snake!");
	printf("\t\t★★★★★★★★  Snake!");
	gotoxy(25, 15);
	color(12);
	printf("1.進(jìn)入游戲\t2.查看說(shuō)明\t3.退出游戲\n");
	color(11);
	printf("請(qǐng)選擇:");
	scanf("%d", &yourchoice);
	switch (yourchoice)
	{
	case 1:
		system("cls");
		// 初始化 
		printGame();
		printSnake();
		printFood();
		break;
	case 2:
		system("cls");
		printTips();
		break;
	case 3:
		system("cls");
		gotoxy(30, 10);
		color(11);
		printf("Bye!");
		exit(0);
	default:
		system("cls");
		printf("沒(méi)有此序號(hào),請(qǐng)輸入1,2或3\n");
		Sleep(2000);
		system("cls");
	}
	return yourchoice;
}
int color(int c)
{
	SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c);        //更改文字顏色
	return 0;
}
void printGame()
{
	int i, j;
	gotoxy(5, 5);
	printf("游戲載入中...請(qǐng)稍后");
	Sleep(2000);
	system("cls");

	// 打印上下界面
	for (i = 0; i <= 50; i += 2)
	{
		gotoxy(i, 0);
		printf("□");
		gotoxy(i, 25);
		printf("□");
	}
	// 打印左右界面
	for (i = 0; i <= 25; i += 1)
	{
		gotoxy(0, i);
		printf("□");
		gotoxy(50, i);
		printf("□");
	}
	// 打印中間網(wǎng)格
	for (i = 1; i <= 24; i += 1)
	{
		for (j = 2; j <= 48; j += 2)
		{
			gotoxy(j, i);
			color(11);
			printf("■");
		}
	}
	// 打印右側(cè)的規(guī)則和計(jì)分欄
	gotoxy(60, 13);
	printf("當(dāng)前分?jǐn)?shù):%d分,當(dāng)前速度%d", score, speed);
	gotoxy(60, 15);
	printf("用↑ ↓ ← →分別控制蛇的移動(dòng)\n");
	gotoxy(60, 18);
	printf("每次獲取食物加10分  按下F1加速,F2減速,空格暫停\n");
	gotoxy(60, 20);
	printf("不能撞墻和咬到自己!");
	gotoxy(60, 22);
	printf("速度不低于100,不高于300");
}
void printSnake(void)
{
	int i;
	// 設(shè)定蛇尾(16,13),頭插入,初始向右 
	tail = (snake*)malloc(sizeof(snake));
	tail->x = 16;
	tail->y = 13;
	tail->next = NULL;
	// 設(shè)定初始蛇長(zhǎng)是4
	for (i = 1; i <= 4; i++)
	{
		head = (snake*)malloc(sizeof(snake));
		head->next = tail;
		head->x = 16 + 2 * i;
		head->y = 13;
		tail = head; // 頭成為尾
	}
	// 輸出蛇身
	while (tail->next)
	{
		gotoxy(tail->x, tail->y);
		color(14);
		printf("★");
		tail = tail->next;
	}
}
void printFood(void)
{
	srand((unsigned)time(NULL)); // 利用時(shí)鐘修改種子 
	food = (snake*)malloc(sizeof(snake));
	food->x = 1; // 初始化x坐標(biāo) 
	while (food->x % 2 && food->x)
	{
		food->x = rand() % 46 + 2;// 2-48 
	}
	food->y = rand() % 23 + 1; // 1-24 
	q = head; // 不改變頭遍歷鏈表 
	while (q->next)
	{
		if (q->x == food->x && q->y == food->y)
		{
			free(food);
			printFood();
		}
		else
		{
			gotoxy(food->x, food->y);
			color(12);
			printf("●");
			break;
		}
	}
}
void printTips(void)
{
	color(11);
	printf("***********Tips************\n");
	printf("1.采用合理的速度可以獲得更高的分?jǐn)?shù)哦!\n");
	printf("2.一定不要撞到自己或者兩邊的墻!\n");
	printf("3.游戲過(guò)程中按ESC退出游戲!\n");
}
void snakeMove(void)
{
	snake *snakenext;
	snakenext = (snake*)malloc(sizeof(snake));
	if (biteSelf())
	{
		gotoxy(60, 11);
		printf("咬到自己啦!");
		free(snakenext);
		Sleep(1500);
		system("cls");
		exit(0);
	}
	else if (encounterWall())
	{
		gotoxy(60, 11);
		printf("撞到墻啦!");
		free(snakenext);
		Sleep(1500);
		system("cls");
		exit(0);
	}
	else
	{
		// 前兩個(gè)條件判斷完成才開(kāi)始移動(dòng) 
		Sleep(350 - speed);
		if (status == UP)
		{
			snakenext->x = head->x;
			snakenext->y = head->y - 1;
			snakenext->next = head;
			head = snakenext;
			q = head;
			if (snakenext->x == food->x && snakenext->y == food->y)
			{
				while (q)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				score += FOOD;
				gotoxy(60, 13);
				printf("當(dāng)前分?jǐn)?shù):%d分,當(dāng)前速度%d", score, speed);
				printFood();
			}
			else
			{
				while (q->next->next)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				gotoxy(q->next->x, q->next->y);
				color(11);
				printf("■");
				free(q->next);
				q->next = NULL;
			}
		}
		else if (status == DOWN)
		{
			snakenext->x = head->x;
			snakenext->y = head->y + 1;
			snakenext->next = head;
			head = snakenext;
			q = head;
			if (snakenext->x == food->x && snakenext->y == food->y)
			{
				while (q)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				score += FOOD;
				gotoxy(60, 13);
				printf("當(dāng)前分?jǐn)?shù):%d分,當(dāng)前速度%d", score, speed);
				printFood();
			}
			else
			{
				while (q->next->next)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				gotoxy(q->next->x, q->next->y);
				color(11);
				printf("■");
				free(q->next);
				q->next = NULL;
			}
		}
		else if (status == LEFT)
		{
			snakenext->x = head->x - 2;
			snakenext->y = head->y;
			snakenext->next = head;
			head = snakenext;
			q = head;
			if (snakenext->x == food->x && snakenext->y == food->y)
			{
				while (q)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				score += FOOD;
				gotoxy(60, 13);
				printf("當(dāng)前分?jǐn)?shù):%d分,當(dāng)前速度%d", score, speed);
				printFood();
			}
			else
			{
				while (q->next->next)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				gotoxy(q->next->x, q->next->y);
				color(11);
				printf("■");
				free(q->next);
				q->next = NULL;
			}
		}
		else if (status == RIGHT)
		{
			snakenext->x = head->x + 2;
			snakenext->y = head->y;
			snakenext->next = head;
			head = snakenext;
			q = head;
			if (snakenext->x == food->x && snakenext->y == food->y)
			{
				while (q)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				score += FOOD;
				gotoxy(60, 13);
				printf("當(dāng)前分?jǐn)?shù):%d分,當(dāng)前速度%d", score, speed);
				printFood();
			}
			else
			{
				while (q->next->next)
				{
					gotoxy(q->x, q->y);
					color(14);
					printf("★");
					q = q->next;
				}
				gotoxy(q->next->x, q->next->y);
				color(11);
				printf("■");
				free(q->next);
				q->next = NULL;
			}
		}
	}
}
int biteSelf(void)
{
	int x = 0; // 默認(rèn)未咬到自己
	q = head->next;
	// 遍歷蛇身 
	while (q->next)
	{
		if (q->x == head->x && q->y == head->y)
		{
			x = 1;
		}
		q = q->next;
	}

	return x;
}
int encounterWall(void)
{
	int x = 0; // 默認(rèn)未撞到墻

	if (head->x == 0 || head->x == 50 || head->y == 0 || head->y == 25)
		x = 1;

	return x;
}
void keyboardControl(void)
{
	status = RIGHT; // 初始蛇向右移動(dòng)
	while (1)
	{
		if (GetAsyncKeyState(VK_UP) && status != DOWN) // GetAsyncKeyState函數(shù)用來(lái)判斷函數(shù)調(diào)用時(shí)指定虛擬鍵的狀態(tài)
		{
			status = UP;           //如果蛇不是向下前進(jìn)的時(shí)候,按上鍵,執(zhí)行向上前進(jìn)操作
		}
		else if (GetAsyncKeyState(VK_DOWN) && status != UP) // 如果蛇不是向上前進(jìn)的時(shí)候,按下鍵,執(zhí)行向下前進(jìn)操作
		{
			status = DOWN;
		}
		else if (GetAsyncKeyState(VK_LEFT) && status != RIGHT) // 如果蛇不是向右前進(jìn)的時(shí)候,按左鍵,執(zhí)行向左前進(jìn)
		{
			status = LEFT;
		}
		else if (GetAsyncKeyState(VK_RIGHT) && status != LEFT) // 如果蛇不是向左前進(jìn)的時(shí)候,按右鍵,執(zhí)行向右前進(jìn)
		{
			status = RIGHT;
		}
		if (GetAsyncKeyState(VK_SPACE))// 空格暫停 
		{
			while (1)
			{
				Sleep(300);
				if (GetAsyncKeyState(VK_SPACE)) // 再次按空格改變狀態(tài) 
				{
					break;
				}

			}
		}
		else if (GetAsyncKeyState(VK_ESCAPE))
		{
			status = ESC; // 按esc鍵,直接到結(jié)束界面
			if (endGame())
			{
				Sleep(500);
				system("cls");
				break;
			}
		}
		else if (GetAsyncKeyState(VK_F1)) // 按F1鍵,加速
		{
			speedUp();
			gotoxy(60, 13);
			printf("當(dāng)前分?jǐn)?shù):%d分,當(dāng)前速度%d", score, speed);
		}
		else if (GetAsyncKeyState(VK_F2)) // 按F2鍵,減速
		{
			speedDown();
			gotoxy(60, 13);
			printf("當(dāng)前分?jǐn)?shù):%d分,當(dāng)前速度%d", score, speed);
		}
		snakeMove();
	}
}
void speedUp(void)
{
	if (speed <= 280)
		speed += 20;
}
void speedDown(void)
{
	if (speed >= 120)
		speed -= 20;
}
int endGame(void)
{
	char x = 0;
	char judge[5];

	getchar();
	gotoxy(60, 9);
	printf("確定退出嗎?(Yes/No)");
	gotoxy(60, 11);
	s_gets(judge, 5);

	if (strcmp(judge, "Yes") == 0)
	{
		Sleep(250);
		system("cls");
		gotoxy(40, 11);
		printf("\tBye!");
		x = 1;
	}
	else
		x = 0;

	return x;
}
char *s_gets(char *st, int n)
{
	char *ret_val;
	char *find;

	gotoxy(60, 11);
	ret_val = fgets(st, n, stdin);
	if (ret_val)
	{
		find = strchr(st, '\n');
		if (find)
			*find = '\0';
		else
		while (getchar() != '\n')
			continue;
	}

	return ret_val;
}
void frees(snake *s)
{
	snake *current = s;

	while (current)
	{
		current = s;
		s = current->next;
		free(current);
	}
}

END

源代碼比較長(zhǎng)只能先放上去這么多,還有更多的小項(xiàng)目?加一下我的c/c++編程資料交流Q群:214574728文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-509611.html

到了這里,關(guān)于C語(yǔ)言經(jīng)典游戲代碼大全(珍藏版)的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶(hù)投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼,基于pygame+pymunk

    Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼,基于pygame+pymunk

    Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼,基于pygame+pymunk 程序依賴(lài):pygame 2.0.1, pymunk 5.5.0 直接運(yùn)行main.py 完整代碼下載地址:Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼 tool.py 完整代碼下載地址:Python版經(jīng)典小游戲憤怒的小鳥(niǎo)源代碼

    2024年02月16日
    瀏覽(104)
  • 輕松上手Jackjson(珍藏版)

    輕松上手Jackjson(珍藏版)

    雖然現(xiàn)在市面上有很多優(yōu)秀的json解析庫(kù),但 Spring默認(rèn)采用Jackson解析Json。 本文將通過(guò)一系列通俗易懂的代碼示例,帶你逐步掌握 Jackson 的基礎(chǔ)用法、進(jìn)階技巧以及在實(shí)際項(xiàng)目中的應(yīng)用場(chǎng)景。 Jackson 是當(dāng)前用的比較廣泛的,用來(lái)序列化和反序列化 json 的 Java 的開(kāi)源框架。 什么

    2024年04月08日
    瀏覽(27)
  • Python經(jīng)典游戲:貪吃蛇

    Python經(jīng)典游戲:貪吃蛇

    Python108款,小游戲集合,總有一個(gè)是你想要的 中國(guó)象棋 像素鳥(niǎo) 五子棋 24點(diǎn)小游戲 貪吃蛇 掃雷 俄羅斯方塊 魂斗羅 消消樂(lè) 坦克大戰(zhàn) 外星人入侵 湯姆貓 斗地主 乒乓球 推箱子 植物大戰(zhàn)僵尸 圍棋 超級(jí)瑪麗 飛機(jī)大戰(zhàn) 迷宮 滑雪 吃豆人…等等 (需要的回復(fù)666或點(diǎn)擊最下方的歷史

    2024年04月22日
    瀏覽(33)
  • 【珍藏版】linux lsof命令詳解

    【珍藏版】linux lsof命令詳解

    一、lsof命令簡(jiǎn)介 lsof(list open files)是一個(gè)列出當(dāng)前系統(tǒng)打開(kāi)文件的工具。在linux環(huán)境下,任何事物都以文件的形式存在,通過(guò)文件不僅僅可以訪問(wèn)常規(guī)數(shù)據(jù),還可以訪問(wèn)網(wǎng)絡(luò)連接和硬件。所以如傳輸控制協(xié)議 (TCP) 和用戶(hù)數(shù)據(jù)報(bào)協(xié)議 (UDP) 套接字等,系統(tǒng)在后臺(tái)都為該應(yīng)用程序分

    2024年02月13日
    瀏覽(17)
  • python游戲開(kāi)發(fā)入門(mén)經(jīng)典教程,python游戲開(kāi)發(fā)引擎

    python游戲開(kāi)發(fā)入門(mén)經(jīng)典教程,python游戲開(kāi)發(fā)引擎

    大家好,給大家分享一下python游戲開(kāi)發(fā)入門(mén)經(jīng)典教程,很多人還不知道這一點(diǎn)。下面詳細(xì)解釋一下?,F(xiàn)在讓我們來(lái)看看! 消消樂(lè)小游戲相信大家都玩過(guò),大人小孩都喜歡玩的一款小游戲,那么基于程序是如何實(shí)現(xiàn)的呢?今天帶大家,用python+pygame來(lái)實(shí)現(xiàn)一下這個(gè)花里胡哨的消

    2024年02月02日
    瀏覽(22)
  • ??創(chuàng)意網(wǎng)頁(yè):貪吃蛇游戲 - 創(chuàng)造一個(gè)經(jīng)典的小游戲

    ??創(chuàng)意網(wǎng)頁(yè):貪吃蛇游戲 - 創(chuàng)造一個(gè)經(jīng)典的小游戲

    ? 博主: 命運(yùn)之光 ? ?? 專(zhuān)欄: Python星辰秘典 ?? 專(zhuān)欄: web開(kāi)發(fā)(簡(jiǎn)單好用又好看) ?? 專(zhuān)欄: Java經(jīng)典程序設(shè)計(jì) ?? 博主的其他文章: 點(diǎn)擊進(jìn)入博主的主頁(yè) 前言: 歡迎踏入我的Web項(xiàng)目專(zhuān)欄,一段神奇而令人陶醉的數(shù)字世界! ?? 在這里,我將帶您穿越時(shí)空,揭開(kāi)屬于

    2024年02月14日
    瀏覽(27)
  • 【面試經(jīng)典150 | 矩陣】生命游戲

    【面試經(jīng)典150 | 矩陣】生命游戲

    本專(zhuān)欄專(zhuān)注于分析與講解【面試經(jīng)典150】算法,兩到三天更新一篇文章,歡迎催更…… 專(zhuān)欄內(nèi)容以分析題目為主,并附帶一些對(duì)于本題涉及到的數(shù)據(jù)結(jié)構(gòu)等內(nèi)容進(jìn)行回顧與總結(jié),文章結(jié)構(gòu)大致如下,部分內(nèi)容會(huì)有增刪: Tag:介紹本題牽涉到的知識(shí)點(diǎn)、數(shù)據(jù)結(jié)構(gòu); 題目來(lái)源:

    2024年02月07日
    瀏覽(25)
  • 面試經(jīng)典150題——生命游戲

    面試經(jīng)典150題——生命游戲

    2.1 思路一——暴力求解 之所以先暴力求解,是因?yàn)槲议_(kāi)始也沒(méi)什么更好的思路,所以就先寫(xiě)一種解決方案,沒(méi)準(zhǔn)寫(xiě)著寫(xiě)著就來(lái)新的靈感了。暴力求解思路還是很簡(jiǎn)單的,就是嘗試遍歷面板的每個(gè)格子,判斷其周?chē)藗€(gè)位置的狀態(tài)(對(duì)于邊角需要特殊處理),根據(jù)邊角種存在

    2024年02月21日
    瀏覽(22)
  • Python經(jīng)典游戲 喚醒你童年記憶

    Python經(jīng)典游戲 喚醒你童年記憶

    ??游戲規(guī)則:使用方向鍵控制蛇去吃球。每吃一次球,蛇身就長(zhǎng)出一格。吃到自己或者出界游戲結(jié)束。 游戲演示: ??游戲規(guī)則:用箭頭導(dǎo)航控制黃色吃豆人吃掉所有白色食物,若被紅色的鬼魂抓住,游戲結(jié)束。 游戲演示: ??游戲規(guī)則:點(diǎn)擊屏幕發(fā)射炮彈。炮彈在它的路徑

    2024年02月03日
    瀏覽(24)
  • 【pygame游戲開(kāi)發(fā)】這幾個(gè)經(jīng)典游戲,小紅書(shū)Python面試題目

    【pygame游戲開(kāi)發(fā)】這幾個(gè)經(jīng)典游戲,小紅書(shū)Python面試題目

    pygame.time.set_timer(change_hole_event, 800) mole = Mole(cfg.MOLE_IMAGEPATHS, hole_pos) hammer = Hammer(cfg.HAMMER_IMAGEPATHS, (500, 250)) clock = pygame.time.Clock() your_score = 0 flag = False init_time = pygame.time.get_ticks() while True: time_remain = round((61000 - (pygame.time.get_ticks() - init_time)) / 1000.) if time_remain == 40 and not flag: hole

    2024年04月25日
    瀏覽(117)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包