Sign in to follow this  
boshkodj

SDL Whats wrong with this function?

Recommended Posts

boshkodj    100
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..

Share this post


Link to post
Share on other sites
rip-off    10976
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?

Share this post


Link to post
Share on other sites
Ectara    3097
Might be completely irrelevant, but your function name is Right_Press, yet it checks for a left mouse button press. Did you intend this?

Share this post


Link to post
Share on other sites
boshkodj    100
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... :)

Share this post


Link to post
Share on other sites
jyk    2094
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?

Share this post


Link to post
Share on other sites
rip-off    10976
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?

Share this post


Link to post
Share on other sites
Ezbez    1164
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?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this