Resolution confusion

This is a discussion on Resolution confusion within the Game Programming forums, part of the General Programming Boards category; I made the CAVE demo, a text game in C++. But i want it to automaticly switch to a full ...

  1. #1
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Question Resolution confusion

    I made the CAVE demo, a text game in C++. But i want it to automaticly switch to a full screen. I followed the tutorial, but it didn't work. I got 4 error, 2 of which were the real problems (2 where: #warning and {each unidentified...})
    I have the errors here:
    Code:
    #include <iostream.h>
    #include <stdlib.h>
    
    int main()
    {
    void SetMCGA() {
    
        _AX = 0x0013;
    
        geninterrupt (0x10);
    
      }
    
    }
    line 6: Parse error before {
    line 10: geninterrupt undeclared

    My game code is the next message, would someone please tell me how to make it work in that resolution?
    Or fix the code so that it does work, then post?
    Thank you!!!
    --------------------
    PS: I am a 'Newbie'
    Last edited by Blizzarddog; 12-11-2002 at 12:02 PM.
    This war, like the next war, is a war to end war.

  2. #2
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373

    Code

    The follwing code is property of:
    Blizzarddog Inc; The beave tribe, and all other Blizzarddog
    company branches.
    Stealing this code and claiming it your own is Illegal. Edit only for this post. Distribute this demo... but no saying that you made it!
    VIOLATORS WILL BE SUED

    Code:
    /********************************************************************
    *Zachs first CPP game. Kind of a RPG. Text based.
    *Started Dec. 1; Put in movement
    *Modified Dec. 2; put in some traps, items, more commands.
    *Modified Dec. 3; Defined enemies. Fixed health/end_game loop.
    *Defined Weaponry, bombs, and sword.
    *Still can't get item manipultion to work.
    *Modified Dec. 3; Got Items to work! Wolf is placed.
    *Modified Dec. 4; Ghost is placed, but not yet working.
    *Inserted 3 cheats.
    *Modified Dec. 9-10; Colored text, improved layout.
    *******************************************************************/
    
    #include <iostream>
    #include <cstdlib>
    #include <conio.h>             //allows getch();
    #include <iomanip>             //for setw
    #include <windows.h>           //for playsound()
    #include <mmsystem.h>          //for playsound()
    using namespace std;          //allows cout instead of std::cout
    /*Edit the following for your own custom game*/
    int player_location_Y = 0;    /* Player*/
    int player_location_X = 0;    /*  Start*/
    int health = 100;             //player health
    int health_potion = 10;       //gives ten health
    int end_game = 100;           // timer: if zero, game ends
    int points = 0;               //score
    int bread = 0;                //food
    int trap1 = 0;                //trap
    int trap2 = 0;                //trap
    int trap3 = 0;                //another trap
    int trap4 = 0;                //yet another trap
    int trap5 = 0;                //the last trap
    int wolf = 1;                //wolf enemy
    int ghost_Y = 10;               //ghost enemie
    int ghost_X = 10;
    int holy = 0;
    int dragon = 1;             //dragon enemie
    int ledge = 0;                //ledge
    int bomb = 10;                //ticking time bomb
    int sword = 0;                //weapon
    int gold = 2;
    int max_h = 100;
    int Y;
    int X;
    int need = 30 - gold;
    char input;
    
    void DrawColorString(string szText, int X, int Y, WORD color)
    {	
    	HANDLE OutputH;
    	COORD position = {X, Y};
    
    	OutputH = GetStdHandle(STD_OUTPUT_HANDLE);
    
    	SetConsoleTextAttribute(OutputH, color);
    
        SetConsoleCursorPosition(OutputH, position);
    
    	cout << szText;
    
    }
    
    int main()
    {
        char name[20];
        cout << "Welcome to CAVE.\n ";
        DrawColorString("",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\nPlease enter your name: ";
        cin >> name;
        cout << "\nHello " << name << ". Welcome to my quest!\n";
        cout << "You must venture through this maze avoiding traps\n";
        getch();
        {
         while (end_game > 0 || health > 0)
         {
         if (player_location_Y == 25)
         {
         system("cls");
         DrawColorString("BLOCKED!\n",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
         cout << "That way is blocked!\n\n";
         player_location_Y--;
         getch();
         }
         else if (player_location_Y == -25)
         {
         system("cls");
         DrawColorString("BLOCKED!\n",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
         cout << "That way is blocked!\n\n";
         player_location_Y++;
         getch();
         }
         else if (player_location_X == 25)
         {
         system("cls");
         DrawColorString("BLOCKED!\n",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
         cout << "That way is blocked!\n";
         player_location_Y--;
         getch();
         }
         else if (player_location_X == -25)
         {
         system("cls");
         DrawColorString("BLOCKED!\n",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
         cout << "That way is blocked!\n";
         player_location_Y++;
         getch();
         }
         system("cls");
        end_game--;
        {
        if (end_game <= 0)
           {
           system("cls");
            DrawColorString("GAME OVER\n",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
           cout << "Time Out!\n";
           system("pause");
           return 0;
           }
        }
        {
        if (health <= 0)
        	{
            system("cls");
            DrawColorString("GAME OVER\n",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        	cout << "Out of health!\n";
        	cout << "GAME OVER\n";
            system("pause");
        	return 0;
    	}
       }
        DrawColorString("\n", 20, 2, FOREGROUND_BLUE | FOREGROUND_GREEN);
        cout << setw(20) << "*****************************************\n";
        cout << setw(20) << "**|||||****||***|***|***|||||************\n";
        cout << setw(20) << "**||******|**|**|***|***||***************\n";
        cout << setw(20) << "**||*****||||||**|*|****||--*************\n";
        cout << setw(20) << "**||****||****||*|*|****||***************\n";
        cout << setw(20) << "**|||||*||****||* | ****|||||************\n";
        cout << setw(20) << "*****************************************\n\n";
    	cout << "__________________<CAVE V. 1.4>__________________\n\n";
        cout <<"North (N)\nSouth (S)\nEast (E)\nWest (W)\nHelp (H)\n\n";
        cin >> input;
    	cout <<"\n";
    
     	if (input == 'Q' || input == 'q')
    	{
    		system("cls");
    		return 0;
    	}
    
     	if (input == 'H' || input == 'h')
    	{
         system("cls");
         DrawColorString("HELP MENU",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout <<"\nNorth (n)\nSouth (S)\nEast(E)\nWest (W)\nQuit (Q)\n";
            cout <<"Life (L)\nPoints (P)\nHelp (H)\nTime (T)\nStory (Y)\n";
            cout <<"Full status (F)\n\n";
            cout <<"Gold: "<< gold<<"\n\n";
            cin >> input;
      	}
    
     	if (input == 'L' || input == 'l')
    	{
            system("cls");
            DrawColorString("HEALTH",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout << "\nHealth is "<<health<<"\n\n";
           getch();
    	}
    
      if (input == 'v' || input == 'V')
    	{
         system("cls");
         DrawColorString("CHEAT MENU",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout << "\nCheats:\n\n";
            cout << "More time (x)\n5+ gold (a)\nPosition jump (z)\nWin game (o)\n";
            cout << "Must have 30 or more gold to use win game.\n";
            cin >> input;
    	}
    
     	if (input == 'P' || input == 'p')
    	{
            system("cls");
            DrawColorString("POINTS",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout << "\nPoints are "<<points<<"\n\n";
            getch();
    	}
    
        if (input == 'T' || input == 't')
    	{
            system("cls");
            DrawColorString("TIME REMAIN",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout << "\nTime left is "<<end_game<<" moves left.\n\n";
            getch();
    	}
    
        if (input == 'M' || input == 'm')
    	{
            system("cls");
            DrawColorString("MAP",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout << "\nPosition is\nY: " << player_location_Y << "\nX: ";
            cout << player_location_X <<"\n\n";
            getch();
    	}
    
        if (input == 'y' || input == 'Y')
    	{
         system("cls");
         DrawColorString("STORY",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout << "\n\n'Marry my daughter? You? Why, I wouldn't let\n";
            cout << "you marry my neighbors dog! You don't have any\n";
            cout << "money at all! If you can get 30 gold, you can\n";
            cout << "marry her.'\n";
            cout << "Those words rang through your head as you searched\n";
            cout << "for 30 gold coins. You pawned your gold watch and\n";
            cout << "got 6 gold. Then the sheriff came and collected taxes,\n";
            cout << "leaving you with 2 coins. No one will hire you.\nn";
            cout << "The citizens aren't donating either. There is one\n";
            cout << "hope left... the cave. Many people go in, all rich.\n";
            cout << "None came out. You were sure to find 30 coins in there.\n\n";
            cout << "You remember your mother, 'Don't go in there, you'll\n";
            cout << "never come out!\n\n";
            cout << "You light a torch and enter the cave....\n\n";
            getch();
    	}
    
    
     	if (input == 'n' || input == 'N')
    	{
        system("cls");
        DrawColorString("MOVING",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\nYou venture north\n";
    	   player_location_Y = player_location_Y++;
        getch();
    	}
    
    	if (input == 's' || input == 'S')
    	{
        system("cls");
        DrawColorString("MOVING",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\nYou venture south\n";
    		player_location_Y = player_location_Y--;
        getch();
    	}
    
    	if (input == 'e' || input == 'E')
    	{
        system("cls");
        DrawColorString("MOVING",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\nYou venture east\n";
    		player_location_X = player_location_X++;
        getch();
    	}
    
    	if (input == 'w' || input == 'W')
    	{
        system("cls");
        DrawColorString("MOVING",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\nYou venture west\n";
    		player_location_X = player_location_X--;
        getch();
    	}
    
        if (input == 'z')
    	{
        system("cls");
        DrawColorString("POSITION JUMP",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\nEnter location Y: ";
        cin >> Y;
        cout << "Enter location X: ";
        cin >> X;
        player_location_Y = Y;
        player_location_X = X;
        cout << "\nPosition:\nY: " << player_location_Y << "\nX: ";
        cout << player_location_X << "\n";
        getch();
    	}
    
        if (input == 'x')
    	{
        system("cls");
        DrawColorString("TIME CHEAT, WIMP",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\n10 turns added.";
        end_game = end_game + 10;
        cout << "\nturns left: " << end_game;
        getch();
    	}
    
        if (input == 'a')
    	{
        system("cls");
        DrawColorString("MONEY CHEAT",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
        cout << "\n5 gold added.";
        gold = gold + 5;
        cout << "\nGold: " << gold;
        getch();
    	}
    
        if (input == 'F' || input == 'f')
    	{
         system("cls");
         DrawColorString("FULL STATS",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		cout << "\nHealth is "<<health<<"\n";
            cout << "Gold is: "<<gold<<"\n";
            cout << "Points are: "<<points<<"\n";
            cout << "Time left: "<<end_game<<" moves.\n";
            getch();
    	}
    
        if (input == 'o' || input == 'O')
        {
           if (gold < 30)
    	      {
                 system("cls");
                 DrawColorString("CHEATER",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
    		     cout << "\nNot enough gold to win!\n"<<need<<" needed";
                 getch();
    }
           else if (gold <= 30)
                {
                 system("cls");
                 DrawColorString("CHEATER",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                 cout << "\nYou win! Points: " << points << "\n";
                 system("pause");
                 return 0;
                }
    	}
    
    if (player_location_Y == 0 && player_location_X == 1)  //wall
    {
                system("cls");
                DrawColorString("WALL!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nThats a wall, stupid!\n";
                player_location_X--;
                getch();
    }
    
    if (player_location_Y == 1 && player_location_X == 1)  //wall
    {
                system("cls");
                DrawColorString("WALL!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nThats a wall, stupid!\n";
                player_location_X--;
                getch();
    }
    
    if (player_location_Y == 2 && player_location_X == 1)  //wall
    {
                system("cls");
                DrawColorString("WALL!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nThats a wall, stupid!\n";
                player_location_X--;
                getch();
    }
    
    if (player_location_Y == 3 && player_location_X == 1)  //wall
    {
                system("cls");
                DrawColorString("WALL!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nThats a wall, stupid!\n";
                player_location_X--;
                getch();
    }
    
    if (player_location_Y == 4 && player_location_X == 1)  //wall
    {
                system("cls");
                DrawColorString("WALL!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nThats a wall, stupid!\n";
                player_location_X--;
                getch();
    }
    
    if (player_location_Y == 5 && player_location_X == 0)  //fountain
    {
       if (health < max_h)
                {
                system("cls");
                DrawColorString("Fountain!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nFountain of cool water, + 5 health!\n";
                getch();
    }
       else if (health == max_h)
                {
                system("cls");
                DrawColorString("Fountain!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nYou can't drink a drop of water.\n";
                getch();
                }
    }
    
     if (player_location_Y == 7 && player_location_X == 0)  //bread
    {
       if (bread == 0)
                {
                system("cls");
                DrawColorString("FOOD!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nLoaf of bread! + 20 time!\n";
                points = points + 1;
                bread = bread + 1;
                getch();
    }
       else if (bread == 1)
                {
                system("cls");
                DrawColorString("CRUMBS!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nBread crumbs\n";
                getch();
                }
    }
    
     if (player_location_Y == 3 && player_location_X == 5)  //trap1
    {
       if (trap1 == 0)
                {
                system("cls");
                DrawColorString("TRAP",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nFire pit! - 10 health!\n";
                health = health - 10;
                trap1 = trap1 + 1;
                getch();
    }
       else if (trap1 == 1)
                {
                system("cls");
                DrawColorString("TRAP",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nYou carefully cross the fire pit\n";
                getch();
                }
    }
    
     if (player_location_Y == -5 && player_location_X == 9)  //trap2
    {
       if (trap2 == 0)
                {
                system("cls");
                DrawColorString("TRAP",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nYIKES! SPIKES! - 25 health!\n";
                health = health - 10;
                trap2 = trap2 + 1;
                getch();
    }
       else if (trap2 == 1)
                {
                system("cls");
                DrawColorString("TRAP",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nYou carefully cross the spikes\n";
                getch();
                }
    }
    
     if (player_location_Y == 7 && player_location_X == 5)  //sword
    {
       if (sword == 0)
                {
                system("cls");
                DrawColorString("SWORD",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nThere is a sword. Heavy, but usable.\n";
                sword = sword + 1;
                points = points + 10;
                getch();
    }
       else if (sword == 1)
                {
                system("cls");
                DrawColorString("SWORD",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nA sword used to be here.\n";
                getch();
                }
    }
    
     if (player_location_Y == -5 && player_location_X == 1)  //wolf
    {
       if (sword == 0)
                {
                system("cls");
                DrawColorString("WOLF!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nA wolf jumps out of a hole and kills you!\n";
                health = 0;
                getch();
    }
       else if (sword == 1 && wolf == 1)
                {
                system("cls");
                DrawColorString("WOLF!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nA wolf jumps out of a hole, but you kill it.\n";
                wolf = 0;
                getch();
    }
       else if (wolf == 0)
                {
                system("cls");
                DrawColorString("WOLF!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nA wolf's corpse remains.\n";
                getch();
    }
    
     if (player_location_Y == -19 && player_location_X == 7)  //light
    {
       if (gold < 30)
                {
                system("cls");
                DrawColorString("ALMOST!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nOne more step to the south, and you'll win..\n";
                cout << "but wait...\n";
                cout << "Not enough gold!\n";
                cout << "Gold needed: " << need << "\n";
                getch();
    }
       else if (gold >= 30)
                {
                system("cls");
                DrawColorString("ALMOST!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nOne more step south, and you win!\n";
                getch();
    }
       else if (gold == 50)
                {
                system("cls");
                DrawColorString("ALMOST!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\n50 gold! WOW! STEP SOUTH TO WIN, MY LORD!.\n";
                getch();
    }
    }
    
    if (player_location_Y == ghost_Y && player_location_X == ghost_X)  //ghost
    {
       if (holy == 0)
                {
                system("cls");
                DrawColorString("G-GHOST!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nYou see a ghost. He tries to talk to you\n";
                cout << "but you don't have any holy power to hear him\n!";
                getch();
                }
    }
       else if (holy == 1)
                {
                system("cls");
                DrawColorString("G-GHOST!",10, 1, FOREGROUND_RED | FOREGROUND_BLUE);
                cout << "\nA ghost appears and says:\n";
                cout << "At position y (-20) and x (17)\n";
                cout << "is your destiny.";
                getch();
                }
    }
    }
    }
    }
    Last edited by Blizzarddog; 12-11-2002 at 04:55 PM.
    This war, like the next war, is a war to end war.

  3. #3
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    The follwing code is property of:...
    You're taking your whole little explanation way too far. Don't worry, nobody is going to make it big off of your code lol!

    Btw, nobody is going to help you until you make use out of
    [ code ] tags [ /code ]

  4. #4
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    I did put [ code ] tags [ /code ]
    I took it that far because some one stole my digital music and i don't want it happening to my source code. lol.
    This war, like the next war, is a war to end war.

  5. #5
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369
    I hope you're joking. BTW, you need to add a [/code] at the end of your code.
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  6. #6
    Linux Forever
    Join Date
    Oct 2002
    Posts
    373
    Ah-HA! That's all that was wrong????? THAT'S ALL????
    PHP sux, C++ ROOLZ!
    This war, like the next war, is a war to end war.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ubuntu screen resolution
    By lruc in forum Tech Board
    Replies: 13
    Last Post: 11-27-2008, 05:03 PM
  2. Function to find resolution
    By Bag a Bones in forum C++ Programming
    Replies: 7
    Last Post: 01-19-2006, 12:53 PM
  3. Resolution testing for. . .
    By Waspntr in forum Windows Programming
    Replies: 6
    Last Post: 02-18-2003, 10:31 PM
  4. DOS resolution problem in Win2k
    By charisma in forum C Programming
    Replies: 2
    Last Post: 12-27-2002, 05:04 AM
  5. How to write code to change the printer resolution
    By ooosawaddee3 in forum C++ Programming
    Replies: 0
    Last Post: 07-26-2002, 07:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21