Download

How would I go about making a "text" game in Blueprints?

I want to make a text game where you can move a text representation of a player on a grid. Something liek this C++ code I wrote a while back, but instead of using console to control movement it would just be WASD. I need to translate this into blueprint, but i’m a little confused on how to go about that.


#include <iostream>
#include <string>

int main()
{
    char character = 'O';
    const char mapTile = '-';
    char boulder = 'G';
    const int mapX = 12;
    const int mapY = 23;
    char gameMap[mapX][mapY];

    int playerXCoord = 0;
    int playerYCoord = 0;

    int boulderX = 5;
    int boulderY = 5;

    int choice{};

    while (choice != -1)
    {
        for (int i = 0; i < mapX; i++)
        {
            for (int j = 0; j < mapY; j++)
            {
                gameMap*[j] = mapTile;
                gameMap[boulderX][boulderY] = boulder;
                gameMap[playerXCoord][playerYCoord] = character;
                std::cout << gameMap*[j];
            }
            std::cout << std::endl;
        }

        std::cout << "Player X: " << playerXCoord << "
";
        std::cout << "Player Y: " << playerYCoord << "

";

        std::cout << "Which direction would you like to move in?
";
        std::cout << "1) Up
";
        std::cout << "2) Down
";
        std::cout << "3) Left
";
        std::cout << "4) Right
";

        std::cin >> choice;

        switch (choice)
        {
        case 1:
            if (playerXCoord < 1)
            {
                std::cout << "Cannot go Up anymore
";
            }
            else
            {
                playerXCoord -= 1;
            }
            break;
        case 2:
            if (playerXCoord == mapX - 1)
            {
                std::cout << "Cannot go in Down anymore
";
            }
            else
            {
                playerXCoord += 1;
            }
            break;
        case 3:
            if (playerYCoord < 1)
            {
                std::cout << "Cannot go Left anymore
";
            }
            else
            {
                playerYCoord -= 1;
            }
            break;
        case 4:
            if (playerYCoord == mapY - 1)
            {
                std::cout << "Cannot go Right anymore
";
            }
            else
            {
                playerYCoord += 1;
            }
            break;
        default:
            std::cout << "Error
";
        }
    }

    return 0;
}


The advantages of using a 3D engine relies on overcoming the need for you to code your own DirectX/OpenGL 3D code.

Why do you need a 3D powerhouse like Unreal Engine to build a text adventure? That can be done directly from a pure Visual Studio application.

Anyway, the FString class can be used for that, UMG can be used to display the text on screen.

Because I really hate programming in C++ honestly, I mean dont get me wrong it’s fun sometimes as a side hobby, but I just despise doing it for actual work.