Jump to content
IGNORED

Collision detection in Inty Basic


Recommended Posts

I'm a novice/hobbyist programmer and nearly lifelong Intellivison fan.  Lately I've been having fun making graphics and animations with Inty Basic.  

Right now I'm trying to make collision detection work, but I'm not having any success.  My program consists of an animated helicopter and a fuel tank at which moves across the bottom of the screen, like in Super Cobra.  The helicopter is 16-pixesl wide.  The right half of it is SPRITE 0.  The left half is SPRITE 1.  The fuel tank is also made up of 2 sprites, SPRITE 2 and SPRITE 3.

Here is my code which is supposed to detect a collision between the helicopter and the fuel tank:

 

IF COL0 AND HIT_SPRITE2 THEN 
        PRINT AT 0 COLOR 2, "COLLISION!"
        WAIT
        x=10
        y=10
END IF

 

Can anyone tell if it's incorrect? I looked at examples in Oscar's book and demos from the Inty Basic collection but can't figure out what's wrong with mine.  All I want it to do is let me know when a collision occurs.  Once I get it working, then I'll draw an explosion or something.

I can post my entire code if necessary.  

Thanks.

Bill

Link to comment
Share on other sites

Hi, Bill,

 

Welcome to the forum!  A couple of things to check that could affect collisions:

  • The COLx variables will only be set on the next frame after moving the sprites, so you should test them after a WAIT statement, or close to it.
  • You need to make sure that your sprites have the "interaction" flag set.  This is bit 8 ($0100) on the X register, or using the HIT constant from the "Constants.bas" file.

Let me know if any of that helps.  If not, we'll dig deeper.

 

    Cheers!

    -dZ.

  • Like 1
Link to comment
Share on other sites

Thanks a lot for the suggestions.  Once I put in the HIT constant, it worked.  I encountered a few other problems, but by looking at the "game2" demo from Inty Basic, and at other topics in this forum, I was able to make progress.

 

Bill

 

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...