Hail, Knight! (This needs to be the new greeting for us. Smile )

I'd like to know about vector mathematics from the ground up and how I would implement collision detection using the Separating Axis Theorum. In Lua is preferred but, in theory is cool too.

Thanks.

Reminder for Kerm to change my title from Power User to Phantom of Vandalia.
Well, there are some useful tutorials online. Do you have any questions specifically?
I'd like to know how to get the vectors or vertices from an image and check that image for collisions using the Separating Axis Theorum.
Raylin wrote:
vectors or vertices from an image

Sounds like a misapplication of SAT. Working from a raster image, you either need to treat it as a large poly with a vertex at each external pixel, or have a separate structure tracking its hitbox. Either way, it's pretty clunky.

The usual way to check collision between arbitrary sprites (which I assume is what you intend to do) is seeing if they overlap at all when drawn, AFAIK.
The Tari is correct regarding normal hit detection. You generally want to check for intersection with the less-numerous objects when drawing the more-numerous objects. For example, if you have tons of bullets, you can check for overlap with ships during the bullet rendering loop. Alternatively, you can do pixel-based detection: if any pixel inside your ship's sprite (or mask) is colored, you've been hit. If you want the most trivial way to check coordinate overlap (ASM?) here's an example from Doors CS:


Code:
;----------Hot spot detection-----------
;inputs: b,c (first x and y cor)
;        d,e (last x and y cor)
;        h,l (current x,y)
;output: "z" flag [either true (set) or false (reset)]

hdetect:
   ld a,h
   cp b
   jr c,hno_detect
   cp d
   jr nc,hno_detect
   ld a,l
   cp c
   jr c,hno_detect
   cp e
   jr nc,hno_detect
hyes_detect:
   xor a
   or a
   ret
hno_detect:
   xor a
   cp 1
   ret
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement