![]() |
Forum Index : Microcontroller and PC projects : MMC2 Sprite collision
Author | Message | ||||
Deadreddreadhead Newbie ![]() Joined: 07/02/2021 Location: United StatesPosts: 7 |
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: CanadaPosts: 1132 |
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 StatesPosts: 7 |
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 StatesPosts: 490 |
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 StatesPosts: 7 |
Thank you. I will do that. Peter. |
||||
Deadreddreadhead Newbie ![]() Joined: 07/02/2021 Location: United StatesPosts: 7 |
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: CanadaPosts: 1132 |
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 StatesPosts: 7 |
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. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |