Sign in to follow this  
EvanClark

BlitzMax Collision Barrier

Recommended Posts

Kaptein    2224
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

Share this post


Link to post
Share on other sites
BeerNutts    4400
[quote name='EvanClark' timestamp='1348484748' post='4983176']
Hello could someone send me a piece of code that when an image collides with another it stops moving
[/quote]

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

[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;
{
[/code]

Share this post


Link to post
Share on other sites

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

Sign in to follow this