资源简介

c++实现的彩色控制台版本吃豆人,单个怪物,怪物能自动寻路,具体功能参见资源内的用户手册

资源截图

代码片段和文件信息

#include “CGame.h“
#include “StdAfx.h“
#include “setdisplay.h“

#include 
#include 

CGame::CGame()
{
//     nCurrentPlayerX = nPlayerStartX;
//     nCurrentPlayerY = nPlayerStartY;

    //nCurrentGhostX = nMonsterStartX;
    //nCurrentGhostY = nMonsterStartY;
}

// void CGame::SetCurrentGhostX(int CurrentGhostX)
// {
//     nCurrentGhostX = CurrentGhostX;
// }
// 
// void CGame::SetCurrentGhostY(int CurrentGhostY)
// {
//     nCurrentGhostY = CurrentGhostY;
// }

void CGame::echoMap()
{
    int i = 0;
    int j = 0;
    // 设置颜色
    WORD ColorWall = SetConsoleColor(0  COLOR_GREEN);  // 绿色背景,前景无所谓
    WORD ColorRoad = SetConsoleColor(0  COLOR_WHITE);  // 白色背景,前景无所谓
    WORD ColorGhost = SetConsoleColor(COLOR_PURPLE  COLOR_WHITE); // 紫色前景,白色背景
    WORD ColorFrightenGhost = SetConsoleColor(COLOR_BLUE  COLOR_WHITE); // 蓝色前景,白色背景
    WORD ColorBean  = SetConsoleColor(COLOR_BLACK  COLOR_WHITE);  // 黑色前景,白色背景
    WORD ColorPlayer = SetConsoleColor(COLOR_RED  COLOR_WHITE);   // 红色前景,白色背景
    WORD ColorSuperBean  = SetConsoleColor(COLOR_YELLOW  COLOR_WHITE);   // 黄色前景,白色背景
    WORD ColorText = SetConsoleColor(COLOR_LIGHTBLUE  COLOR_WHITE);   // 蓝色前景,白色背景

    // 输出地图
    for(i = 0; i < MAPROW ; ++i)
    {
        for(j = 0; j < MAPCOL; ++j)
        {
            // 打印元素
            if (g_map[ i ][ j ] == 1)
            {
                WriteChar(i  j  “  “  ColorWall);
            }
            if (g_map[ i ][ j ] == 3 || g_map[ i ][ j ] == 2)
            {
                WriteChar(i  j  “  “  ColorRoad);
            }
            if (g_map[ i ][ j ] == 0)
            {
                WriteChar(i  j  “☉“  ColorBean);
            }
            if (g_map[ i ][ j ] == 47)
            {
                WriteChar(i  j  “★“  ColorPlayer);
            }
            if (g_map[ i ][ j ] == 9)
            {
                WriteChar(i  j  “▲“  ColorSuperBean);
            }
            if (g_map[ i ][ j ] == 99 && nMonsterState == 0)
            {
                WriteChar(i  j  “●“  ColorGhost);
            }
            if (g_map[ i ][ j ] == 99 && (nMonsterState == 1 || nMonsterState == 2))
            {
                WriteChar(i  j  “●“  ColorFrightenGhost);
            }
            if(i == 11 && j == 27)
            {
                WriteChar(i  j + 2 “-----------------“  ColorText);
               // printf(“%s“ “     -----------------“);
            }
            if(i == 12 && j == 27)
            {
                WriteChar(i  j + 2 “|    游戏规则   |“  ColorText);
                //printf(“%s“ “     |    游戏规则   |“);
            }
            if(i == 13 && j == 27)
            {
                WriteChar(i  j + 2  “-----------------“  ColorText);
                //printf(“%s“ “     -----------------“);
            }
            if(i == 14 && j == 27)
            {
                WriteChar(i  j + 2 “|    W

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-04-28 21:52  吃豆人\pacman1\
     目录           0  2018-04-30 17:21  吃豆人\pacman1\pacman1\
     文件       30805  2018-04-30 17:18  吃豆人\pacman1\pacman1\CGame.cpp
     文件        6634  2018-04-30 16:14  吃豆人\pacman1\pacman1\CGame.h
     目录           0  2018-04-30 17:18  吃豆人\pacman1\pacman1\Debug\
     文件       68449  2018-04-30 17:20  吃豆人\pacman1\pacman1\Debug\CGame.obj
     文件           0  2018-04-30 17:20  吃豆人\pacman1\pacman1\Debug\CGame.sbr
     文件     3081216  2018-04-30 17:20  吃豆人\pacman1\pacman1\Debug\pacman1.bsc
     文件      282695  2018-04-30 17:20  吃豆人\pacman1\pacman1\Debug\pacman1.exe
     文件      420964  2018-04-30 17:20  吃豆人\pacman1\pacman1\Debug\pacman1.ilk
     文件       20191  2018-04-30 16:55  吃豆人\pacman1\pacman1\Debug\pacman1.obj
     文件      400336  2018-04-29 03:23  吃豆人\pacman1\pacman1\Debug\pacman1.pch
     文件      820224  2018-04-30 17:18  吃豆人\pacman1\pacman1\Debug\pacman1.pdb
     文件           0  2018-04-30 16:55  吃豆人\pacman1\pacman1\Debug\pacman1.sbr
     文件       16483  2018-04-29 03:23  吃豆人\pacman1\pacman1\Debug\setdisplay.obj
     文件           0  2018-04-29 03:23  吃豆人\pacman1\pacman1\Debug\setdisplay.sbr
     文件        2047  2018-04-29 03:23  吃豆人\pacman1\pacman1\Debug\StdAfx.obj
     文件        4072  2018-04-29 03:23  吃豆人\pacman1\pacman1\Debug\StdAfx.sbr
     文件      214016  2018-04-30 17:20  吃豆人\pacman1\pacman1\Debug\vc60.idb
     文件      151552  2018-04-30 17:18  吃豆人\pacman1\pacman1\Debug\vc60.pdb
     文件         337  2018-04-30 16:19  吃豆人\pacman1\pacman1\pacman1.cpp
     文件        4848  2018-04-29 04:55  吃豆人\pacman1\pacman1\pacman1.dsp
     文件         520  2018-04-28 21:52  吃豆人\pacman1\pacman1\pacman1.dsw
     文件       66560  2018-04-30 17:21  吃豆人\pacman1\pacman1\pacman1.ncb
     文件       51712  2018-04-30 17:21  吃豆人\pacman1\pacman1\pacman1.opt
     文件        1153  2018-04-30 17:20  吃豆人\pacman1\pacman1\pacman1.plg
     文件        1214  2018-04-28 21:52  吃豆人\pacman1\pacman1\ReadMe.txt
     文件        4975  2018-04-28 22:04  吃豆人\pacman1\pacman1\setdisplay.cpp
     文件        2760  2017-07-28 19:36  吃豆人\pacman1\pacman1\setdisplay.h
     文件         294  2018-04-28 21:52  吃豆人\pacman1\pacman1\StdAfx.cpp
     文件         769  2018-04-28 21:52  吃豆人\pacman1\pacman1\StdAfx.h
............此处省略1个文件信息

评论

共有 条评论