How do you "equip" things? :D

First i would like to say that i'm new and have been learning for about four or five days now.
I'm making a little adventure game (console window :D)
and I was wonder how would I equip things, for example;
The character walks into a hude door and the only way to get through it is to cut it down. now earlier the character had seen a axe, how would i make it so that the character could hold the axe and chop the gate down?
closed account (S6k9GNh0)
How do you plan on doing this via console? ASCII symbols?
How do you use ASCII symbols in making such a game
Do you mean how can you know that the character has the axe object?

Many, many ways. You could have a boolean variable named "hasAxe" that changes when the character holds or does not hold the axe.
closed account (zb0S216C)
Here's a rough code segment that may prove useful to you:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class WEAPON
{
    int Damage;
    std::string Name;
};

class ENEMY
{
    int Health;
    std::string Name;
};

class PLAYER
{
    WEAPON *ActiveWeapon;
    
    void UseWeapon( ENEMY &TargetEnemy )
    {
        if( this->ActiveWeapon == nullptr )
            return;

        TargetEnemy.Health -= ActiveWeapon->Damage;
    }
};

Confused? If you are, I wouldn't be surprised. Now, since you're new, I don't expect you to know what this means. This example is an OOP (Object Orientated Programming) approach to game development. Personally, the OOP approach is easier to understand.

I have no intention of killing your interest in C++ with examples such as the one above. Instead, study how it's laid out. The whole concept of OOP, in a nutshell, is to group data to form an object. Here, there're 3 objects: The player, the enemy, and a weapon.

Don't get me wrong but building games is fun. However, you cannot rush yourself when it comes to programming, especially C++. Take your time and enjoy the learning process and gradually build your game as your learn.

Wazzak
Should i post everything i've written so far (i mean the coding i've done)?
I'm actually only making the game so i run into errors as much as possible and try work through them.
Thnx frame, but i don't think that's exactly what i wanted and seeing how my knowledge in c++ is very limited, at this time i'm not gonna try to write something that detailed (for me anyway -.-) into an already large (for me -.-) program, also lots of mistakes. So should i post what i've written so far?

closed account (zb0S216C)
blooddeal wrote:
So should i post what i've written so far? (sic)

If you wish. :)

Wazzak

// dhjyu56.cpp : Defines the entry point for the console application.
//
#include <iostream>
#include "stdafx.h"
#include<string>
using namespace std;

int functionEast()
{
string direction = "west";
string direction1 = "east";
string direction2 = "north";
string direction3 = "south";
string player;
string answer1 = "yes";
string answer2 = "no";
string down = "down";
string up = "up";

cout << "You enter a large cabin\n" "You entered the cabin, you can see stairs up and down which way?\n";
cin >> player;
if (player == down)
cout << "You enter the cellar and notice a shining blue crystal, as you walk towards it a midget grabs your nuts, and you die.";
else if (player == up)
cout << "lol, no you're not going up there";
else cout <<"Retard, either type up or type down";


char f;
cin >> f;
return 0;


}




int functionSouth()
{
string direction = "west";
string direction1 = "east";
string direction2 = "north";
string direction3 = "south";
string player;
string answer1 = "yes";
string answer2 = "no";
{
{
cout << "You smell an african child molesting some sheep, do you want to do a pooh\n?";
cin >> player;
if (player == "yes")

cout << "That's just disgusting, but... that's how you win the game!! You have won, Congratz!!";
if (player == "no")
cout << "why not? You ate some pork before, oh no.... your stomach exploded from to much pork and you neglecting to take a shit. You have died, that is absolutely terrible. " << "The end";

char f;
cin >> f;
return 0;

}



}






char f;
cin >> f;
return 0;


}


int functionNorth()

{

{
string direction = "west";
string direction1 = "east";
string direction2 = "north";
string direction3 = "south";
string player;
string answer1 = "yes";
string answer2 = "no";

cout << "As you pass through the forest you smell something, follow it?\n";

if (player == answer1)

cout << "You found a burnt kebab left by a lebo, do you want to eat it?\n";
cin >> player;


if (player == answer2)

cout << "Ok, Where now?\n";
cin >> player;


if (player == "south")
functionSouth();

if (player == "east")
cout << " You walk into a wooden shed";

if (player == "north")

cout << "Well you want to go north do you?\n Well that's to bad. I'll take you east :)\n";
(player == "east");
cout << "you're now in east";


if (player == answer1)
cout << "A lebo comes out of the bushes and slits your throat with a plastic glass,\n you're dead";
if (player == answer2)
cout << "Well... where now?\n";
cin >> player;
if (player == "east")
cout << "you find yourself caught in a spiders web, you don't have a weapon" << endl << "You try squeeze your way out, and you are succesfull\n" << "where now?\n";
cin >> player;
if (player == "north")
{
cout << "You see a mountain, climb it?\n";
cin >> player;
}

else if (player == answer1)
cout << " As you reach the top you see the surrounding area,\n to the north, only a vast sand maze which surely leads to death,\n to the south a cave, with a large opening,\n to the east, there is a 7/11 with a bunch of bogans smoking ciggies,\n to the west, there is gold!";
if (player == "south")
cout << "You can't go that way, it's the end of the map, choose again\n";



if( player == "east")

cout << " You end up in a abonded house, you enter in and on the table is a knife, pick it up?";
cin >> player;


char f;
cin >> f;
return 0;






}
int main();
{

string direction = "west";
string direction1 = "east";
string direction2 = "north";
string direction3 = "south";
string player;
string answer1 = "yes";
string answer2 = "no";

int x = 9;

cout << "This is my first game.\n";
cout << "You have to make your way home.\n";
cout << "Type in either east, west, north or south.\n";
cout << "Wich way do you want to go?\n";
cout << "Choose your direction:\n";
cin >> player;

if (player == "north")
functionNorth();

if (player == "west")

cout << "You see a car through the thick fog!\n";

else if (player == "east")
functionEast();

else if (player == "south")
{

cout << "It's blocked off, try another way\n";
cin >> player;
}
else if (player == "south")


cout << "You dumb? Enter a different direction\n";
cin >> player;


if (player == "east")
{
functionEast();
cin >> player;
}

else if (player == "north")
functionNorth();






char f;
cin >> f;
return 0;

}



Oh no!! As i was compying it, i done something, and couldnt get it fixed. :(
end of file found before the left brace '{
I was trying to correct it, but it was playing tricks.!!
Also don't laught at how silly it is or the fact that i'm not good at this
Last edited on
Topic archived. No new replies allowed.