Aug 8, 2010 at 2:11am UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#include <iostream>
#include <windows.h>
#include <conio.h>
using namespace std;
char MMAP[80][45];
int GridX = 0;
int GridY = 0;
char THKey[10] = {0, '#' , '.' , '+' , '(' , ')' , 0, 1, 2, 3};
int CHKey[10];
int cTHKey = 1;
int cCHKey = 1;
char CCMD;
int main()
{
HANDLE hPos;
COORD CPOS;
hPos = GetStdHandle(STD_OUTPUT_HANDLE);
bool rLoop = true ;
for (int X = 0; X < 80; X++)
{
for (int Y = 0; Y < 45; Y++)
{
MMAP[X][Y] = '.' ;
}
}
for (int X = 0; X < 80; X++)
{
for (int Y = 0; Y < 45; Y++)
{
cout << MMAP[X][Y];
}
}
for (int X = 0; X < 79; X++)
{
cout << (char )205;
if (X == 37)
{
cout << (char )203;
}
}
cout <<
"ASCII Map Editor (80 x 45 characters) " << (char )186 << "Current Tile: ' ' " << endl <<
"Keys: " << (char )186 << "Tile Hotkeys: Color Hotkeys: " << endl <<
"'Q' = Quit to menu " << (char )186 << "1: # 1: " << endl <<
"'S' = Save map " << (char )186 << "2: . 2: " << endl <<
"'L' = Load map " << (char )186 << "3: + 3: " << endl <<
"'C' = Change color " << (char )186 << "4: ( 4: " << endl <<
"'t' = Change tile " << (char )186 << "5: ) 5: " << endl <<
"'a' = Apply tile " << (char )186 << "6: 6: " << endl <<
"'H' = Change tile hotkeys " << (char )186 << "7: 7: " << endl <<
"'L' = Load map " << (char )186 << "8: 8: " << endl <<
"'C' = Change color " << (char )186 << "9: 9: " << endl <<
"'L' = Load map " << (char )186 << "Cursor Position: / " << endl;
for (int X = 0; X < 79; X++)
{
cout << (char )205;
if (X == 37)
{
cout << (char )202;
}
}
CPOS.X = GridX;
CPOS.Y = GridY;
SetConsoleCursorPosition(hPos, CPOS);
while (rLoop == true )
{
CCMD = getch();
switch (CCMD)
{
case '8' :
GridY--;
break ;
case '2' :
if (GridY < 44)
{
GridY++;
}
break ;
case '4' :
GridX--;
break ;
case '6' :
GridX++;
break ;
case 't' :
CCMD = getch();
if (CCMD > 1 && CCMD < 10)
{
cTHKey = CCMD;
}
break ;
case 'a' :
MMAP[GridX][GridY] = THKey[cTHKey];
cout << THKey[cTHKey];
break ;
}
CPOS.X = GridX;
CPOS.Y = GridY;
SetConsoleCursorPosition(hPos, CPOS);
}
}
This is the problem line:
1 2 3 4 5
CCMD = getch();
if (CCMD > 1 && CCMD < 10)
{
cTHKey = CCMD;
}
Basically you should put a key 1 - 9, and it SHOULD make cTHKey equal that. But if i do it, it doesnt change it, and keeps placing '#'s when I click a... And I always press t, 3, and when I make it show what I pressed under the if, it still says EXACTLY what I pressed... Help?
Last edited on Aug 8, 2010 at 2:16am UTC
Aug 8, 2010 at 2:46am UTC
1 2 3 4 5 6 7 8 9
//...
case 't' :
CCMD = getch();
if (CCMD >= '1' && CCMD <= '9' )
{
cTHKey = CCMD-'0' ;
}
break ;
//...
;)
Last edited on Aug 8, 2010 at 2:47am UTC
Aug 8, 2010 at 2:52am UTC
Huh never though of that one... I do stuff like that all the time. Damn thanks saves me some time, I was trying like THKey((char)cTHKey) and everything like that.
Last edited on Aug 8, 2010 at 2:53am UTC