SDL Whats wrong with this function?

Started by
5 comments, last by Ezbez 14 years, 10 months ago
Hey,I am making Tic Tac Toe,and i create function "Right_Press". But,this function is not working,i dont know why? There arent any syntax error,but when I call this function,there is an error. Function : <code> #ifndef _MOUSE_H #define _MOUSE_H #include "SDL.h" #include "Event.h" bool Right_Press(int x,int y,int w,int h) { if(event.type == SDL_MOUSEBUTTONDOWN) { if(event.button.button == SDL_BUTTON_LEFT) { int X = event.button.x; int Y = event.button.y; if( ( X > x ) && ( X < x + w ) && ( Y > y ) && ( Y < y + h ) ) { return true; } } } return false; } #endif <code> Please help me..
Advertisement
Quote:
There arent any syntax error,but when I call this function,there is an error.

You have told us what the error isn't, but we still don't know what the error is. Can you describe what happens?
Might be completely irrelevant, but your function name is Right_Press, yet it checks for a left mouse button press. Did you intend this?
When I call this function,nothing happening. I have only Right_Press function. If you want,I can put all source code?
P.S. Sorry for gramatical errors,I am from Serbia... :)
A couple of tips/suggestions:

1. Use [source] tags when posting code.

2. Remove the leading underscores from your header guards (symbols beginning with an underscore followed by a capital letter are reserved by the implementation).

3. Saying that 'nothing happens' doesn't give us a lot to go on in terms of helping you diagnose the problem. Can you provide more detail?

4. Have you tried using the debugger and/or adding some debug output to your program?
Quote:
When I call this function,nothing happening.

What do you expect to happen when you call this function? All it does is return true or false. If you don't make use of this information that is returned to you then for all intents and purpose it does nothing.

Can you show us the calling code?
You must have more code than this. Your function references "event" which is not defined in the code you give us. Is "event" a global?

This topic is closed to new replies.

Advertisement