Im sad someone debug for me. its simple code.

Started by
8 comments, last by Ic3man 18 years, 7 months ago
basically i have a grid.. that when you click on the colours change right. now for some reason no matter how i loop it, it screws around. Can someone please help me.. im a glut newbie. See i have the bottom buttons running well changing variables. and the color variables pass etc. cos i have debugged for like 5 hours now and can't get anywhere. YES i know my code is messy. The idea is to get a 29x29 graph. made out of squares.. when you click on them it changes just that one 1x1 box. colour thats it. I need to implement more functions but this is the main one. http://carld.sytes.net/game.cpp thanks..
Advertisement
comon 35 views.. and not a single answer.
Any comments.
any ideas.
would be good.
I don't quite understand the 0.1f if i use the other way instead of my pixel per pixel way.

Basically all my code is for loops.
something that creates the button.

the main areas would be the buttonchk. and the drawgraph. im assuming.
setthegraph() is the initialize for the graph which sets up all the variables
what i don't get if you click the main pixel it senses it and forwards the code.
sets the other variable to what it should be.. then the friggen perfect graph starts growing shit on the left and squares go missing.

HELLP
maybe you where destined for failure.
Matt : mattb0001@hotmail.comClick me please
I've only spent about 30 seconds looking at your code (it was all I could bear) but heres a couple of things:
GLint graph_one[29][20][2];int maxgraphx = 29;int maxgraphy = 29; //That doesn't make a lick of sense.for(int y=0; y<=maxgraphy; y++) //Normally people use <, not <=.

People weren't replying because your code makes them cringe.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
okay redone half of it.
code has been resaved in current location
the reason for maxgraphx and maxgraphy is so i can change the 3 variables on the fly. so if i want longer y or longer x then i just change the variables in that and the array. its purely in a test mode at the moment.

My coding has slowly started the cleaning up process.
I got rid of most of the commenting.. does it help..
AS for the for loops.. <= meh.. i will change it later.
thanks for the comments though..

Btw most of this stuff has been self taught.



Optimized most of the code. from my knowledge which is growing faster and faster.
Cleaned up the code.
and tested.. Program is still creating problems.
and not working the way i want it to.
Quote:Original post by Ic3man
...
AS for the for loops.. <= meh.. i will change it later.
...

But THAT IS your problem. At least one of them. To illustrate:
GLint graph_one[29][29][2];GLint graph_two[29][29][2];...int maxgraphx = 29;int maxgraphy = 29;...    for (int x=0; x<=maxgraphx; x++){	for (int y=0; y<=maxgraphx; y++){		if (startup==false){			graph_one[x][y][0] = startxpos*(x+1);...

Your loops run between 0 and 29, inclusive. At the last iteration, they try to access the element with index 29. Since we are counting from zero, this is actually the 30th element, which doesn't exist.
Jooleem. Get addicted.
I thought it should exist.. arrays start at 0
so looping starting at 0 should work too
i changed all my signs to < or > not => so hopefully this fixes some of the issues.
UPDATED
Yes, arrays start at 0. But they finish at length - 1. So for an array 28 long, the last index that doesn't screw up is 27. There are 28 different valid indices: 0, 1, ... 26, 27. So you check that i is smaller than 28, meaning it never actually is 28. And um. Why were you "optimising" if it doesn't even work? Cleaning up I can understand, but not optimising. I realise your self taught, but so am I. Make sure you have a good book, and that you take every little thing it says seriously.

EDIT: I just noticed:
GLint graph_one[29][29][2];
int maxgraphx = 30;
int maxgraphy = 30;

You fixed the problem, then compensated and broke it again. Nice.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
Thanks for the reply. I've actually totally changed the code again. Kinda works kinda doesn't.. works better than it did.
Thanks for everyones help though.
Now it can pick individual boxes :D

This topic is closed to new replies.

Advertisement