Jump to content

dx collisions


Wisin

Recommended Posts

But Orange, there are no functions for that. So he will have to do calculations with the positions + size, and when the second dx position is less then the previous result, they will collide. Eg:

dx1 starts at x=40, and is 60 wide. dx2 starts at 90. 40+60=100, so dx2 will collide. But what if dx2 starts at x=10? Then do it vice versa; dx2 will be calculated as dx1.

Link to comment

should work, didn't test it tough.

  
function doesCollide(x1,y1,v1,h1,x2,y2,v2,h2) 
  local horizontal=(x1)~=(x1+v1) or (x1>x2)~=(x1>x2+v2) 
  local vertical=(y1)~=(y1+h1) or (y1>y2)~=(y1>y2+h2) 
  return (horizontal and vertical) 
end 
  

Link to comment
Thanks karlis, but im not sure of how to use your function, i want to check when my character (a dx image) collides with a enemie (another dx image) and then do something (thats for later).

np

first 2args is x and y cord of 1st element, then its width, then height, then same 4 for second.

returns true/false

however you should test it fully as well, i cant gurantee itll work.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...