Go Back   RunUO - Ultima Online Emulation > Developer's Corner > Programming > XNA

XNA Tutorials and support for game development using Microsoft's XNA Game Studio framework.

Reply
 
Thread Tools Display Modes
Old 12-09-2007, 06:01 PM   #1 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,148
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default XNA Window

I have an XNA Game Window loaded into a Windows Form and would like to know how I can create some sort of...mouse bounds?

right now, when i check for mouse coordinates it checks the entire form, but i only want it to check when on the xna window and only in the xna window. how do i accomplish this?
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline   Reply With Quote
Old 12-10-2007, 11:44 AM   #2 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,760
Default

Quote:
Originally Posted by Storm33229 View Post
I have an XNA Game Window loaded into a Windows Form and would like to know how I can create some sort of...mouse bounds?

right now, when i check for mouse coordinates it checks the entire form, but i only want it to check when on the xna window and only in the xna window. how do i accomplish this?
depends on your code. But you should be able to do something like

Code:
if(mouseState.X > 0 && mouseState.Y > 0 && 
    mouseState.X < GraphicsDevice.PresentationParameters.BackBufferWidth &&
    mouseState.Y < GraphicsDevice.PresentationParameters.BackBufferHeight)
{
    //Mouse is inside the game window.
}
This is of course for checking inside the game, if you are checking from inside the windows form, thats another story. That would require more work and we would need to see code.
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Old 12-10-2007, 12:06 PM   #3 (permalink)
Forum Expert
 
Join Date: Jul 2003
Location: Arizona
Age: 18
Posts: 3,148
Send a message via AIM to Storm33229 Send a message via Yahoo to Storm33229
Default

Well we have an XNA Graphical Device window inside a windows form, but a game class is never actually defined. We have a class that calls IServices, IGraphicalDevice something-or-another. I don't have the code in front of me right now. I was thinking to myself last night though, I should make it a game window. Apparently I may have been right.

We also need to check the X,Y of the mouse so that we can keep the 48x48 tile attached to the exact mouse location; right now its got a weird offset. Ideas?
__________________
Quote:
Originally Posted by Radwen
You should crush your pills and sniff them.
Storm33229 is offline   Reply With Quote
Old 12-10-2007, 03:16 PM   #4 (permalink)
ConnectUO Creator
 
Jeff's Avatar
 
Join Date: Jan 2004
Location: In your mom
Age: 27
Posts: 4,760
Default

Quote:
Originally Posted by Storm33229 View Post
Well we have an XNA Graphical Device window inside a windows form, but a game class is never actually defined. We have a class that calls IServices, IGraphicalDevice something-or-another. I don't have the code in front of me right now. I was thinking to myself last night though, I should make it a game window. Apparently I may have been right.

We also need to check the X,Y of the mouse so that we can keep the 48x48 tile attached to the exact mouse location; right now its got a weird offset. Ideas?
All this stuff needs to be done inside the game, not the windows form. You need to check the x,y of the mouse per frame.

Code:
MouseState mouseState = Mouse.GetState();
int x = mouseState.X;
int y = mouseState.Y;
its that simple.
__________________
Jeff Boulanger
ConnectUO - Core Developer

Want to help make ConnectUO better? Click here to submit your ideas/requests
Use your talent to compete against other community members in RunUO hosted coding competitions

If you know XNA (even if its just a little) or are a good artist(2d or 3d) and are interested in making games for a hobby send me a pm or drop by #xna in irc.runuo.com. I'm looking to put together a small game development team.


Please do not pm me for support. If you are having issues please post in the appropriate forum. Thanks for your continued support of both ConnectUO and RunUO
Jeff is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5