ID:1695463
 
Keywords: collision, detection
(See the best response by Pokemonred200.)
Hi guys,

I have just come back to this site after 6 years and am amazed to see how things have changed.

I always thought the tile based system of movement and collisions was always going to be a thing BYOND game developers had to work around as I believed it was a fundamental part of how Dream Maker operated.

But after a few minutes of trying to relearn how to code here I find that pixel based movement appears to be the built in norm nowadays. This is amazing but now I wonder how collisions are done if a tile system is no longer the way mobs relate to the world anymore.

So my questions are;
1) Are collisions now done using a non tile based method?

2) If yes, does this mean that mobs no longer have to be the same size as a tile in regards to hit detection?
Best response
When two mobs overlap, Cross() is called, and if the overlap succeeds, Crossed() is called, so these may be used for pixel movement collisons.. The bounding box of obj/mob can be set using bound_x, bound_y, bound_width, and bound_height, so mobs don't need to be the same size as a tile for hit detection.

The bounding box for collisions can be set as follows:

bound_x = 8 // 8 pixels of empty space to the left of the icon
bound_y = 8 // 8 pixels of empty space above the icon
bound_width = 16 // Icon is 16 pixels wide
bound_height = 16 // Icon is 16 pixels high


And Pixel-Based collision is as easy as:

mob/Crossed(atom/movable/O)
if(ismob(O))
O << "You collided with [src]!"


When two mobs no longer overlap, Uncross() is called, following which Uncrossed() is called if the end of collision succeeds.

mob/Uncrossed(atom/movable/O)
if(ismob(O))
O << "You have backed away from [src]"
Thank you so much for the reply, your explanation is really helpful. It's so cool that BYOND can do that these days and opens up all kinds of possibilities.
I think the original announcement (as well as the DM Reference) has plenty of information about this.

http://www.byond.com/forum/?post=117967
Thank you for the link. I am very appreciative of the help!