need help with game bug
May 5, 2013 at 9:08pm UTC
its really weird if you look in the code it should display a | in the corner of
the screen but it doesn't and if you move left twice (hit "a" then enter then repeat)it shows 2 of them one in a correct position one not if you go up from the spawn position (hit "w" then enter) it is in a correct position if you go over once it displays it in the correct position.
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
#include <iostream>
#include <string>
#include <stdlib.h>
#include <fstream>
using namespace std;
int main()
{
string command ;
string save;
//menu
menu:
cout << " say newgame to start or, load to load new game " << endl;
cin >> command;
if (command == "newgame" );
if (command == "load" ) goto load;
system("cls" );
//end
dstart:
//stats
int hp = 100;
int maxhp = 100;
int xp = 0;
//end
//spawn pos.
int x = 5;
int y = 5;
//end
//save
save:
//end
start:
//map
char world [10] [10] = {0};
world [6] [6] = '|' ;
if (x == 8) x = 3;
if (x == 2) x = 7;
if (y == 8) y = 3;
if (y == 2) y = 7;
//end
//avatar
world[x][y] = '@' ;
//end
//death
if (hp < 1)
{
cout << "you died" << endl << endl;
goto dstart;
}
//end
//graphics script
cout << world[x+2][y+1];
cout << world[x-1][y+1];
cout << world[x][y+1];
cout << world[x-1][y+1];
cout << world[x-2][y+1];
cout << endl;
cout << world[x+2][y];
cout << world[x+1][y];
cout << world[x][y];
cout << world[x-1][y];
cout << world[x-2][y];
cout << endl;
cout << world[x+2][y-1];
cout << world[x+1][y-1];
cout << world[x][y-1];
cout << world[x-1][y-1];
cout << world[x-2][y-1];
cout << endl <<endl;
cout << "Health:" << hp << endl << endl;
//end
//movement script
cin >> command;
cout << endl;
if (command == "w" && world[x][y+1] != '|' ) y = y + 1;
if (command == "s" && world[x][y-1] != '|' ) y = y - 1;
if (command == "d" && world[x-1][y] != '|' ) x = x - 1;
if (command == "a" && world[x+1][y] != '|' ) x = x + 1;
if (command == "save" ) goto save;
//end
system("cls" );
goto start;
load:
goto start;
return 0;
}
Topic archived. No new replies allowed.