Jump to content
  • Advertisement
Sign in to follow this  
boshkodj

SDL Whats wrong with this function?

This topic is 3319 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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?

Share this post


Link to post
Share on other sites
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
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!