| | |
BIG Function Help..
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Aug 2005
Posts: 29
Reputation:
Solved Threads: 0
So my problem is that my function isn't working properly. I realize that this is not efficient but I need it done in one fucntion.
It is supposed to be a function that draws a room and lets you walk around in it using the arrow keys in console mode.
The Problem lies in the movement..Something is very messed up and I just can't understand why! :eek:
Here is the code and if ANYONE can help Thank You!!!
This is in Dev-C++ on a windows machine.
It is supposed to be a function that draws a room and lets you walk around in it using the arrow keys in console mode.
The Problem lies in the movement..Something is very messed up and I just can't understand why! :eek:
Here is the code and if ANYONE can help Thank You!!!
C++ Syntax (Toggle Plain Text)
#include <cstdlib> #include <iostream> #include <conio.h> using namespace std; void MovementAndRoom(int height, int width){ /* **corner - All refer to the corners ASCII code *border - Refers to the border ASCII code space - Refers to space ASCII code o* - Refer to the original Values given to the function //331 Left //333 right //328 UP //336 Down */ char tleftcorner = 201; char bleftcorner = 200; char trightcorner = 187; char brightcorner = 188; char hborder = 186; char vborder = 205; char space = 040; /* int left = 331; int right = 333; int up = 328; int down = 336; */ int oheight = height; int owidth = width; int currentLineNumber = 0; int currentRowNumber = 0; int rowNumber = 3; int lineNumber = 6; char move; while(true){ move; while(move = getch()){ currentRowNumber = 0; currentLineNumber = 0; //Use of the Color Console Code to Color the Box cout << tleftcorner; //Makes the top bar - vborder is shown twice because a line break is //roughly twice as large as a space width = owidth; height = oheight; while(width > 0){ cout << vborder << vborder; width--; } //Show the Right Corner cout << trightcorner << endl; //Resets Width width = owidth; //Makes the rows with spaces in betwen for future expansion while(height > 0){ //Shows Border cout << hborder; while(width > 0){ if(lineNumber == currentLineNumber && (rowNumber * currentLineNumber) == currentRowNumber){ cout << "X" << space; } else{ //Adds Spaces cout << space << space; } currentRowNumber++; width--; } //Shows Right Border cout << hborder << endl; currentLineNumber++; currentRowNumber = owidth; //Resets Width width = owidth; //Lowers Height for new Row height--; } //Shows Bottom Left Corner cout << bleftcorner; //Shows the bottom Border while(width > 0){ cout << vborder << vborder; width--; } //Shows Last Corner cout << brightcorner << endl; move; move = getch(); switch(move){ case 331: if(rowNumber == 1){ break; } rowNumber--; move; break; case 333: if(rowNumber == width - 1){ break; } rowNumber++; move; break; case 328: if(lineNumber == height - 1){ break; } move = 'a'; lineNumber--; break; case 336: if(lineNumber == 1){ break; } move = 'a'; lineNumber++; break; } } } } int main(int argc, char *argv[]) { int width = 5,height = 5; //Calls room function cout << "How Wide do you want to the room to be? "; cin >> width; cout << "How High do you want to the room to be? "; cin >> height; MovementAndRoom(height,width); system("PAUSE"); return EXIT_SUCCESS; }
This is in Dev-C++ on a windows machine.
![]() |
Similar Threads
- c language problm, how to pass pointer to a function (C)
- factoring function for large numbers (C++)
- Cannot get PAIR::big to just display greater number (C++)
- Big-theta notation question. (Computer Science)
- Shell Function (Visual Basic 4 / 5 / 6)
- Big Problem, Generic Error (VB.NET)
- i need to add function for add, subtract, multiply and division. (C++)
- I have a question about functions (Java)
Other Threads in the C++ Forum
- Previous Thread: Create log file in Visual C++.NET
- Next Thread: Plz, helping with writing a bit of code. Thanks
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class classes code coding compile console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker linux list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





