11 December 2015, 04:21 | #1 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Sprite collision help
I am doing a game using 1 sprite for player and 6 sprites for enemies. The game is designed in such a way there are never more than 6 enemies on screen, so this work fine for me.
But I can't make collisions work properly! The code I am using is very simples: Code:
DoColl For tta=2 to 7 If SColl (0,tta) = -1 and contavida = 0 explode{} End If If I draw the player using sprite 1 (and changes the collision code accodingly), no collisions are detected ever. If I use sprite 2 (again, changing collision routine), I again can only collide with even sprites. It's like sprites collisions can only be detected on even sprite channels! Is this really the case? Is this an Amiga Hardware limitation, a Blitz Basic limitation, or am I doing something stupidly wrong? |
11 December 2015, 12:19 | #2 |
Registered User
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 6,374
|
It's a long time since I did anything with sprites, but it should work fine. There are commands to set the collision detection to even or odd colours on the display, but none for even or odd sprite channels that I know of.
The sprite channels are organised in pairs, so perhaps that's doing something to affect things. Maybe you could post your sprite and display initialisation code - are you using the DisplayLib or slices? Are you configuring your sprites as 15-colours? Because using 15-colour sprites disables the odd channels, as does using sprites wider than 16 pixels. What hardware are you running it on? If you're using an emulator, check for full sprite collision emulation. Often emulators don't do full collision detection in order to speed up the emulation but you can usually manually enable it. Another thing you could try is putting the DoColl command after the For command, so it executes prior to every check. I can't remember enough about it, but maybe it's required I take it the contavida variable is remaining equals zero? As in, you're not modifying it in an interrupt or anything? |
11 December 2015, 14:55 | #3 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Contavida is equal zero while the player is "alive". When you die, it goes to a number and keeps coming down until it gets to zero again (it makes you invencible for a while, also don't let you "die" again while you are already "dead"). It's always zero (the collision *do* happen on even channels)
All sprites are being loaded from a 2 bitplanes bitmap, and I can also draw all 8 on screen without trouble. I am testing using Winuae , I remember there was an option to disable full sprite collision, but I didn't find it anywhere. |
11 December 2015, 15:00 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,545
|
Sprite collisions are weird in Amiga
"Full collision" only enables sprites to bitplane collisions. Only known game that uses sprite to bitplane collisions is Rotor.. |
12 December 2015, 21:23 | #5 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
I've never used Blitz, but maybe one (or more) of your sprite definitions is larger than a 16 pixel width limit, thus causing it to grab 2 sprites to complete the image.
I could be totally wrong, but worth checking out. |
12 December 2015, 21:32 | #6 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Yeah, it makes senso, but that's not the case.. they are all 16 px wide and, like I said , I can draw all of them at the same time without problem. If that was the case, it wouldn't be able to draw all 8 sprites.
I am really frustrated with this, it's a very weird error. |
12 December 2015, 22:20 | #7 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
firstly there is no Next tta (in your explanation)
try this DoColl For tta=2 to 6 step 2 If SColl (0,tta) = -1 and contavida = 0 explode{} End If Next tta ...... As I say I know little of Blitz |
12 December 2015, 22:42 | #8 |
Warhasneverbeensomuchfun
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 41
Posts: 3,450
|
Duh, that was a stupid mistake of mine, there is a next on the code I just typed it wrongly here
If I do your suggestion, I'll still only have collisions with even channels. I actually did that before, same thing happens. |
12 December 2015, 23:02 | #9 |
Registered User
Join Date: Mar 2015
Location: Sheffield UK
Posts: 360
|
Just out of interest try doing it a different way
Some languages have wierd bugs. Also check the spelling of your variables (VERY IMPORTANT) EG: DoColl tta=2 Repeat If SColl (0,tta) = -1 and contavida = 0 explode{} End If inc tta until tta>7 or even ..... DoColl tta=2 Repeat If SColl (0,tta) = -1 If contavida=0 explode{} End If End If inc tta until tta>7 break it down until you find where the problem lies. Last edited by volvo_0ne; 12 December 2015 at 23:23. |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
OCS collision and clx registers | PiCiJi | Coders. Asm / Hardware | 11 | 30 July 2019 06:15 |
Collision detection: 2 doubts | nandius_c | Coders. Asm / Hardware | 6 | 30 November 2014 00:53 |
Is there a Pacmania with sprite-collision disabled? | Predseda | request.Other | 3 | 30 January 2012 17:10 |
Sprite movement and Collision Routine | Blip | Coders. General | 35 | 14 February 2011 00:00 |
Slamtilt and RTC collision | Predseda | support.Games | 5 | 22 August 2009 22:28 |
|
|