|
Tool Tip crash |
Fire Wolf
Member #7,640
August 2006
|
When I move the mouse to the area for tool tip 1 the program crashes. Anyone know how to fix it?
|
X-G
Member #856
December 2000
|
i is going to be something wrong here, resulting in going out-of-bounds on the tooltip array: Quote:
tips[ i ].text, For that matter, why is i a global and not just a local thing inside the for loop? -- |
Fire Wolf
Member #7,640
August 2006
|
Im not the best programmer in the world so bare ith me. 'i' : undeclared identifier in the draw_function() if I only declare it in the logic_function() |
BAF
Member #2,981
December 2002
|
As far as I can see, i is never changed from it's initial value of 0, at least in that code snippet. |
X-G
Member #856
December 2000
|
I'm assuming logic_function is called now and then, which would screw with things eventually, I should think. Anyway, why are you even using i in that function when what you want to use is tooltip? -- |
BAF
Member #2,981
December 2002
|
Nevermind, I completely overlooked that for loop. But yeah, why is i global? And why is the variable to tell you what tooltip to draw global, instead of a class member? |
Fire Wolf
Member #7,640
August 2006
|
dont know how to do it any other way, I suck at programming I'm dumb!. Does it matter? |
X-G
Member #856
December 2000
|
Go back and learn the basics before trying to tackle this task. It's way above your head. Do something simpler first, like Hello World, and go from there. Preferably in a slightly more safe language like Python. -- |
Fire Wolf
Member #7,640
August 2006
|
Sorry X-G I'm doing c++ for my degree not python. Doing this is helping me alot. |
X-G
Member #856
December 2000
|
I'm being serious. You don't seem to grasp the basics of imperative programming. Without even that, dealing with the additional intricacies of a language like C++ is going to be outside of your league. You need to start at the bottom and work your way up, and Python is a good language for a beginner. I recommend you try that out. -- |
BAF
Member #2,981
December 2002
|
Quote: Sorry X-G I'm doing c++ for my degree not python. Doing this is helping me alot. How is this helping you? |
kazzmir
Member #1,786
December 2001
|
I don't think it was mentioned explicitly but all I think you need to do is change draw_function to this if ( tooltip >=0 ) { textout_ex( buffer, font, tips[ tooltip ].text, tips[ tooltip ].left, tips[ tooltip ].bottom, makecol(222, 100, 111), -1 );
|
X-G
Member #856
December 2000
|
Geez, kazzmir, that way he won't learn anything. And if he can't figure out that bit for himself, he really needs to start out with something simpler, as I said. -- |
Fire Wolf
Member #7,640
August 2006
|
Im doing it for fun as well X-G, dont be so serious Edit: Awesome kazzmir, thanks for the help. I can continue programming my game in C++ now. |
TeamTerradactyl
Member #7,733
September 2006
|
Fire, for the ToolTip struct, you declare char *text, and then later create two objects: the first contains the text, "Start new game" and the other contains NULL. If you change "Start new game" to NULL or even '\0', does it still crash? Just briefly looking at it would make me think that *text hasn't been given a specific size, and therefore, would SEGFAULT when you try to cram "Start new game" into it. Try changing it to NULL and see if it still crashes. If not, my theory is wrong, but nothing's really wasted but a few minutes of testing time
|
|