BlitzMax Collision Barrier

Started by
2 comments, last by BeerNutts 11 years, 6 months ago
Hello could someone send me a piece of code that when an image collides with another it stops moving
Advertisement
bump
i think you will have to ask in the blitzmax forums, as your question may be too language specific :)
i don't know how many here at the forums know blitzmax, but i think seeking help in the official forums is your best bet for help

Hello could someone send me a piece of code that when an image collides with another it stops moving


How do you think something like this would work? Well, you need to know the height and width of the images. I assume Blitzmax can provide that information once you've loaded them. Then you need to know the locations of the images on the screen. You control that, so you know where they are. Then you simply check if the X, Y and Height, Width of Image 1 overlaps the X, Y, and Height, Width of image 2, like this (pseudo-code):


bool IsCollision(Image image1, Image image2)
{
if (image1.x + image1.width < image2.x ||
image1.x > image2.x + image2.width ||
image1.y + image1.height < image2.y ||
image1.y > image2.y + image2.height) {
return false;
}
return true;
{

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

This topic is closed to new replies.

Advertisement