XNA Hit "prediction" instead of "detection"?

  • (2 Pages)
  • +
  • 1
  • 2

21 Replies - 4842 Views - Last Post: 07 February 2013 - 07:39 AM

#16 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: XNA Hit "prediction" instead of "detection"?

Posted 28 January 2013 - 07:40 PM

Here's what I don't understand - why do you need to know all the pixel of the ball?

I guess what I was trying to highlight is with basic geometry you can calculate that with minimal set of tracked knowledge, right? You know the center and diameter you can use a basic math formula to get any point. There is no need to drag along a perpetually updating list of pixels.. that's wasted CPU and data storage.

Just think a bit more outside of the box. If you need some timer countdown from the ball hitting a block then just do the math. You have a velocity vector... draw that line out from the center of the ball until it intersects a brick. Drop lop off the radius and you have the distance.. a bit more math and you can factor in time to impact.

Again.. a list of every single pixel is not the way to go.
Was This Post Helpful? 0
  • +
  • -

#17 gummipalle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 23-January 13

Re: XNA Hit "prediction" instead of "detection"?

Posted 28 January 2013 - 07:49 PM

Ughhh.... Pasted code above looks bad on my screen at least, but I cant find an edit function?
Help me find it, and I'll make it look better... (It looks neater in my Visual-express editor.)
Also, cant see pictures without right-clicking on the text that says 'posted image', and selecting 'display image', which is not as cool as yours... Did my best...
Was This Post Helpful? 0
  • +
  • -

#18 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: XNA Hit "prediction" instead of "detection"?

Posted 28 January 2013 - 07:52 PM

Edit functions are enabled after a sufficient amount of posts.
Was This Post Helpful? 0
  • +
  • -

#19 gummipalle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 23-January 13

Re: XNA Hit "prediction" instead of "detection"?

Posted 28 January 2013 - 08:04 PM

Man you are fast!

ok, thought I initially needed all pixels simply to determine/test which of them are on the circumferance...
Then I'd throw the others away...

Quote

You know the center and diameter you can use a basic math formula to get any point.


I think thats what I might be looking for, all i have is this to test Yes/No against, for every pixel:

(x - x_0)^2 + (y - y_0)^2 = r^2\,

which is not yielding good results for me...

If you know the name of a formula, or can point me in its direction, I'll read up on that.

May be slow on my next post, trying to get what you are saying... I'm snow-blind from looking at my old code for so long...

Just remembered, I think my trouble may stem from coordinates on the cirle not exactly matching pixel-coordinates on the screen, if that makes sense...
Was This Post Helpful? 0
  • +
  • -

#20 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9287
  • View blog
  • Posts: 34,811
  • Joined: 12-June 08

Re: XNA Hit "prediction" instead of "detection"?

Posted 28 January 2013 - 08:08 PM

https://en.wikipedia...ircle#Equations
Was This Post Helpful? 0
  • +
  • -

#21 gummipalle  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 23-January 13

Re: XNA Hit "prediction" instead of "detection"?

Posted 28 January 2013 - 08:26 PM

Yeah, thats actually my source for what I had...
darn...

Well, these last couple of days I've been thinking of scrapping this stuff anyways,
burrying it, and starting from scratch... Re-think it... Just had so much time invested in it,
making it hard to let go...But seems I'm getting nowhere... So... Yeah...

Well thanks for your time and effort this time around... I'm off to meet square 1, an old friend from way back... :-)

cheers!
Was This Post Helpful? 0
  • +
  • -

#22 BBeck  Icon User is offline

  • Here to help.
  • member icon


Reputation: 580
  • View blog
  • Posts: 1,287
  • Joined: 24-April 12

Re: XNA Hit "prediction" instead of "detection"?

Posted 07 February 2013 - 07:39 AM

I thought I would add my two cents. I had a similar problem for 3D collisions with walls.

My solution was request permission to move in a certain direction by a certain distance, determine if the full movement is allowable, if not determine what the maximum move allowable is, then return the maximum move allowable - which may or may not be what was requested. After that, the requestor knows exactly how far it can move before the draw call without causing a collision.

I think in 3D XNA has a ray function that you can use to test intersections with planes and I used that to determine the distance to the wall.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2