Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Mouse trouble DBP

Author
Message
Random Man A
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location:
Posted: 2nd Mar 2007 01:26
I am at my wits' end. I've tried everything I can think of, I've read tutorials, and I'm getting absolutely nowhere.

My game is a trivia game of sorts. Players have 3 minutes to answer twenty questions correctly. The trick is, the answers are on a board of 49 possible answers. The idea was that they'd find the answer, click the number of the answer, and the game would tell them if they're right or wrong.

Problem is, the game apparently has no idea where the mouse is. The game knows that the mouse has been clicked, I double-checked that, and I'm good there, but the game doesn't know where.

Here's the code I'm using, starting from recognizing the click.



Then, at Answered...



And so on, ad nauseam. I have it set up so the game SHOULD check first which column the player clicked in, and then determine specifically which answer. But when I add a little text thing that says if the player clicked here, say so, nothing appears.

I tried just using individual buttons (if x and y and x and y) instead of going column, then row, but that didn't work. I read TDK Man's tutorial on mouse entry forward and backward, and his button program works just fine. Apparently I'm missing something, but at this point, I have absolutely no idea what it is.

Please help. I'm going to pull what little hair I have left right out of my head.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 2nd Mar 2007 02:54
How is the board drawn?

If it's a grid then you calculate the square clicked on from the mouse X and Y positions.

Essentially you take the mouse X position and subtract the X position of the top left corner of the grid. Divide this by the width of the button and you get the horizontal button position.

Next, you take the mouse Y position and subtract the Y position of the top left corner of the grid. Divide this by the height of the button and you get the vertical button position.

The vertical button position is multiplied by the number of buttons in a row and finally the horizontal button position is added.

On a 10x10 grid of buttons this returns 0 to 99 so if you want the first button to be number 1, you add 1 in the final calculation.



You can use the same method with buttons as long as they are pretty closely grouped and they are arranged in a rectangular pattern. You just need to know the top left X and Y position that the buttons start, the number of columns and rows, as well as the button's width and height.

TDK_Man

Random Man A
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location:
Posted: 2nd Mar 2007 04:29
And now I'm more confused than when I posted.

No, the buttons are NOT in a grid. Here's how they're set up.



Players will need to be able to click all of the blue number buttons, as well as the black BAIL-OUT button, and the green PASS and PITSTOP areas.

So, let me see if I got some of it. Is part of what you're saying that before I can get the program to read mouse x and y, I need to tell the program where x and y can be? I had assumed that it would just take the x and y from the available area onscreen(in this case 800x600), but are you saying that's not the case?

Aaron
Random Man A
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location:
Posted: 2nd Mar 2007 11:33
I just had a thought pop at me from out of nowhere. That image above is a 2D image background for the game, and it's a .jpg I built in Paint, not drawn in-program. Could that have anything to do with it? Like the mouse is on the wrong layer or something? And if it is, is there some way around it? (I REALLY don't want to contemplate programming drawing that)

Because aside from that, I'm completely stumped. If anyone can help it would be greatly appreciated.

Aaron
Random Man A
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location:
Posted: 8th Mar 2007 11:41
Ever find that the answer is so stupid, you want to smack yourself upside the head again and again?

I went over the code again and again and again. I even went so far as to have the game draw all graphics, instead of loading pictures, and still nothing. Finally, out of desperation, I uninstalled and reinstalled DBP.

I was about ready to throw in some serious towel when someone at work said the word 'direct'. A light went off in my brain, and I re-installed DirectX. Only now, it included a "Runtime Optional Package". I went ahead and installed it, and BINGO! The mouse works!

My joy was short-lived, as I realized this is probably the first thing I should've done after a recent upgrade. Thanks for trying to help anyway, TDK.

Aaron

Login to post a reply

Server time is: 2024-11-12 16:34:03
Your offset time is: 2024-11-12 16:34:03