Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 08:54 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMC2 Sprite collision

Author Message
Deadreddreadhead
Newbie

Joined: 07/02/2021
Location: United States
Posts: 7
Posted: 10:51pm 08 Feb 2021
Copy link to clipboard 
Print this post

Hello there. My name is Peter and I am new on here. I have a MMC2. I programed in basic years ago and am bit rusty but getting back into the swing of things and looking forward to making some retro games.

I am putting together a version of centipede as that was something I could program easily back then.

I am just starting to look into the collision detection.

I see 'SPRITE INTERRUPT collision' could be used to call a routine called 'collision' when a collision occurs but my question is this:

If I had 3 individual and independent missile sprites for sprites 3, 4 and 5 and then aliens on sprites 10-20 how would i detect which missile had hit which alien?

Thanks in advance for any help that can be given.

Peter.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 11:00pm 08 Feb 2021
Copy link to clipboard 
Print this post

Welcome to another Peter!

There are a whole bunch of sprite functions that can give you a glut of information, starting around page 114 of the manual. (CMM2 User Manual V5.06.00)

SPRITE(C,___), SPRITE(S) and SPRITE(T,___) all look especially useful.
.
Edited 2021-02-09 09:01 by vegipete
Visit Vegipete's *Mite Library for cool programs.
 
Deadreddreadhead
Newbie

Joined: 07/02/2021
Location: United States
Posts: 7
Posted: 03:24pm 09 Feb 2021
Copy link to clipboard 
Print this post

Hey there, also Peter! Thank you for your response!

I have Ver 5.05.05, I will have a look at the updated one you mention for enlightenment!

Towards the end of 'GRAPHICS Programming on the Colour MaxMite 2, Ver 2.0a, near the bottom of Page 40, is says that sprite collisions will be discussed in much more detail in the next post but I have not been able to find that post so far.

Thanks.

Peter.
 
mclout999
Guru

Joined: 05/07/2020
Location: United States
Posts: 490
Posted: 06:11pm 09 Feb 2021
Copy link to clipboard 
Print this post

  Quote  Towards the end of 'GRAPHICS Programming on the Colour MaxMite 2, Ver 2.0a, near the bottom of Page 40, is says that sprite collisions will be discussed in much more detail in the next post but I have not been able to find that post so far.
 Download the full current version 5.06.00 and the PDF is in it.

https://geoffg.net/maximite.html
Edited 2021-02-10 04:13 by mclout999
 
Deadreddreadhead
Newbie

Joined: 07/02/2021
Location: United States
Posts: 7
Posted: 06:32pm 09 Feb 2021
Copy link to clipboard 
Print this post

Thank you. I will do that.

Peter.
 
Deadreddreadhead
Newbie

Joined: 07/02/2021
Location: United States
Posts: 7
Posted: 09:24pm 11 Feb 2021
Copy link to clipboard 
Print this post

OK so.....

If I use:

Local spritehit=sprite(T,2)

That will put a number into 'spritehit' that is a number that represents which sprite sprite(2) has hit, but it will be a decimal value such as 4,8,16,32,64,128,256 etc.

If there any quick way to convert that to the relevant sprite number it represents?

Thank you.

Peter.
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 10:23pm 11 Feb 2021
Copy link to clipboard 
Print this post

SPRITE(T,2) will return ALL sprites that #2 is touching.

To check if #2 is touching a particular sprite, #N say, you need something like:

IF SPRITE(T,2) AND 2^N THEN <touching sprite #N>
-or-
IF spritehit AND 2^N THEN <touching sprite #N>

2^N is used as a bit mask: the Nth bit is set.
The AND performs a logical AND which returns 1, making the IF statement TRUE, only if the Nth bit is set in both values.
Visit Vegipete's *Mite Library for cool programs.
 
Deadreddreadhead
Newbie

Joined: 07/02/2021
Location: United States
Posts: 7
Posted: 12:16am 12 Feb 2021
Copy link to clipboard 
Print this post

Ah Peter, you are a star! I have implemented that and while all still a bit messy and causing other errors in the code I am now seeing some positive results! Half the fun is trying to think through the problems as I am sure you know so I will see how far I can get before pressing the help button again!

Thank you Vegipete and mclout999 for all your help so far!

It is  much appreciated!

Peter.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025