OK looks a bit better now - though still some issues:
You still have the goto loop - it looks like never ending. Use a while loop with some condition to end.
Goto's are really really bad - don't use them ever!!
Indentation - still is a 8 chars. The code is 2 screens wide on my system. There is a sort of rule that says code shouldn't be more than 80 chars per line, this is so it fits in one screen, and can be printed easily. It is possible to "fold" you lines of code, just press enter and continue on the next line - doesn't make any difference to the compiler.
This is at least unnecessary:
1 2 3
|
void Myunction() {
return;
}
|
void means that the function doesn't return anything, so putting a return statement is meaningless.
You still have lots of global variables, I know it seems easier to do it this way, but it is bad form and can lead to all kinds of problems. At least put them in main, and send whichever ones are necessary to the functions. If you need to change the value of some of them, send a pointer or reference to the function, change the value in the function, the changed value of the variable will still be there in main().
With the if statements - if (conditional) expression. Put the expression part on it's own line.
These if statements could still be put into functions. The functions would be short (2 or 3 lines, if you fold them), but it will make the code easier to read.
With variables, it's a good idea to initialise them to something (even 0) when you declare them - it will save you one day. Uninitialised variables are one of the biggest source of errors. Your variables are OK, this is just a handy hint for the future.
Could tedit be a bool type?
Could all this code in main be in a switch statement? I am guessing you don't need to test each one, just select one value of k
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
|
if(k==100)
posx=posx+1;
if(k==97)
if(posx>0)
posx=posx-1;
if(k==115)
posy=posy+1;
if(k==119)
if(posy>0)
posy=posy-1;
if(k==101) {
w[((www+posx)-(www/2))][((wwh+posy)-(wwh/2))]=250;
updatewires();
}
if(k==113) {
w[((www+posx)-(www/2))][((wwh+posy)-(wwh/2))]=0;
updatewires();
}
if(k==102)
updatewires(); //do you need baces here?
drawworld();
|
Here is what the switch could look like;
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
switch (k ) {
case 100:
posx=posx+1;
break;
case 97:
if(posx>0)
posx=posx-1;
break;
//etc
//etc
default:
//error processing here
}
|
Hope this helps