Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A brief example of collision detection written in the script-8 game engine.
//Checks if the entity collides with the other entity, using a rectangle based hitbox setup.
//Determine if the x and y coordinate of the element (top left corner) is within the other element's rectangle (x to x + width and y to y + height).
function isCollide(entity, other) {
if(other.x >= entity.x && other.x <= (entity.x + entity.width) && other.y >= entity.y && other.y <= (entity.y + entity.height)) {
return true
} else {
return false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment