[A83] Re: hitdetection
[Prev][Next][Index][Thread]
[A83] Re: hitdetection
At 04:38 PM 4/21/01 +0200, you wrote:
>I'm working on a hitdetection-routine for a ball-game. The balls that are
>moving around the field have an equation (y(x)=3Dax+b) (i use left-bottom=
as
>(0,0) and work with pixels (so x from 0 to 95 and y from 0 to 64) and every
>frame I increase 'x' 1 or more times.
>Now hitdetection would work this way: i check if d(m1,m2)=3Dr=B2 (m1:=
centre of
>the ball that is moving, m2: centre of ball i want to check (if hit) and r:
>the radius of the ball)
>Now my question is: should i work with OP1-OP6 ('cause i know they are
>easily to work with (for multiplying, square root,...)) or should i work
>with the usual registers: af, bc, de and hl ('cause my coordinates have to
>be integers in the end)
>Another problem would be that the balls aren't really circles, they're
>sprites that look like circles...
>
>Ball:
> .db %01110000
> .db %11111000
> .db %11111000 :=3D> third number of this row would=
be
>the centre
> .db %11111000
> .db %01110000
> .db %00000000
> .db %00000000
> .db %00000000
dont use OP1-OP6. They are way too slow, so there is no way you could=20
check every frame, especially moving the balls 1 or 2 pixels per=20
frame. crashman has some really good math routines you should take a look=
=20
at (specifically a division and multiplication routine for 8 bit=20
numbers). something else you might want to look at is approximating your=20
algorithms. They balls might not exhibit as fluid of motion, but they=20
would move much faster, resulting in a more challenging game.
-harper
References: