Help me please!

Started by
23 comments, last by Zael 11 years, 12 months ago

Because if u want me to do a Text game i think i will need just : char,int,array,cin.cout,if,else,while,do while? not too much smile.png.I was thinking at making a maze but i am too stupid to make an object to move around sad.png(I CANT find any tutus on net)
I thought if i make something like this will work but i am pretty sure it wont work biggrin.png : so if we have a char ,,&,, and a room:
1 2 3 (<== room)
4 & 6
7 8 9
and he is siting on 5 i can make him to move using an algoritm like : 8-5 = 2 if he want to go to 2 but i cant imagin how to move an object around using MATH (i am not so bad at match but this is very hard) whitout that ideea from up i cant imagin something else...
I was thinking at this cuz when i made the tic-tac toe it was like this, but i want to make him to move perfect not in many screens if u understand.
And i was thinking to add:

(i cant make it to work on the forum but u can try it for yourself)
* * * * * * * * * * * *
* *
* Hello, Vlad! *
* *
********************

so i made this program:


// ask for a person's name, and generate a greeting
#include <iostream>
#include <string>

int main()
{
std::cout << "Please enter your first name: ";
std::string name;
std::cin >> name;

// build the message that we intend to write
const std::string greeting = "Hello, " + name + "!";

// build the second and fourth lines of the output
const std::string spaces(greeting.size(), ' ');
const std::string second = "* " + spaces + " *";

// build the first and fifth lines of the output
const std::string first(second.size(), '*');

// write it all
std::cout << std::endl;
std::cout << first << std::endl;
std::cout << second << std::endl;
std::cout << "* " << greeting << " *" << std::endl;
std::cout << second << std::endl;
std::cout << first << std::endl;

return 0;
}
(i dont know if this is a rule but when i want to use the string amd i use << xxx << instend of + xxx + is not working)
If someone know a better way to show the ,,*,, please post it,thanks for reading,please comment biggrin.png
and a way to put the ,*, as the walls(it dosent matter if they are solid -for text game dosent mater, but if u know how to make it solid leave anathor post biggrin.png.
Finally i want to thanks to everyone for such a good COMUNITY! Have a nice day !


Use code tags please (there's a button in the text editor shaped like "<>".

write

using namespace std;

at the top of your code (below #include <iostream>)

That way you don't have to write out 'std::' all the time
Advertisement
Thx,
Guys i have a very important question for you!! please respond as quickly is possible!!!
1) How can i make a main menu where the player will see start game,save game,load,credits,exit.Then i want to start the main game in a different screen,like the pages from the book,damn eng.
2)And can i color the numbers or the letters?
Thanks for helping me out! Have a nice day!


P.S:If u teach me how to make the main menu please take your time and teach me how to make a script for saving and loading the game,TY!

How can i make a main menu where the player will see start game,save game,load,credits,exit.Then i want to start the main game in a different screen,like the pages from the book,damn eng.
[/quote]
What specific parts of making a main menu are you having trouble with? What have you got working so far?


And can i color the numbers or the letters?
[/quote]
Standard c++ does not provide you with a way to do this. You can use platform specific APIs to do this.

For example, on Windows you can call a function SetConsoleTextAttribute to do this:

#include <string>
#include <iostream>
#include <Windows.h>

int main()
{
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
WORD colours[] = { FOREGROUND_RED, FOREGROUND_GREEN, FOREGROUND_BLUE };
for(int i = 0 ; i < 3 ; ++i)
{
SetConsoleTextAttribute(console, colours);
std::cout << "Dark!" << std::endl;
SetConsoleTextAttribute(console, colours | FOREGROUND_INTENSITY);
std::cout << "Bright!" << std::endl;
std::string s;
std::getline(std::cin, s);
}

const WORD Yellow = FOREGROUND_RED | FOREGROUND_GREEN;
SetConsoleTextAttribute(console, Yellow);
std::cout << "Dark Yellow!" << std::endl;
SetConsoleTextAttribute(console, Yellow | FOREGROUND_INTENSITY);
std::cout << "Bright Yellow!" << std::endl;

std::string s;
std::getline(std::cin, s);
}

There are similar BACKGROUND colour constants. As illustrated, you can get other colours by combining the colours using the bitwise OR operator. The colours you can make are illustrated like so, and as demonstrated you can use the FOREGROUND_INTENSITY to make a brighter colour.


P.S:If u teach me how to make the main menu please take your time and teach me how to make a script for saving and loading the game,TY!
[/quote]
Take things one step at a time. Get a simple menu to work first - don't include "save" or "load" for the moment.
Rip-off u are one of the best guy from here biggrin.png and i want to thanks you very much for helping a noob how to fix out the problems.
I want to make Main menu where u can see the start game and exit(u said no save/load biggrin.png)
And i was looking for a

[background=transparent]CONSOLE RPG GAME tutorial but i cant find one (i want to have it for the future)[/background]


I want to make Main menu where u can see the start game and exit(u said no save/load )
[/quote]
I understand. Still, what specific parts of making a main menu are you having trouble with? What have you got working so far?
I have problem have problem with all the main menu biggrin.png but i made an @ to move around in a room biggrin.png and now i am trying to add a new room(i only need to make a room then to add & no? i mean to connect them eachother)
Typically in a text based game a menu will be simple output with different input option.


Example "Menu":

int choice = 0;
while(choice != 2)
{
std::cout << "What would you like to do?\n";
std::cout << "1) Start a new game\n";
std::cout << "2) Quit\n";
cin >> choice;
switch (choice)
{
case 1:
startGame();
break;
case 2:
return;
break:
}
}


Does that make sense or are you asking something else?
Man...thx for helping but i am not stupid,i am making a Dos Rpg game biggrin.png not a text game cuz that is too simple biggrin.png
Didn't mean to insult you. You would be surprised at some of the simple things people will ask how to do. In a cmd window I am not aware of any mouse functions (could be wrong), so you may still need to do a simple menu like that when the user makes choices. Of course maybe you are more creative than I. Ideally you would use a system library that reads each key as it is pressed (instead of waiting for the user to hit the enter key). Most text based games I have played use a method like that with certain keys toggling a menu.

This topic is closed to new replies.

Advertisement