B
Brian
Greetings all,
I wrote a message regarding hit-lines here a couple of days back
saying:
"Anyone got links to some examples of using Region and/or
Region.Intersect in a graphical / gaming enviroment?
Am investigating into using it for hit-lines in my game."
I apologise for not writing this after the message but i didn't think
a message a few days old would be noticed with a new reply.
I got a reply from Dmitriy Lapshin:
"If your game is 2D, or at least you hit-test 2D projections, you can
create
regions for two entities you are going to check for a collision and
then
intersect these regions. Then check whether the resultant region is
non-empty and if it is, you've got the collision, otherwise there was
no
collision."
Some great advice here from Dmitriy.
Some brief questions though.. my hit-lines are a series of graphical
lines. I add these lines (AddLine()) to a GraphicsPath object and i
then make this a region. Is this correct so far? Should i use the
CloseFigure() method or anything? I then my convert to a rectangle and
intersect the region and rectangle. Does this seem plausible?
Also, my puck is constantly moving over the table but i want to check
if the puck has moved outside it. This is proving quite the
difficulty... anyone got any suggestions how exactly to draw and
intersect the region in this situation?
Many apologies for not replying this to my original post, but i've
been stuck in a rut with these hit-lines for a couple of weeks now.
Brian
I wrote a message regarding hit-lines here a couple of days back
saying:
"Anyone got links to some examples of using Region and/or
Region.Intersect in a graphical / gaming enviroment?
Am investigating into using it for hit-lines in my game."
I apologise for not writing this after the message but i didn't think
a message a few days old would be noticed with a new reply.
I got a reply from Dmitriy Lapshin:
"If your game is 2D, or at least you hit-test 2D projections, you can
create
regions for two entities you are going to check for a collision and
then
intersect these regions. Then check whether the resultant region is
non-empty and if it is, you've got the collision, otherwise there was
no
collision."
Some great advice here from Dmitriy.
Some brief questions though.. my hit-lines are a series of graphical
lines. I add these lines (AddLine()) to a GraphicsPath object and i
then make this a region. Is this correct so far? Should i use the
CloseFigure() method or anything? I then my convert to a rectangle and
intersect the region and rectangle. Does this seem plausible?
Also, my puck is constantly moving over the table but i want to check
if the puck has moved outside it. This is proving quite the
difficulty... anyone got any suggestions how exactly to draw and
intersect the region in this situation?
Many apologies for not replying this to my original post, but i've
been stuck in a rut with these hit-lines for a couple of weeks now.
Brian