Hello all,
Quick question!
How would i keep a point inside a region? For example, the mouse pointer.
You should be able to move the mouse around in this region but not anywhere
outside it.
How would i go about doing this?
Thanks in advance,
Brian 4 4590
Do a test move that creates a point from the current point and the new
delta. If its inside the region, you check this ising Region.IsVisibl e, make
the move permanent. If not, discard it.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@p lease.com> wrote in message
news:OS******** ******@TK2MSFTN GP15.phx.gbl... Hello all,
Quick question!
How would i keep a point inside a region? For example, the mouse pointer. You should be able to move the mouse around in this region but not anywhere outside it.
How would i go about doing this?
Thanks in advance,
Brian
Cheers Bob.. but that was probably a bad example as i've implemented it
using the mouse position myself but it's not really ideal as what i want to
do is ensure the position of a paddle is inside of a player's region.
Since the mouse controls the paddle.. i assumed simply using the mouse
positions with Region.IsVisibl e would work. But if you move the mouse
quickly outside of the region, it won't redraw it where it should (at the
edge of the region).. it'll simply freeze at the last place it was drawn.
I should really be using the X and Y position of the paddle but that does
not seem to work.. as the paddle will stick as soon as it goes outside of
the region, with no way to move it back inside the region (as it's already
outside, you're disregarding any movement it's attempting).
Quite difficult to word there.. and probably more difficult to understand.
The code i was using for the mouse position was:
Point paddle1Position = new Point(e.X, e.Y);
bool isVisibleInP1Re g = player1Rgn.IsVi sible(paddle1Po sition);
if(isVisibleInP 1Reg == true)
{
paddle1_x = e.X;
paddle1_y = e.Y;
}
else
{
//do nothing
}
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:eQ******** ******@TK2MSFTN GP14.phx.gbl... Do a test move that creates a point from the current point and the new delta. If its inside the region, you check this ising Region.IsVisibl e, make the move permanent. If not, discard it.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@p lease.com> wrote in message news:OS******** ******@TK2MSFTN GP15.phx.gbl... Hello all,
Quick question!
How would i keep a point inside a region? For example, the mouse pointer. You should be able to move the mouse around in this region but not anywhere outside it.
How would i go about doing this?
Thanks in advance,
Brian
The game needs to capture the mouse and also probably get the current mouse
position and extrapolate a line from the last position to the current one to
see if it exits the region. Bresenhams line algorithm will give you all the
points between two coordinates.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@p lease.com> wrote in message
news:eC******** ******@tk2msftn gp13.phx.gbl... Cheers Bob.. but that was probably a bad example as i've implemented it using the mouse position myself but it's not really ideal as what i want to do is ensure the position of a paddle is inside of a player's region.
Since the mouse controls the paddle.. i assumed simply using the mouse positions with Region.IsVisibl e would work. But if you move the mouse quickly outside of the region, it won't redraw it where it should (at the edge of the region).. it'll simply freeze at the last place it was drawn.
I should really be using the X and Y position of the paddle but that does not seem to work.. as the paddle will stick as soon as it goes outside of the region, with no way to move it back inside the region (as it's already outside, you're disregarding any movement it's attempting).
Quite difficult to word there.. and probably more difficult to understand.
The code i was using for the mouse position was:
Point paddle1Position = new Point(e.X, e.Y); bool isVisibleInP1Re g = player1Rgn.IsVi sible(paddle1Po sition);
if(isVisibleInP 1Reg == true) { paddle1_x = e.X; paddle1_y = e.Y; } else { //do nothing } "Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message news:eQ******** ******@TK2MSFTN GP14.phx.gbl... Do a test move that creates a point from the current point and the new delta. If its inside the region, you check this ising Region.IsVisibl e, make the move permanent. If not, discard it.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@p lease.com> wrote in message news:OS******** ******@TK2MSFTN GP15.phx.gbl... Hello all,
Quick question!
How would i keep a point inside a region? For example, the mouse pointer. You should be able to move the mouse around in this region but not anywhere outside it.
How would i go about doing this?
Thanks in advance,
Brian
Bob,
Cheers for the info.
Read up on that Bresenham's Line Algorithm.. seems a bit too complicated for
me, especially at this time of night.
Will come back to that problem in a couple of days.
Thanks again!
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:eP******** ******@TK2MSFTN GP10.phx.gbl... The game needs to capture the mouse and also probably get the current mouse position and extrapolate a line from the last position to the current one to see if it exits the region. Bresenhams line algorithm will give you all the points between two coordinates.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@p lease.com> wrote in message news:eC******** ******@tk2msftn gp13.phx.gbl... Cheers Bob.. but that was probably a bad example as i've implemented it using the mouse position myself but it's not really ideal as what i want to do is ensure the position of a paddle is inside of a player's region.
Since the mouse controls the paddle.. i assumed simply using the mouse positions with Region.IsVisibl e would work. But if you move the mouse quickly outside of the region, it won't redraw it where it should (at the edge of the region).. it'll simply freeze at the last place it was drawn.
I should really be using the X and Y position of the paddle but that does not seem to work.. as the paddle will stick as soon as it goes outside of the region, with no way to move it back inside the region (as it's already outside, you're disregarding any movement it's attempting).
Quite difficult to word there.. and probably more difficult to understand.
The code i was using for the mouse position was:
Point paddle1Position = new Point(e.X, e.Y); bool isVisibleInP1Re g = player1Rgn.IsVi sible(paddle1Po sition);
if(isVisibleInP 1Reg == true) { paddle1_x = e.X; paddle1_y = e.Y; } else { //do nothing } "Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message news:eQ******** ******@TK2MSFTN GP14.phx.gbl... Do a test move that creates a point from the current point and the new delta. If its inside the region, you check this ising Region.IsVisibl e, make the move permanent. If not, discard it.
-- Bob Powell [MVP] Visual C#, System.Drawing
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Brian Basquille" <re**********@p lease.com> wrote in message news:OS******** ******@TK2MSFTN GP15.phx.gbl... Hello all,
Quick question!
How would i keep a point inside a region? For example, the mouse pointer. You should be able to move the mouse around in this region but not anywhere outside it.
How would i go about doing this?
Thanks in advance,
Brian
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Kai Grossjohann |
last post by:
I have a table which contains a top-aligned table cell:
....
<tr style="height:40">
...
<td colspan="1" rowspan="2" align="left" valign="top"
style="overflow:hidden;">
...contents.explained.later...
</td>
...
|
by: Skybuck Flying |
last post by:
Hi,
I needed a method to determine if a point was on a line segment in 2D. So I
googled for some help and so far I have evaluated two methods.
The first method was only a formula, the second method was a piece of C code
which turned out to be incorrect and incomplete but by modifieing it would
still be usuable.
The first method was this piece of text:
|
by: Niels Jensen |
last post by:
I have been developing a little project which draw's a hexgrid on a panel
within a form similar to this - it:s used as a client from a e-mail based
strategy game:
____ ____
/ \ / \
/ (0,0) \____/ (2,0) \____/
\ / \ / \
\____/(1,1) \____/ (3,1) \_
/ \ / \
/ (0,1) \____/ (2,1) \____/
|
by: Trammel |
last post by:
Hi. I have been trying to make a simple application that will sit in the
background and alert me of any changes in window focus (IE: Pop-up windows)
on my system.
I have used DirectTextToSpeech from Microsoft and tried the following
code...
The problem I am having is that it detects its own caption fine... but no
captions of other windows :¬/
Could someone please have a look at the following code and lemme know what
|
by: mrkbrndck |
last post by:
Please see the code below as I am trying to use multithreading for copying
files to a new location in a way that improves performance of the client
windows application.
The problem occurs when 2 or more threads are created, the ImportOneFile
method attempts to add a previously added file. If I allow 4 maximum threads
and process 4 files, the last file is attempted 4 times and none of the other
files are added to the destination. If I...
| |
by: Peter Proost |
last post by:
Hi group,
I've got this bit of code (see below) which draws a basketball field in a
picturebox (width:198, height:368)
but now I was wondering what would be the easiest way to check inside the
picturebox mouseup event if I clicked inside or outside the 3point area,
because the 3point area isn't a real cirkle
Any hints or tips are welcome.
|
by: sternr |
last post by:
Hey,
I use the form's graphics object to draw points at random places on the
form.
After drawing the points, how can I know if a certain point on the form
is colored?
Thanks ahead
--sternr
|
by: uncensored |
last post by:
Hello everyone,
I'm fairly new at .Net and I have a repeater inside a repeater problem. I will attach my code to this message but basically what I am able to tell when I run my page it tells me that my second repeater has the following error, System.NullReferenceException: Object reference not set to an instance of an object.
When I put a watch on I can see my second repeater is not being created because it is equal to "Nothing". I can...
|
by: renu |
last post by:
Hello,
I have drawn polygon on window. And I want to check wheather given
point is in that polygon region or not? How shold I find that? I have
created object of class region
GraphicsPath path = new GraphicsPath();
path.AddPolygon(pts); //////// Some points I have passed
Region rgn = new Region(path);
RegionData rgnDta = rgn.GetRegionData();
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |