One hell of a stumper 
Author Message
 One hell of a stumper

Quote:

> Lately I have been having a problem with a game in development.
> The game only has simple blocks for it's graphics but the
> nitty-gritty stuff is almost done. However I can't figure out
> how to recognize which tank  the bullet is hitting.
> Since for PUT you only specify one pixel, the bullet would have
> to hit that spot for the hit to register. Does anyone have any
> ideas? I am rather stumped.

-----------------------------------------------------------------
The concept you're searching for is sometimes refered to as
collision detection.  There are a number of ways of handling it
and it can get complicated, depending on how you've coded your
graphics.

Take a simple case where you want to know if you've "hit" a
rectangular shape.  "PUT" takes only one set of coordinates, but
the first two elements of the array (as specified by the indices
parameter) can be used to calculate the width and length of the
rectangular block of pixels being placed on the screen.  The
coordinates specified are merely the upper left corner of that
block.

Say that the "bullet"'s position is Bx,By and the rectangular
block has opposing corners of X,Y and X+Width,Y+Length.  You
know you've hit the block if Bx>=X AND Bx<=X+Width AND By>=Y AND
By<=Y+Length.  This assumes a coordinate system that increases
from left to right and from top to bottom.

I don't know if this applies to your program, because I'm not
going to go to the trouble of downloading and decoding it this
time. Just a personal opinion, but I think most people would
prefer you save your code in ASCII format and post that rather
than using the "tokenized" format and UUEncoding.
----------------------------------------------------------------
Derek Asari



Tue, 05 Dec 2000 03:00:00 GMT  
 One hell of a stumper

MK>Since for PUT you only specify one pixel, the bullet would have to hit that
MK>spot for the hit to register. Does anyone have any ideas? I am rather
MK>stumped.

   If the target and background are of different colors you might be able
   to use the POINT(x,y) function to determine the screen color of what
   the missile hit and if the color is the same as the target you'll know
   you got a direct hit... Hope that helps. Good luck!

- Robert Fortune

 * OLX 2.1 TD * All hope abandon, ye who enter messages here.



Tue, 05 Dec 2000 03:00:00 GMT  
 One hell of a stumper



Quote:
>Hi,
>    Lately I have been having a problem with a game in development. The game
>only has simple blocks for it's graphics but the nitty-gritty stuff is
>almost done. However I can't figure out how to recognize which tank  the
>bullet is hitting.

>Since for PUT you only specify one pixel, the bullet would have to hit that
>spot for the hit to register. Does anyone have any ideas? I am rather
>stumped.

>PK

Why not use the "central pixel" as a startiing point and expand beyond
it?

PixelHit1=10 REMthis is the X pixel that defines the actual point.
PixelHit2=20 REM this is the Y pixel that defines the actual point.
REM Now, check to see if your'e close
If YourHitX >PixelHit1 -3 and YourHit<PixelHit1+3 then
  If YourHitY pPixelHit2 -3 and YourHit<PixelHit2+3 then
    Print "You hit the tank!"
  end if
end if

Remove NoSpam from my address to email me.


Art



Wed, 06 Dec 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ONE HELL OF A PROBLEM !

2. Class module Question-Stumper

3. STUMPER 2 of 2

4. STUMPER 1 of 2

5. Delegate stumper -- Please Help!

6. stumper

7. ADO stumper

8. A few more stumpers for you experts

9. I have two stumpers for any of you experts out there

10. A few stumper questions

11. printing from vbscript in ie30 stumper

12. I have two stumpers for any of you experts out there

 

 
Powered by phpBB® Forum Software