我的VC++ RPG游戏紫日2037源代码开放

o_2037.JPG
刚学游戏编程时写的程序,对初学者可能有用,希望大家喜欢 :-)

执行文件下载:
http://www.cppblog.com/Files/billhsu/2037.rar

源代码下载:
http://www.cppblog.com/Files/billhsu/Source_2037.rar


/*
********************
紫日2037 RPG 游戏
合肥八中 许仕鹏 制作
********************
*/
#define WIN32_LEAN_AND_MEAN    //定义不使用MFC库
#include <windows.h>
#include "Pub_Def.h"
#include <stdio.h>
#include<stdlib.h>
//定义人物方向
#define Role_UP 0
#define Role_DOWN 1
#define Role_LEFT 2
#define Role_RIGHT 3
//定义动作
#define Act_1 0
#define Act_2 1
#define Act_3 2
//定义图片的宽度和高度
#define Bmp_Width 32
#define Bmp_Height 64

RECT rect;
//全局变量,用来存储窗口的句柄
HWND hwnd;
//地图的Struct
struct Map_struct{
char name[10];
int NpcNo;
int Width;
int Height;
int **Data;
}Map[MAX_MAPS];
//人物的Struct
struct NPCs_struct{
int seeable;
int name;
int NPC_Status;
int Pos_y;
int Pos_x;
};
//指向一个场景中的人物
struct NPC_struct{
NPCs_struct *NPCs;
}NPC[MAX_MAPS];
HDC windowDC = NULL;//窗口DC
HDC MainRoleDC = NULL;//主角DC
HDC memDC =NULL;//记忆DC
HDC msgboxDC=NULL;//消息框DC
HDC MapDC=NULL;//装地图图片的DC
HDC TmpMapDC=NULL;//画出地图的DC
HDC TmpSceneDC=NULL;//画出场景DC
HDC FaceDC=NULL;//人物脸DC
HDC Boy1DC=NULL;//男孩1DC
HDC Boy2DC=NULL;//男孩2DC

HDC Girl1DC=NULL;//女孩1DC
HDC Girl2DC=NULL;//女孩2DC
HDC DiagDC=NULL;//DiagDC

HFONT Font;//字体物件
//以下为图片物件,和上面的DC对应
HBITMAP MainRoleBMP = NULL; 
HBITMAP memBMP=NULL;   
HBITMAP msgboxBMP=NULL;
HBITMAP MapBMP=NULL;
HBITMAP TmpMapBMP=NULL;
HBITMAP TmpSceneBMP=NULL;
HBITMAP FaceBMP=NULL;

HBITMAP Boy1BMP=NULL;
HBITMAP Boy2BMP=NULL;

HBITMAP Girl1BMP=NULL;
HBITMAP Girl2BMP=NULL;

HBITMAP DiagBMP=NULL;

unsigned int active;//本窗口是否为活动
UINT width;//屏幕宽
UINT height;//屏幕高
int Role_X;//人物X坐标
int Role_Y;//人物Y坐标
int Role_Act;//人物动作
int Role_Status;//人物状态(上、下、左、右)

int Map_y=0;//地图Y坐标
int Map_x=0;//地图X坐标

int Scene=0;//场景编号
int ObjTmp;
int ObjTmp_x;
int ObjTmp_y;

int hStory=0;//故事编号
//以下为判断状态的变量
bool enter_1=false;
bool enter_2=false;
bool enter_3=false;
bool enter_4=false;
bool enter_5=false;
bool enter_6=false;
bool enter_7=false;
bool enter_8=false;
bool enter_9=false;
bool enter_10=false;

bool visit_1=false;
bool visit_2=false;
bool visit_3=false;
bool visit_4=false;
bool Get_Sanshi=false;
bool Get_Sunzi=false;
bool enter_zuo=false;
bool visit_zuo=false;
bool talk_apsh=false;
bool talk_czn=false;
bool talk_xz=false;
bool Get_sun=false;
//以下为函数定义
HRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);//消息处理
void DoMain(void);//主循环
void Move(void);//移动主角
void Delay(long time);//延时
void ClearScr(void);//清屏
void Draw(void);//将记忆DC画到窗口DC
void GameTitle(void);//游戏开头字幕
void PrintText(char * chr,int x,int y);//打印文字
void TalkText(int face,char * chr,char * Obj_Name);//人物对话
void MoveNPC(int NPC_Num,int NPC_Dt);//移动人物
void CheckThings(void);//检查物品
bool InitMap(void);//装载地图*.map
void DrawTmpMap(int Old_Scene);//画临时地图
int GetObj(int Obj_y,int Obj_x);//获取物品
void CheckEvent(int Obj_y,int Obj_x);//检查事件
bool CanMove(int Obj_y,int Obj_x);//可以走吗?
void CheckSysMsg(void);//检察系统消息
void ReleaseObjs(void);//释放物件及DC
void DrawTmpScene(int Old_Scene);//画临时场景
void DrawInCheckEvent(void);//CheckEvent函数中的画函数
void DrawInMove(void);//Move函数中的画函数
void DrawInTalkText(void);//TalkText函数中的画函数
void Enter_Scene(char * chr);

HDC const NameToDC(int tempint) ;//将图片号变成DC
int CALLBACK WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
                    LPSTR lpCmdLine,int nCmdShow)
{
int x;
int y;
int x1;
int y1;

MSG msg;

WNDCLASSEX WinClass;

WinClass.cbSize = sizeof(WNDCLASSEX);

WinClass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW; // 标准设置
WinClass.lpfnWndProc = WndProc; //
WinClass.cbClsExtra = 0; // 附加窗口信息,这里不使用
WinClass.cbWndExtra = 0; // 附加窗口信息,这里不使用
WinClass.hInstance = hInstance;
WinClass.hIcon = LoadIcon(NULL, IDI_WINLOGO); //图标
WinClass.hCursor = LoadCursor(NULL, IDC_ARROW); // 鼠标指针
WinClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
WinClass.lpszMenuName = NULL; // 不使用菜单
WinClass.lpszClassName = "Window Class"; //
WinClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO); //
RegisterClassEx(&WinClass);
width=GetSystemMetrics(SM_CXSCREEN);
height=    GetSystemMetrics(SM_CYSCREEN);
if (!(hwnd = CreateWindowEx(NULL,                // 附加样式,不使用
                            "Window Class",      // 类定义
                            "紫日2037",      // 标题
                            WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU| WS_VISIBLE,
                            width/2-160,height/2-160,325,320 ,    // 窗口大小位置
                            NULL,                //
                            NULL,                //
                            hInstance,            //
                            NULL)))              //

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow (hwnd);
    windowDC=GetDC(hwnd);
    //创建字体
    Font=CreateFont(20,
                0,
                0,
                0,
                400,
                FALSE,
                FALSE,
                0,
                GB2312_CHARSET,
                OUT_DEFAULT_PRECIS,
                CLIP_DEFAULT_PRECIS,
                DEFAULT_QUALITY,
                DEFAULT_PITCH|FF_SWISS,
                "黑体");
    SelectObject(windowDC,Font);
    SetBkMode(windowDC,TRANSPARENT);
    SetTextColor(windowDC,RGB(255,0,0));
    TextOut(windowDC,100,130,"Loading...",strlen("Loading..."));
    MainRoleBMP=CreateCompatibleBitmap(windowDC,width,height);
    MainRoleDC=CreateCompatibleDC(windowDC);
    memDC=CreateCompatibleDC(windowDC);
    memBMP=CreateCompatibleBitmap(windowDC,width,height);
    msgboxDC=CreateCompatibleDC(windowDC);
    MapDC=CreateCompatibleDC(windowDC);
    TmpMapDC=CreateCompatibleDC(windowDC);
    TmpMapBMP=CreateCompatibleBitmap(windowDC,width,height);
    TmpSceneDC=CreateCompatibleDC(windowDC);
    TmpSceneBMP=CreateCompatibleBitmap(windowDC,width,height);
    FaceDC=CreateCompatibleDC(windowDC);
    FaceBMP=CreateCompatibleBitmap(windowDC,width,height);
    Boy1DC=CreateCompatibleDC(windowDC);
    Boy1BMP=CreateCompatibleBitmap(windowDC,width,height);
    Boy2DC=CreateCompatibleDC(windowDC);
    Boy2BMP=CreateCompatibleBitmap(windowDC,width,height);
    Girl1DC=CreateCompatibleDC(windowDC);
    Girl1BMP=CreateCompatibleBitmap(windowDC,width,height);
    Girl2DC=CreateCompatibleDC(windowDC);
    Girl2BMP=CreateCompatibleBitmap(windowDC,width,height);
    DiagDC=CreateCompatibleDC(windowDC);
    DiagBMP=CreateCompatibleBitmap(windowDC,width,height);
    //绑定字体和DC
    SelectObject(memDC,Font);
    SetBkMode(memDC,TRANSPARENT);
    SetTextColor(memDC,RGB(255,0,0));
    InitMap();
    //装载图片
    MainRoleBMP=(HBITMAP)LoadImage(NULL,"Res//Role.bmp",IMAGE_BITMAP,Bmp_Width*6,Bmp_Height*4,LR_LOADFROMFILE);
    msgboxBMP=(HBITMAP)LoadImage(NULL,"Res//msgbox.bmp",IMAGE_BITMAP,320,84,LR_LOADFROMFILE);
    MapBMP=(HBITMAP)LoadImage(NULL,"Res//Map.bmp",IMAGE_BITMAP,32,1280,LR_LOADFROMFILE);
    FaceBMP=(HBITMAP)LoadImage(NULL,"Res//Face.bmp",IMAGE_BITMAP,32,320,LR_LOADFROMFILE);
    Boy1BMP=(HBITMAP)LoadImage(NULL,"Res//Boy1.bmp",IMAGE_BITMAP,Bmp_Width*6,Bmp_Height*4,LR_LOADFROMFILE);
    Boy2BMP=(HBITMAP)LoadImage(NULL,"Res//Boy2.bmp",IMAGE_BITMAP,Bmp_Width*6,Bmp_Height*4,LR_LOADFROMFILE);
    Girl1BMP=(HBITMAP)LoadImage(NULL,"Res//Girl1.bmp",IMAGE_BITMAP,Bmp_Width*6,Bmp_Height*4,LR_LOADFROMFILE);
    Girl2BMP=(HBITMAP)LoadImage(NULL,"Res//Girl2.bmp",IMAGE_BITMAP,Bmp_Width*6,Bmp_Height*4,LR_LOADFROMFILE);
    DiagBMP=(HBITMAP)LoadImage(NULL,"Res//Diag.bmp",IMAGE_BITMAP,230,40,LR_LOADFROMFILE);
    //绑定图片和DC
    SelectObject(MainRoleDC,MainRoleBMP);
    SelectObject(memDC,memBMP);
    SelectObject(msgboxDC,msgboxBMP);
    SelectObject(MapDC,MapBMP);
    SelectObject(TmpMapDC,TmpMapBMP);
    SelectObject(FaceDC,FaceBMP);
    SelectObject(TmpSceneDC,TmpSceneBMP);
    SelectObject(Boy1DC,Boy1BMP);
    SelectObject(Boy2DC,Boy2BMP);
    SelectObject(Girl1DC,Girl1BMP);
    SelectObject(Girl2DC,Girl2BMP);
    SelectObject(DiagDC,DiagBMP);
    //初始值设置
    GameTitle();
    Role_X=4;
    Role_Y=3;
    Role_Status=Role_DOWN;
    Role_Act=Act_1;
    x=Role_X*Bmp_Width;
    y=Role_Y*Bmp_Width;
    x1=Role_Act*Bmp_Width+1;
    y1=Role_Status*Bmp_Height+1;
    DrawTmpMap(0);
    ClearScr();
    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);
    Draw();
    TalkText(WizaFace,"你好,Leo!我是Airy.","Airy");
    TalkText(YouFace,"Airy,谢谢他们可以派你 >>","Leo");
    TalkText(YouFace,"来帮我.可是,我会成功吗?","Leo");
    TalkText(WizaFace,"这就要看你自己了 >>","Airy");
    TalkText(WizaFace,"那我们开始吧,好吗?","Airy");
    TalkText(YouFace,"好的,为了世界的和平 >>","Leo");
    TalkText(YouFace,"我一定会竭尽全力的!","Leo");
    TalkText(WizaFace,"你先拜访一下邻居吧.","Airy");
//
    while(1)
    {
        if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
        {
            if(!GetMessage(&msg,NULL,0,0))
            return msg.wParam;
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else if(active)
        {
            DoMain();
        }
        else
            WaitMessage();
    }
}
HRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_ACTIVATEAPP:
        active=wparam;
        SetFocus(hwnd);
        break;
case WM_DESTROY:

    ReleaseObjs();
    PostQuitMessage(0);
    break;
case WM_PAINT:
    PAINTSTRUCT ps;
    HDC PaintDC;
    PaintDC = BeginPaint(hwnd, &ps);
    BitBlt(PaintDC,0,0,325,320,memDC,0,0,SRCCOPY);
    EndPaint(hwnd, &ps);
    ReleaseDC(hwnd,PaintDC);
    return(0);
    break;
case WM_KEYDOWN:
        switch(wparam)
        {
        case VK_ESCAPE:
        ReleaseObjs();
        PostQuitMessage(0);
        break;
        default:
        break;
        }
default:
return(DefWindowProc(hwnd, msg, wparam, lparam));
}
}
void DoMain(void)
{

if(GetAsyncKeyState(VK_UP)<0)//获取按键状态:上
{
Role_Status=Role_UP;
Move();
}

if(GetAsyncKeyState(VK_DOWN)<0)//获取按键状态:下
{
Role_Status=Role_DOWN;
Move();
}
if(GetAsyncKeyState(VK_LEFT)<0)//获取按键状态:左
{
Role_Status=Role_LEFT;
Move();
}
if(GetAsyncKeyState(VK_RIGHT)<0)//获取按键状态:右
{
Role_Status=Role_RIGHT;
Move();
}
if(GetAsyncKeyState(VK_SPACE)<0)//获取按键状态:空格
{
CheckThings();
}
}
void Move(void)
{
int x;
int y;
int x1;
int y1;
int temp;
int Tmp_Width;
int Tmp_Height;
//char xsp1[10];
//char xsp2[10];
switch (Role_Status)
{
case Role_RIGHT:
if ((Role_X+2> Map[Scene].Width) || (!CanMove(Role_Y+1,Role_X+1)))
{DrawInMove();
return;}
Tmp_Width=Bmp_Width;
temp=-1;
break;
case Role_LEFT:
if ((Role_X<=0) || (!CanMove(Role_Y+1,Role_X-1)))
{DrawInMove();
return;}
Tmp_Width=-Bmp_Width;
temp=1;
break;

case Role_UP:
if ((Role_Y+1<=0) || (!CanMove(Role_Y,Role_X)))
{DrawInMove();
return;}

Tmp_Height=-Bmp_Width;
temp=1;
break;

case Role_DOWN:
if ((Role_Y+3> Map[Scene].Height)||(!CanMove(Role_Y+2,Role_X)))
{DrawInMove();
return;}

Tmp_Height=Bmp_Width;
temp=-1;
break;
}
ClearScr();
x=4*Bmp_Width;
y=3*Bmp_Width;
x1=Role_Act*Bmp_Width+1;
y1=Role_Status*Bmp_Height+1;
//画主角
    if ((Role_Status==Role_RIGHT) ||( Role_Status==Role_LEFT) ) {Map_x=Map_x+temp*Bmp_Width/4;}
    else {Map_y=Map_y+temp*Bmp_Width/4;}
    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);
    Draw();
    Delay(80);
    ClearScr();

    x1=x1+Bmp_Width;

    if ((Role_Status==Role_RIGHT) ||( Role_Status==Role_LEFT) ) {Map_x=Map_x+temp*Bmp_Width/4;}
    else {Map_y=Map_y+temp*Bmp_Width/4;}
    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);
    Draw();
    Delay(80);
    ClearScr();
    x1=x1+Bmp_Width;
    if ((Role_Status==Role_RIGHT) ||( Role_Status==Role_LEFT) ) {Map_x=Map_x+temp*Bmp_Width/4;}
    else {Map_y=Map_y+temp*Bmp_Width/4;}
    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);
    Draw();
    Delay(80);
    ClearScr();

    if ((Role_Status==Role_RIGHT) ||( Role_Status==Role_LEFT) ) {Role_X=Role_X-temp;Map_x=Map_x+temp*Bmp_Width/4;}
    else {Role_Y=Role_Y-temp;Map_y=Map_y+temp*Bmp_Width/4;}

    x1=1;

    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);

//    itoa(Role_X,xsp1,10);
//    itoa(Role_Y+1,xsp2,10);
//    strcat(xsp1,"|");
//    strcat(xsp1,xsp2);
//    TextOut(memDC,100,1, xsp1  ,strlen(xsp1));
    Draw();
    Delay(80);
    CheckEvent(Role_Y+1,Role_X);
///////////////////////////
switch (Role_Status)
{
case Role_RIGHT:

if ((Role_X+2> Map[Scene].Width) || (!CanMove(Role_Y+1,Role_X+1)))
{

return;}
break;

case Role_LEFT:

if ((Role_X<=0) || (!CanMove(Role_Y+1,Role_X-1)))
{
return;}
break;

case Role_UP:
if ((Role_Y+1<=0) || (!CanMove(Role_Y,Role_X)))
{
return;}
break;

case Role_DOWN:
if ((Role_Y+3> Map[Scene].Height)||(!CanMove(Role_Y+2,Role_X)))
{
return;}
}
}

void DrawInMove(void)
{
int x;
int y;
int x1;
int y1;
x=4*Bmp_Width;
y=3*Bmp_Width;
x1=1;
y1=Role_Status*Bmp_Height+1;
ClearScr();
BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);
Draw();
}
//按下键后松开
void PressKey(DWORD Key,int x)
{
    if( x==0 )
    while( !GetAsyncKeyState(Key) )
    {CheckSysMsg();}
    while( GetAsyncKeyState(Key) )
    {CheckSysMsg();}
}

void Delay(long time)
{
    static long old_clock, new_clock; //延时变量
    new_clock=old_clock=GetTickCount();
    while( new_clock < old_clock + time )
    {
        new_clock=GetTickCount();
        CheckSysMsg();
    }
}
void ClearScr(void)
{
    rect.left =0;
    rect.top =0;
    rect.right =325;
    rect.bottom = 320;       
    FillRect(memDC, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH));
}
void Draw(void)
{
    BitBlt(memDC,0,236,320,42,msgboxDC,1,1,SRCAND);
    BitBlt(memDC,0,236,320,42,msgboxDC,1,43,SRCPAINT);
    TextOut(memDC,1,1, Map[Scene].name  ,strlen(Map[Scene].name));
    BitBlt(windowDC,0,0,325,320,memDC,0,0,SRCCOPY);
}

void PrintText(char * chr,int x,int y)
{
int word_x=0;
char tmp[40];
for (word_x=0;word_x<=strlen(chr);word_x=word_x+2)
    {
    memset(tmp, 0, 40);
    memcpy(tmp, chr, word_x);
    TextOut(memDC,x,y,tmp,strlen(tmp));
    BitBlt(windowDC,0,0,width,height,memDC,0,0,SRCCOPY);
    Delay(80);

    }
}
void GameTitle(void)
{
char *Game_Title1="    2037年,日本军国主义复辟。";
char *Game_Title2="  你Leo,是一个有责任心的中国人,";
char *Game_Title3="  只身前往日本,去为和平而战。";
char *Game_Title4="  为了方便你完成任务,";
char *Game_Title5="  我们派出了人工智能Airy帮助你。";
char *Game_Title6="  你会成功吗?为了和平奋斗吧!";
char *Game_Title7="  按空格键继续....";

PrintText(Game_Title1,1,20);
PrintText(Game_Title2,1,45);
PrintText(Game_Title3,1,70);
PrintText(Game_Title4,1,95);
PrintText(Game_Title5,1,120);
PrintText(Game_Title6,1,145);
Delay(400);
PrintText(Game_Title7,1,190);
PressKey(VK_SPACE,0);
}
bool InitMap(void)
{

    char *Name[]={"maps//map1.map","maps//map2.map","maps//map3.map","maps//map4.map",
        "maps//map5.map","maps//map6.map","maps//map7.map","maps//map8.map"};
    char *NpcName[]={"NPCs//npc1.npc","NPCs//npc2.npc","NPCs//npc3.npc","NPCs//npc4.npc",
        "NPCs//npc5.npc","NPCs//npc6.npc","NPCs//npc7.npc","NPCs//npc8.npc"};
    FILE *fp;
    FILE *fp1;

    Delay(200);
    for( int i=0; i<MAX_MAPS; i++)
    {
        fp=fopen(Name,"r");
        fp1=fopen(NpcName,"r");
        if( fp==NULL )    return false;
        fscanf(fp,"%s",&Map.name);
        fscanf(fp,"%d",&Map.NpcNo);
        fscanf(fp,"%d",&Map.Width);
        fscanf(fp,"%d",&Map.Height);
        Map.Data =new int*[Map[ i ].Height];
        NPC.NPCs =new NPCs_struct[Map.NpcNo];
        for (int q=0;q<Map.NpcNo;q++)
        {
        fscanf(fp1,"%d",&NPC.NPCs[q].name);
        fscanf(fp1,"%d",&NPC.NPCs[q].seeable);
        fscanf(fp1,"%d",&NPC.NPCs[q].NPC_Status);
        fscanf(fp1,"%d",&NPC.NPCs[q].Pos_y);
        fscanf(fp1,"%d",&NPC.NPCs[q].Pos_x);
        }
        fclose(fp1);
        for (int j=0;j<Map.Height;j++)
        {
        Map.Data[j]=new int [Map.Width];
        for (int k=0;k<Map.Width;k++)
        {
        fscanf(fp,"%d",&Map.Data[j][k] );
        }
        }

        fclose(fp);
    }

    return true;
}
void DrawTmpMap(int Old_Scene)
{

int i;
int j;
int i1;
int j1;
int a=0;
i=Map[Old_Scene].Height;
j=Map[Old_Scene].Width;
i1=Map[Scene].Height;
j1=Map[Scene].Width;
rect.left =0;
rect.top =0;
rect.right =j*32;
rect.bottom = i*32;
FillRect(TmpMapDC, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH));//清空老地图
for (int k=0;k<i1;k++)
{
for (int l=0;l<j1;l++)
{

BitBlt(TmpMapDC,l*32,k*32,32,32,MapDC,0,Map[Scene].Data[k][l]*32,SRCCOPY);//画新地图
}
}

DrawTmpScene(Old_Scene);
}
int GetObj(int Obj_y,int Obj_x)
{
for (int i=0;i<Map[Scene].NpcNo;i++)
{
int TmpNPC_x=NPC[Scene].NPCs.Pos_x;
int TmpNPC_y=NPC[Scene].NPCs.Pos_y+1;
int cansee=NPC[Scene].NPCs.seeable;
if (cansee==1 && TmpNPC_x==Obj_x && TmpNPC_y==Obj_y)
{
    switch (NPC[Scene].NPCs.name){
    case 1:
        return Boy1;
        break;
    case 2:
        return Boy2;
        break;
    case 3:
        return Girl1;
        break;
    case 4:
        return Girl2;
        break;
}
}
}

return Map[Scene].Data[Obj_y][Obj_x];
}

void MoveNPC(int NPC_Num,int NPC_Dt)
{
/////////////////////////////////////
int x;
int y;
int x1;
int y1;
int temp;

//NPC_Dt是人物的方向(不是主角)
switch (NPC_Dt)
{
case Role_RIGHT:
temp=-1;
break;

case Role_LEFT:
temp=1;
break;

case Role_UP:
temp=1;
break;

case Role_DOWN:
temp=-1;
break;
}

NPC[Scene].NPCs[NPC_Num].seeable=0;
DrawTmpScene(Scene);
x=(NPC[Scene].NPCs[NPC_Num].Pos_x)*32;
y=(NPC[Scene].NPCs[NPC_Num].Pos_y)*32;
x1=1;
y1=NPC_Dt*Bmp_Height+1;
int tmp_name=NPC[Scene].NPCs[NPC_Num].name;
//画人物
    if ((NPC_Dt==Role_RIGHT) ||( NPC_Dt==Role_LEFT) ) {x=x-temp*Bmp_Width/4;}
    else {y=y-temp*Bmp_Width/4;}
    DrawTmpScene(Scene);
    BitBlt(TmpSceneDC,x,y,Bmp_Width,Bmp_Height,NameToDC(tmp_name),x1,y1,SRCAND);
    BitBlt(TmpSceneDC,x,y,Bmp_Width,Bmp_Height,NameToDC(tmp_name),x1+Bmp_Width*3,y1,SRCPAINT);
    DrawInCheckEvent();
    Delay(80);
    x1=x1+Bmp_Width;

    if ((NPC_Dt==Role_RIGHT) ||( NPC_Dt==Role_LEFT) ) {x=x-temp*Bmp_Width/4;}
    else {y=y-temp*Bmp_Width/4;}
    DrawTmpScene(Scene);
    BitBlt(TmpSceneDC,x,y,Bmp_Width,Bmp_Height,NameToDC(tmp_name),x1,y1,SRCAND);
    BitBlt(TmpSceneDC,x,y,Bmp_Width,Bmp_Height,NameToDC(tmp_name),x1+Bmp_Width*3,y1,SRCPAINT);
    DrawInCheckEvent();
    Delay(80);
    x1=x1+Bmp_Width;

    if ((NPC_Dt==Role_RIGHT) ||( NPC_Dt==Role_LEFT) ) {x=x-temp*Bmp_Width/4;}
    else {y=y-temp*Bmp_Width/4;}
    DrawTmpScene(Scene);
    BitBlt(TmpSceneDC,x,y,Bmp_Width,Bmp_Height,NameToDC(tmp_name),x1,y1,SRCAND);
    BitBlt(TmpSceneDC,x,y,Bmp_Width,Bmp_Height,NameToDC(tmp_name),x1+Bmp_Width*3,y1,SRCPAINT);
    DrawInCheckEvent();
    Delay(80);

    if ((NPC_Dt==Role_RIGHT) ||( NPC_Dt==Role_LEFT) ) {NPC[Scene].NPCs[NPC_Num].Pos_x=NPC[Scene].NPCs[NPC_Num].Pos_x-temp;}
    else {NPC[Scene].NPCs[NPC_Num].Pos_y=NPC[Scene].NPCs[NPC_Num].Pos_y-temp;}
    NPC[Scene].NPCs[NPC_Num].NPC_Status=NPC_Dt;
    NPC[Scene].NPCs[NPC_Num].seeable=1;
    DrawTmpScene(Scene);
    DrawInCheckEvent();
    Delay(80);
/////////////////////////////////////
}

void TalkText(int face,char * chr,char * Obj_Name)
{
    int x;
    int y;
    int x1;
    int y1;
    x=4*Bmp_Width;
    y=3*Bmp_Width;
    x1=Role_Act*Bmp_Width+1;
    y1=Role_Status*Bmp_Height+1;
    ClearScr();
    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);

    BitBlt(memDC,0,236,320,42,msgboxDC,1,1,SRCAND);
    BitBlt(memDC,0,236,320,42,msgboxDC,1,43,SRCPAINT);
    TextOut(memDC,1,1, Obj_Name,strlen(Obj_Name));
    BitBlt(memDC,20,241,32,32,FaceDC,0,face*32,SRCAND);
    TextOut(memDC,55,248,chr,strlen(chr));
    BitBlt(windowDC,0,0,width,height,memDC,0,0,SRCCOPY);
    PressKey(VK_SPACE,0);
    DrawInTalkText();
}


void CheckThings(void)
{
    while(GetAsyncKeyState(VK_SPACE) )
    {CheckSysMsg();}
switch(hStory)
{
case 0:
if ((Scene==2)&&(ObjTmp_x==7)&& (ObjTmp_y==3)){
TalkText(Boy2Face,"请问你是谁呀?","东史郎");
TalkText(YouFace,"你好,我是Leo,你的新邻居","Leo");
TalkText(Boy2Face,"啊,欢迎.可听你说话 >>","东史郎");
TalkText(Boy2Face,"怎么,有点奇怪啦…","东史郎");
TalkText(YouFace,"哦,我是从中国来的, >>","Leo");
TalkText(YouFace,"放假了,过来...玩... >>","Leo");
TalkText(YouFace,"请多多关照^_^","Leo");
TalkText(Boy2Face,"太好了,这几天我好寂寞 >>","东史郎");
TalkText(Boy2Face,"可以找你玩吗?","东史郎");
TalkText(YouFace,"好呀!那我先走了","Leo");
TalkText(Boy2Face,"再见!","东史郎");
visit_1=true;
return; 
}

if ((Scene==3)&&(ObjTmp_x==2)&& (ObjTmp_y==4)){
TalkText(Boy4Face,"小家伙,你是谁啊?","东条纯四");
TalkText(YouFace,"你好,我是Leo,你的新邻居","Leo");
TalkText(Boy4Face,"你准备好了吗?","东条纯四");
TalkText(YouFace,"准备好什么?","Leo");
TalkText(Boy4Face,"争霸世界啊,你怎么 >>","东条纯四");
TalkText(Boy4Face,"不知道!","东条纯四");
TalkText(YouFace,"我不是你们一伙的!","Leo");
TalkText(Boy4Face,"那你来我这送死啊,滚!","东条纯四");
TalkText(WizaFace,"对付他你要小心点 >>","Airy");
TalkText(WizaFace,"他是 东条英机 的曾孙","Airy");
TalkText(YouFace,"怪不得那么丑!","Leo");
TalkText(WizaFace,"离开这儿吧,似乎这里 >>","Airy");
TalkText(WizaFace,"不安全.","Airy");
visit_2=true;
return; 
}
break;
////////////////////////////////
case 1:
if ((Scene==0)&&(ObjTmp_x==5)&& (ObjTmp_y==3)){
TalkText(YouFace,"东史郎,你来啦!","Leo");
TalkText(Boy2Face,"恩……","东史郎");
TalkText(YouFace,"怎么了,东史郎?你 >>","Leo");
TalkText(YouFace,"看起来很伤心啊.","Leo");
TalkText(Boy2Face,"我可能过几天就要走了...","东史郎");
TalkText(YouFace,"走? 怎么了?","Leo");
TalkText(Boy2Face,"他们想打仗,我不得不 >>","东史郎");
TalkText(Boy2Face,"去参军...","东史郎");
TalkText(YouFace,"去“争霸世界”?","Leo");
TalkText(Boy2Face,"说去送死还差不多 >>","东史郎");
TalkText(Boy2Face,"我们本来就是不正确的...","东史郎");
TalkText(YouFace,"他们真可恶!","Leo");
TalkText(Boy2Face,"是啊…对了!你真的是…","东史郎");
TalkText(YouFace,"是什么?","Leo");
TalkText(Boy2Face,"你真的是过来玩的吗?","东史郎");
TalkText(Boy2Face,"现在来这儿玩好像有点…","东史郎");
TalkText(YouFace,"好吧,其实我是来阻止战争的.","Leo");
TalkText(YouFace,"只是还没什么方向…","Leo");
TalkText(Boy2Face,"真的吗?太好了 >>","东史郎");
TalkText(Boy2Face,"你可以问问佐藤洋一 >>","东史郎");
TalkText(Boy2Face,"他一定知道怎么办!","东史郎");
TalkText(YouFace,"可是他家好像没人…","Leo");
TalkText(Boy2Face,"他一定是躲起来了 >>","东史郎");
TalkText(Boy2Face,"他胆子有点小,不过 >>","东史郎");
TalkText(Boy2Face,"我听说他爱古籍","东史郎");
TalkText(YouFace,"古籍?那我拿几本古籍 >>","Leo");
TalkText(YouFace,"去找他试试.","Leo");
TalkText(Boy2Face,"祝你好运,我们的命运 >>","东史郎");
TalkText(Boy2Face,"都等着你改写呢!","东史郎");
Map[Scene].Data[5][9]=wiz;
Map[Scene].Data[3][9]=wiz;
visit_3=true;
DrawTmpMap(0);
return;
}

if ((Scene==0)&&(ObjTmp_x==9)&& (ObjTmp_y==5) && (visit_3==true) ){
Get_Sunzi=true;
TalkText(WizaFace,"哇!你得到了 孙子兵法 啦!","Airy");
return;
}
if ((Scene==0)&&(ObjTmp_x==9)&& (ObjTmp_y==3) && (visit_3==true) ){
Get_Sanshi=true;
TalkText(WizaFace,"哇!你得到了 三十六计 啦!","Airy");
return;
}
break;
////////////////////////////////
case 2:
if ((Scene==4)&&(ObjTmp_x==2)&& (ObjTmp_y==4)&&(!visit_zuo)){
TalkText(YouFace,"佐藤爷爷好!","Leo");
TalkText(Boy1Face,"你好,哇,你有孙子兵法 >>","佐藤洋一");
TalkText(Boy1Face,"借我看看好吗?","佐藤洋一");
TalkText(YouFace,"当然啦!","Leo");
TalkText(Boy1Face,"太好了.","佐藤洋一");
TalkText(YouFace,"爷爷,我有个问题想问","Leo");
TalkText(Boy1Face,"那就快问,快问…","佐藤洋一");
TalkText(YouFace,"怎样才可以阻止政府…","Leo");
TalkText(Boy1Face,"阻止政府出兵?","佐藤洋一");
TalkText(YouFace,"对啊!爷爷快告诉我!","Leo");
TalkText(Boy1Face,"这……我不能说","佐藤洋一");
TalkText(YouFace,"爷爷怎么了,难道您认为 >>","Leo");
TalkText(YouFace,"他们是对的?!","Leo");
TalkText(Boy1Face,"当然不对…可是 我是 >>","佐藤洋一");
TalkText(Boy1Face,"日本人,我不能背叛祖国!","佐藤洋一");
TalkText(YouFace,"你认为背叛那些BT的懦夫 >>","Leo");
TalkText(YouFace,"就是背叛祖国吗? 他们 >>","Leo");
TalkText(YouFace,"只是一团团狗屎!","Leo");
TalkText(Boy1Face,"我不能背叛祖国!","佐藤洋一");
TalkText(WizaFace,"有麻烦了……","Airy");
TalkText(YouFace,"怎么办吗!","Leo");
TalkText(WizaFace,"我查查 三十六计…","Airy");
TalkText(WizaFace,"看!上面有条“上屋抽梯”","Airy");
TalkText(YouFace,"太好了!我把他的梯子抽掉试试.","Leo");
enter_10=true;
return;
}
if ((Scene==4)&&(Role_X==6)&& (Role_Y==1)&&(!visit_zuo)&&(enter_10)){
TalkText(YouFace,"老鬼子,我把你的梯子抽掉!","Leo");
Map[Scene].Data[2][6]=WallD;
visit_zuo=true;
DrawTmpMap(4);
Draw();
Role_Status=Role_UP;
Map_y-=32;
Role_Y=2;
DrawInCheckEvent();
return;
}
if ((Scene==4)&&(Role_X==6)&& (Role_Y==2)&&(!visit_zuo)&&(enter_10)){
TalkText(YouFace,"老鬼子,我把你的梯子抽掉!","Leo");
Map[Scene].Data[2][6]=WallD;
visit_zuo=true;
DrawTmpMap(4);
Draw();
DrawInCheckEvent();
return;
}

if ((Scene==4)&&(ObjTmp_x==2)&& (ObjTmp_y==4)&&(visit_zuo)){
TalkText(YouFace,"对不起,爷爷,我把梯子抽了","Leo");
TalkText(YouFace,"你走不了啦……","Leo");
TalkText(Boy1Face,"看来你是铁心了.好吧…","佐藤洋一");
TalkText(Boy1Face,"这场战争的根源 >>","佐藤洋一");
TalkText(Boy1Face,"在靖国神社,我家有通向 >>","佐藤洋一");
TalkText(Boy1Face,"那里的通道.","佐藤洋一");
TalkText(Boy1Face,"你首先得进入靖国神社 >>","佐藤洋一");
TalkText(Boy1Face,"我也只能告诉你这些.","佐藤洋一");
TalkText(Boy1Face,"和平是每个人都向往的","佐藤洋一");
TalkText(Boy1Face,"祝你成功.","佐藤洋一");
TalkText(YouFace,"谢谢爷爷!","Leo");
hStory=3;
return;
}
break;
////////////////////////
case 3:
if ((Scene==5)&&(ObjTmp_x==6)&& (ObjTmp_y==4)){
TalkText(Girl2Face,"你怎么敢闯入军机处?","小百合");
TalkText(YouFace,"为了和平,希望你理解.","Leo");
TalkText(Girl2Face,"你的事我已经知道了","小百合");
TalkText(Girl2Face,"我相信每个人都理解你!","小百合");
TalkText(Girl2Face,"先祝你顺利,不过我建议 >>","小百合");
TalkText(Girl2Face,"你最好看看军机处的资料.","小百合");
TalkText(YouFace,"谢谢.","Leo");
enter_6=true;
return;
}
if ((Scene==5)&&(ObjTmp_x==4)&& (ObjTmp_y==4)&&(enter_6)){
TalkText(WizaFace,"资料说,靖国神社中央 >>","Airy");
TalkText(WizaFace,"有一个小太阳神像","Airy");
TalkText(WizaFace,"它是邪恶力量之源.","Airy");
TalkText(YouFace,"了解.","Leo");
hStory=4;
return;
}
break;
//////////////////////
case 4:
if ((Scene==6)&&(ObjTmp_x==5)&& (ObjTmp_y==4)){
TalkText(Boy3Face,"Leo,我们都支持你!","城之内");
TalkText(YouFace,"谢谢,城之内.","Leo");
talk_czn=true;
return;
}
if ((Scene==6)&&(ObjTmp_x==6)&& (ObjTmp_y==4)){
TalkText(Girl1Face,"Leo,一定要成功啊!","杏子");
TalkText(YouFace,"我不会让你失望的,杏子.","Leo");
talk_xz=true;
return;
}
if ((Scene==6)&&(ObjTmp_x==7)&& (ObjTmp_y==4)){
TalkText(Girl3Face,"Leo,无论多艰难 >>","安倍绍惠");
TalkText(Girl3Face,"都不要放弃!","安倍绍惠");
TalkText(YouFace,"我一定不放弃.","Leo");
talk_apsh=true;
return;
}

break;
//////////////////////
case 5:
if ((Scene==7)&&(ObjTmp_x==8)&& (ObjTmp_y==4)&&(!Get_sun)&&(!enter_9)){
TalkText(Boy4Face,"Leo,你果然来了!","东条纯四");
TalkText(Boy4Face,"先给你看看我抓的一个人","东条纯四");
MoveNPC(1,Role_UP);
MoveNPC(1,Role_UP);
TalkText(YouFace,"东史郎!","Leo");
TalkText(Boy2Face,"Leo!救我!","东史郎");
enter_9=true;
return;
}
if ((Scene==7)&&(ObjTmp_x==6)&& (ObjTmp_y==5)&&(!Get_sun)&&(enter_9)){
TalkText(YouFace,"什么破太阳神!我把你打碎!","Leo");
Map[Scene].Data[5][6]=Floor1;
Get_sun=true;
TalkText(Boy4Face,"啊!怎么了!我在融化啊!","东条纯四");
TalkText(YouFace,"切!大笨蛋!","Leo");
NPC[Scene].NPCs[0].seeable=0;
DrawTmpMap(7); 
MoveNPC(1,Role_DOWN);
TalkText(Boy2Face,"Leo!你成功啦!","东史郎");
TalkText(YouFace,"是啊!成功啦!","Leo");
TalkText(WizaFace,"Leo,恭喜啦!","Airy");
TalkText(Boy2Face,"我们回家玩吧,好吗?","东史郎");
TalkText(YouFace,"好啊,反正一切都过去了…","Leo");
TalkText(Boy2Face,"我们走吧—— >>","东史郎");
TalkText(Boy2Face,"看,Leo,太阳怎么那么紫啊?","东史郎");
TalkText(YouFace,"邪恶的太阳要下山了 >>.","Leo");
TalkText(YouFace,"就变紫了.","Leo");
TalkText(Boy2Face,"那明天早上,我们去看看 >>","东史郎");
TalkText(Boy2Face,"新的太阳的升起,它一定很美丽","东史郎");
TalkText(YouFace,"是啊,和平永远都是美丽的…","Leo");
TalkText(WizaFace,"那游戏就到这里吧!","Airy");

WinExec("Res//Mplayer.exe",SW_SHOW);//播放片尾视频
ReleaseObjs();
PostQuitMessage(0);
return;
}
break;
//////////////////////
}
}
void CheckEvent(int Obj_y,int Obj_x)
{
switch(hStory)
{
case 0:
if ((Scene==0)&&(Role_X==7)&& (Role_Y==0)){//进入走廊
Scene=1;
DrawTmpMap(0);
Role_X=10;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入走廊");
if ((visit_1==true) && (visit_2==true) && (enter_3==true)){TalkText(WizaFace,"回基地吧.","Airy");TalkText(YouFace,"好的 ","Leo");hStory=1;}
return;
}
if ((Scene==1)&&(Role_X==10)&& (Role_Y==0)){//进入基地
Scene=0;
DrawTmpMap(1);
Role_X=7;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入基地");
return;
}
if ((Scene==1)&&(Role_X==7)&& (Role_Y==0)){//进入东史郎家
Scene=2;
DrawTmpMap(1);
Role_X=7;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入东史郎家");
if (!enter_2){ MoveNPC(0,Role_UP);MoveNPC(0,Role_UP);MoveNPC(0,Role_LEFT);MoveNPC(0,Role_UP);enter_2=true;}
return;
}
if ((Scene==2)&&(Role_X==7)&& (Role_Y==0)){//进入走廊
Scene=1;
DrawTmpMap(2);
Role_X=7;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入走廊");
if ((visit_1==true) && (visit_2==true) && (enter_3==true)){TalkText(WizaFace,"回基地吧.","Airy");TalkText(YouFace,"好的 ","Leo");hStory=1;}
return;
}
if ((Scene==1)&&(Role_X==4)&& (Role_Y==0)){//进入东条纯四家
Scene=3;
DrawTmpMap(1);
Role_X=4;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入东条纯四家");
if (!enter_1){ MoveNPC(0,Role_UP);MoveNPC(0,Role_RIGHT);enter_1=true;}
return;
}
if ((Scene==3)&&(Role_X==4)&& (Role_Y==0)){//进入走廊
Scene=1;
DrawTmpMap(3);
Role_X=4;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入走廊");
if ((visit_1==true) && (visit_2==true) && (enter_3==true)){TalkText(WizaFace,"回基地吧.","Airy");TalkText(YouFace,"好的 ","Leo");hStory=1;}
return;
}
if ((Scene==1)&&(Role_X==1)&& (Role_Y==0)){//进入佐藤洋一家
Scene=4;
DrawTmpMap(1);
Role_X=6;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入佐藤洋一家");
TalkText(WizaFace,"这家好像没人啊..","Airy");
TalkText(YouFace,"奇怪..","Leo");
enter_3=true;
return;
}
if ((Scene==4)&&(Role_X==6)&& (Role_Y==0)){//进入走廊
Scene=1;
DrawTmpMap(4);
Role_X=1;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入走廊");
if ((visit_1==true) && (visit_2==true) && (enter_3==true)){TalkText(WizaFace,"回基地吧.","Airy");TalkText(YouFace,"好的 ","Leo");hStory=1;}
return;
}
return;
break;

////////////////////
case 1:
if ((Scene==1)&&(Role_X==10)&& (Role_Y==0)){//进入基地
Scene=0;
DrawTmpMap(1);
Role_X=7;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入基地");
NPC[Scene].NPCs[0].seeable =true;
DrawTmpScene(0);
if (!enter_4){
MoveNPC(0,Role_UP);
MoveNPC(0,Role_RIGHT);
enter_4=true;}
return;
}
if ((Scene==0)&&(Get_Sunzi==true)&& (Get_Sanshi==true) && !visit_4){
TalkText(WizaFace,"都有了,我们去找佐藤洋一","Airy");
visit_4=true;
hStory=2;
return;
}
return;
break;
///////////////////////////////
case 2:
if ((Scene==0)&&(Role_X==7)&& (Role_Y==0)){//进入走廊
Scene=1;
DrawTmpMap(0);
Role_X=10;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入走廊");
return;
}
if ((Scene==1)&&(Role_X==10)&& (Role_Y==0)){//进入基地
Scene=0;
DrawTmpMap(1);
Role_X=7;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入基地");
return;
}
if ((Scene==1)&&(Role_X==1)&& (Role_Y==0)){//进入佐藤洋一家
Scene=4;
DrawTmpMap(1);
Role_X=6;
Role_Y=1;
NPC[Scene].NPCs[0].seeable=true;
DrawTmpScene(4);
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入佐藤洋一家");
if (!enter_zuo){ MoveNPC(0,Role_UP);MoveNPC(0,Role_UP);MoveNPC(0,Role_RIGHT);enter_zuo=true;}
}

return;
break;
//////////////////////////////////
case 3:
if ((Scene==4)&&(Role_X==2)&& (Role_Y==0)){//进入军机处
Scene=5;
DrawTmpMap(4);
Role_X=7;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入军机处");
if (!enter_5){
MoveNPC(0,Role_UP);
MoveNPC(0,Role_RIGHT);
enter_5=true;}

return;
}
return;
break;
/////////////////////////////////
case 4:
if ((Scene==5)&&(Role_X==4)&& (Role_Y==0)){//进入内阁
Scene=6;
DrawTmpMap(5);
Role_X=6;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入内阁");
if (!enter_7){

MoveNPC(0,Role_UP);
MoveNPC(0,Role_UP);
MoveNPC(1,Role_UP);
MoveNPC(1,Role_UP);
MoveNPC(2,Role_UP);
MoveNPC(2,Role_UP);
enter_7=true;
}

return;
}
if ((Scene==6)&&(Role_X==6)&& (Role_Y==0)&&(talk_apsh)&&(talk_czn)&&(talk_xz)){//进入军机处
Scene=5;
DrawTmpMap(6);
Role_X=4;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入军机处");
hStory=5;
return;
}
break;
////////////////////////////
case 5:
if ((Scene==5)&&(Role_X==1)&& (Role_Y==0)){//进入靖国神社
Scene=7;
DrawTmpMap(5);
Role_X=9;
Role_Y=1;
Map_x=(4-Role_X)*32;
Map_y=(3-Role_Y)*32;
Role_Status=Role_DOWN;
DrawInCheckEvent();
Enter_Scene("进入靖国神社");
TalkText(WizaFace,"靖国神社到了,你要小心啊","Airy");
TalkText(YouFace,"鬼子们也要小心我啦!","Leo");
if (!enter_8){
MoveNPC(0,Role_UP);
MoveNPC(0,Role_RIGHT);
enter_8=true;
}
return;
}
break;


}


}

bool CanMove(int Obj_y,int Obj_x)
{
ObjTmp_x=Obj_x;
ObjTmp_y=Obj_y;
ObjTmp=GetObj(Obj_y,Obj_x);
if ( ObjTmp==Floor1 || ObjTmp==Floor2 || ObjTmp==Door || ObjTmp==Carpet1
    || ObjTmp==Carpet2 || ObjTmp==Carpet3 || ObjTmp==Carpet4 || ObjTmp==Carpet5 ||
    ObjTmp==Carpet6 || ObjTmp==Carpet7 || ObjTmp==CarpetM || ObjTmp==CarpetL||ObjTmp==Ladder) return true;

return false;
}
void CheckSysMsg(void)
{
    MSG msg;
        if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
        {
            if(!GetMessage(&msg,NULL,0,0)) return;
            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
 

}


void DrawInCheckEvent(void)
{
    int x;
    int y;
    int x1;
    int y1;
    x=4*Bmp_Width;
    y=3*Bmp_Width;
    x1=Role_Act*Bmp_Width+1;
    y1=Role_Status*Bmp_Height+1;
    ClearScr();
    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);
    Draw();
}
void DrawInTalkText(void)
{
    int x;
    int y;
    int x1;
    int y1;
    x=4*Bmp_Width;
    y=3*Bmp_Width;
    x1=Role_Act*Bmp_Width+1;
    y1=Role_Status*Bmp_Height+1;
    ClearScr();
    BitBlt(memDC,Map_x,Map_y,(Map[Scene].Width+1)*32 ,(Map[Scene].Height+1)*32,TmpSceneDC,0,0,SRCCOPY);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1,y1,SRCAND);
    BitBlt(memDC,x,y,Bmp_Width,Bmp_Height,MainRoleDC,x1+Bmp_Width*3,y1,SRCPAINT);
    BitBlt(memDC,0,236,320,42,msgboxDC,1,1,SRCAND);
    BitBlt(memDC,0,236,320,42,msgboxDC,1,43,SRCPAINT);
    TextOut(memDC,1,1, Map[Scene].name  ,strlen(Map[Scene].name));
    BitBlt(windowDC,0,0,325,320,memDC,0,0,SRCCOPY);
}

void DrawTmpScene(int Old_Scene)
{
int k;
int j;

k=Map[Old_Scene].Height;
j=Map[Old_Scene].Width;

rect.left =0;
rect.top =0;
rect.right =j*32;
rect.bottom = k*32;
FillRect(TmpSceneDC, &rect, (HBRUSH)GetStockObject(BLACK_BRUSH));

BitBlt(TmpSceneDC,0,0,(Map[Scene].Width+1)*32,(Map[Scene].Height+1)*32,TmpMapDC,0,0,SRCCOPY);

for (int i=0;i<Map[Scene].NpcNo;i++)
{
int TmpNPC_x=NPC[Scene].NPCs.Pos_x*32;
int TmpNPC_y=(NPC[Scene].NPCs.Pos_y)*32;
int Tmp_y1=NPC[Scene].NPCs.NPC_Status*Bmp_Height+1;
int Tmp_name=NPC[Scene].NPCs.name;
int cansee=NPC[Scene].NPCs.seeable;
if (cansee==1)
{
BitBlt(TmpSceneDC,TmpNPC_x ,TmpNPC_y,32,64,NameToDC(Tmp_name),1,Tmp_y1,SRCAND);
BitBlt(TmpSceneDC,TmpNPC_x ,TmpNPC_y,32,64,NameToDC(Tmp_name),97,Tmp_y1,SRCPAINT);
}
}
}

HDC const NameToDC(int tempint)
{
    switch (tempint){
    case 1:
    return Boy1DC;
    break;
    case 2:
    return Boy2DC;
    break;
    case 3:
    return Girl1DC;
    break;
    case 4:
    return Girl2DC;
    }
}

void Enter_Scene(char * chr)
{
BitBlt(memDC,45,126,230,40,DiagDC,0,0,SRCCOPY);
TextOut(memDC,66,136,chr,strlen(chr));
Draw();
Delay(1000);
while(GetAsyncKeyState(VK_UP))
{CheckSysMsg();}
while(GetAsyncKeyState(VK_SPACE))
{CheckSysMsg();}
ClearScr();
DrawInCheckEvent();
Draw();
}

void ReleaseObjs(void)
{

    for( int i=0; i<MAX_MAPS; i++)
    {    delete[] NPC.NPCs;

        for (int j=0;j<Map.Height;j++)
        {
        delete []Map.Data[j];
        }
    }
    //释放
    ReleaseDC(hwnd,MainRoleDC);
    ReleaseDC(hwnd,windowDC);
    ReleaseDC(hwnd,memDC);
    ReleaseDC(hwnd,msgboxDC);
    ReleaseDC(hwnd,MapDC);
    ReleaseDC(hwnd,TmpMapDC);
    ReleaseDC(hwnd,FaceDC);
    ReleaseDC(hwnd,TmpSceneDC);
    ReleaseDC(hwnd,Boy1DC);
    ReleaseDC(hwnd,Boy2DC);
    ReleaseDC(hwnd,Girl1DC);
    ReleaseDC(hwnd,Girl2DC);
    ReleaseDC(hwnd,DiagDC);

    DeleteObject(MainRoleBMP);
    DeleteObject(memBMP);
    DeleteObject(msgboxBMP);
    DeleteObject(MapBMP);
    DeleteObject(Font);
    DeleteObject(TmpMapBMP);
    DeleteObject(TmpSceneBMP);
    DeleteObject(Boy1BMP);
    DeleteObject(Boy2BMP);
    DeleteObject(Girl1BMP);
    DeleteObject(Girl2BMP);
    DeleteObject(DiagBMP);
}
阅读更多

没有更多推荐了,返回首页