Jump to content

dx collisions


Wisin

Recommended Posts

Posted

Hi, i would like to know if theres a way to check if a dx image is collisioning with another dx element, example another image, thanks.

Posted

For that, everything has to be mixed in one resource. Create an object "dximage" or somewhat, and then in onClientRender, when rendering these, check if they collide and trigger an event if they do. That's all

Posted

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.

Posted

I've just written how to start :> Of course, calculations are needed, and dx objects are one of the most useful solutions right now.

Posted

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 
  

Posted

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).

Posted
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.

Posted

i have another question, is there a way to check if im over another DX element (a image)? im making platform mini game that requires this, if someone could tell me i would appreciate it.

Posted

Lol, offtopicers :P See The-kid's IWTG gamemode, that's a pretty nice 2d mode.

Wishin: when 'over'? You mean with your mouse? If so, let me make some simple functions which you can expand.

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...