Viewing a single comment thread. View all comments

SplitRings t1_j27x27t wrote

Why wait a year?

My Prompt: Create a simple text based game in c++

ChatGPT: Sure! Here is a simple text-based game in C++ that allows the player to explore a small, imaginary world and collect treasures:

(Copy pasting to Reddit ruined indentation but whatever)

#include <iostream> #include <string> using namespace std; int main() { // Declare variables string location; int treasureCount = 0; // Welcome message cout << "Welcome to the treasure hunt game!" << endl; cout << "In this game, you will explore a small, imaginary world and collect treasures." << endl; // Main game loop while (true) { cout << "You are currently in: " << location << endl; cout << "Treasure count: " << treasureCount << endl; cout << "What do you want to do?" << endl; cout << "1. Go north" << endl; cout << "2. Go east" << endl; cout << "3. Go south" << endl; cout << "4. Go west" << endl; cout << "5. Pick up treasure" << endl; cout << "6. Quit game" << endl; int choice; cin >> choice; if (choice == 1) { location = "north"; } else if (choice == 2) { location = "east"; } else if (choice == 3) { location = "south"; } else if (choice == 4) { location = "west"; } else if (choice == 5) { cout << "You have picked up a treasure!" << endl; treasureCount++; } else if (choice == 6) { cout << "Thanks for playing!" << endl; break; } else { cout << "Invalid choice, please try again." << endl; } } return 0; }

This game will present the player with a menu of options, and allow them to choose which direction to move or pick up a treasure. The player can also quit the game at any time. The game keeps track of the player's location and treasure count, and prints this information to the screen each time the menu is displayed.

I hope this helps! Let me know if you have any questions or if you'd like to see any other examples.

(It's not fun but it's a game)

3

Joeskithejoe OP t1_j2bjf9a wrote

That’s really cool, so where would you input that code in order to get a playable game?

1