Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Javascript Is/If Collision Functions (My Functions)

function javascript

  • Please log in to reply
1 reply to this topic

#1 YoungPythoner

YoungPythoner

    CC Newcomer

  • Member
  • PipPip
  • 17 posts
  • Location:Turkey, Hatay
  • Programming Language:Python, Bash, Others
  • Learning:JavaScript, Delphi/Object Pascal

Posted 03 July 2015 - 07:29 PM

Hi! I wrote a is/if collision functions. They're for games and anything. They are includes:

Up, down, left, right collisions.

Hope you like it!

function IfCollisionDown(x1, y1, w1, h1, x2, y2, w2, h2)
{
if (x1>x2-(w2/2)&&x1<x2+(w2/2)&&y1-(h1/2)<y2+(h2*1.5)&&y1>y2)
{
return true
}
else
{
return false
}
}

function IfCollisionRight(x1, y1, w1, h1, x2, y2, w2, h2)
{
if (y1<y2+(h2/2)&&y1>y2-(h2/2)&&x1-(w1/2)<x2+w2&&x1>x2)
{
return true
}
else
{
return false
}
}

  • 0

#2 leon242

leon242

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 21 July 2016 - 09:49 AM

Excellent, I'll take it


  • 0





Also tagged with one or more of these keywords: function, javascript