?? game.h
字號(hào):
#pragma once
#include <stdio.h>
#include <list>
#include "draw.h"
#include "input.h"
#include "sound.h"
using namespace std;
#define WAY_UP 1 // 運(yùn)動(dòng)的方向
#define WAY_DOWN 0
#define WAY_LEFT 3
#define WAY_RIGHT 2
#define STATUS_FREE 0 // 玩家的狀態(tài)
#define STATUS_MOVE 1
#define STATUS_DIED 2
#define STATUS_DELAY 3
#define CAN_BLOCK 0 // 玩家可執(zhí)行的動(dòng)作
#define CAN_MOVE 1
#define CAN_PUSH 2
#define CAN_KICK 3
#define TYPE_NULL 0 // 玩家的身份標(biāo)識(shí)
#define TYPE_USER 1
#define TYPE_USEROTHER 2
#define TYPE_COMPUTER 3
#define MaxVertexNum 13*15
#define PLAYER_NUM 8
#define INFINITY 1000 // 大于13*15即可
#define SoundEffectNum 9 // 音效個(gè)數(shù)
#define START 0 // 音效的編號(hào)
#define WIN 1
#define DEUCE 2
#define LOST 3
#define LAY 4
#define DETONATION 5
#define APPEAR 6
#define GET 7
#define DIE 8
#define GAME_FREE 0
#define GAME_START 1
#define GAME_WIN 2
#define GAME_DEUCE 3
#define GAME_LOST 4
#define DISPLAYCOUNTER 300
struct PLAYER
{
int x; // x坐標(biāo)(以像素為單位)
int y; // y坐標(biāo)(以像素為單位)
int way; // 主角方向
int bomb; // 炸彈數(shù)
bool kick; // 能踢泡泡
bool cast; // 投擲、扔泡泡
bool pin; // 救命針
int speed; // 速度(像素/幀,取值范圍 1 -- 10)
int step; // 步長(zhǎng)
int frame; // 動(dòng)畫貞數(shù)
int counter; // 計(jì)數(shù)器
int status; // 狀態(tài)
int power; // 泡泡的威力
int type; // 主角類型
int presswaykey;// 連續(xù)按住方向鍵計(jì)數(shù)(因?yàn)橥葡渥踊蚴翘吲菖菪枰欢螘r(shí)間)
int image; // 圖像編號(hào)
};
struct ITEM
{
int type; // 物體的類型
int status; // 當(dāng)前的狀態(tài),針對(duì)不同的物體,有不同的解釋
int xoffset; // 針對(duì)箱子表示x偏移,針對(duì)爆炸效果表示爆炸效果當(dāng)前的長(zhǎng)度
int yoffset; // 針對(duì)箱子表示y偏移
int way; // 移動(dòng)時(shí)的方向(針對(duì)箱子)
int counter; // 計(jì)數(shù)器(針對(duì)箱子)
int move; // 是否移動(dòng)(針對(duì)箱子)
int tag; // 附屬品
int who; // 此泡泡是誰(shuí)擺放的
};
struct MOVEBOMB
{
int x; // x坐標(biāo)(以像素為單位)
int y; // y坐標(biāo)(以像素為單位)
int way; // 運(yùn)動(dòng)方向
int mode; // 0:踢,1:扔
int tox; // 目標(biāo)點(diǎn)x坐標(biāo),如果是踢的話則此參數(shù)無意義,扔的話則事先算好目標(biāo)點(diǎn)當(dāng)落下時(shí)如果發(fā)現(xiàn)有東西,則再算一次
int toy; // 目標(biāo)點(diǎn)y坐標(biāo)
int counter; // 計(jì)數(shù)器
int offset; // 扔泡泡的時(shí)候y方向上的偏移
int power; // 威力
bool addorsub; // 控制偏移量增加或是減少,true表示增加
int who; // 此泡泡是誰(shuí)擺放的
};
class CGame
{
public:
CGame(void);
~CGame(void);
bool Create(HWND hWnd, HINSTANCE hInstance);
HRESULT Run();
HRESULT ChangeDisplayMode( BOOL bWindowed );
HRESULT RestoreSurfaces();
void ResetMapInfor();
void DoInput(); // 處理玩家輸入
void DoMove(); // 處理角色移動(dòng)
void DoKick(); // 處理踢泡泡
void DoCast(); // 處理扔泡泡
void DoProperty(); // 處理道具
void DoKill(); // 判斷對(duì)方是否已被炸,若是,則經(jīng)過時(shí)可立刻殺死對(duì)方
void SetBlast(int i,int j);
bool FindPropertyForGet(int PlayerIndex); // 查看道具的位置,若找到則去吃
bool FindAdversaryForAttack(int PlayerIndex); // 查找對(duì)手的位置,找到后去攻擊
bool FindTeammateForRescue(int PlayerIndex); // 查找需要營(yíng)救的隊(duì)友的位置
bool FindSafety(int PlayerIndex); // 查找一個(gè)安全的位置,找到后去躲藏
bool FindLay(int PlayerIndex); // 查找一個(gè)放置炸彈的位置(能炸對(duì)手就炸對(duì)手,否則炸物體,以便得到道具)
bool FindAddress(int PlayerIndex,int s); // 查找一個(gè)放置
int GetDestroyNumber(int PlayerIndex,int x,int y); // 得到某個(gè)玩家在(x,y)處方下炸彈可以摧毀的物體數(shù)目
bool IsDangerous(int player_x,int player_y); // 檢查當(dāng)前是否有危險(xiǎn)(輸入?yún)?shù)為玩家的坐標(biāo))
bool IsRescue(); // 檢查現(xiàn)在是否要救人
void SetGraph(int PlayerIndex); // 設(shè)置圖
void Dijkstra(int G[MaxVertexNum][MaxVertexNum], int D[MaxVertexNum], int P[MaxVertexNum],int s); // 迪杰斯特拉算法
HWND m_hWnd;
BOOL m_bWindowed;
CDraw* m_pDraw;
CSurface* m_pSurface;
CSurface* m_pSurfacePlayer;
CSurface* m_pSurfaceWord;
CInput* m_pInput;
CSound* m_pSound;
CWavMidi* m_pSoundEffect[SoundEffectNum];
CMP3* m_pBackgroundMusic;
PLAYER m_Player[PLAYER_NUM]; // 存放所有玩家信息
bool m_PlayerLay[PLAYER_NUM]; // 是否放炸彈
int m_LayX[PLAYER_NUM]; // 炸彈擺放位置x
int m_LayY[PLAYER_NUM]; // 炸彈擺放位置y
int m_Delay[PLAYER_NUM]; // 躲避危險(xiǎn)的延時(shí)時(shí)間
int m_GameState;
int m_GameCounter;
ITEM m_ScreenItem[13][15]; // 存放背景信息
list<MOVEBOMB> m_bombKick; // 存放踢出來的泡泡信息
list<MOVEBOMB> m_bombCast; // 存放扔出來的泡泡信息
int m_Graph[MaxVertexNum][MaxVertexNum]; // 圖的鄰接矩陣,此處用二維數(shù)組表示
int m_Distance[MaxVertexNum]; // 源點(diǎn)到其它各頂點(diǎn)的最短距離
int m_Path[MaxVertexNum]; // 源點(diǎn)到其它各頂點(diǎn)的最短路徑
BOOL m_bHelp;
DWORD m_timeNew;
DWORD m_timeOld;
DWORD m_counter;
float m_fps;
POINT m_CursorPos; // 鼠標(biāo)坐標(biāo)
int test; // must delete!
};
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -