English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 11 December 2015, 04:21   #1
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 35
Posts: 2,928
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
The game only tests collisions with sprites 2, 4 and 6. SPrites 1, 3 and 5 are ignored.

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?
Shatterhand is offline  
AdSense AdSense  
Old 11 December 2015, 12:19   #2
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,823
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?
Daedalus is online now  
Old 11 December 2015, 14:55   #3
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 35
Posts: 2,928
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.
Shatterhand is offline  
Old 11 December 2015, 15:00   #4
Toni Wilen
WinUAE developer
 
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 43
Posts: 21,169
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..
Toni Wilen is offline  
Old 12 December 2015, 21:23   #5
volvo_0ne
Registered User

 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 288
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.
volvo_0ne is offline  
Old 12 December 2015, 21:32   #6
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 35
Posts: 2,928
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.
Shatterhand is offline  
Old 12 December 2015, 22:20   #7
volvo_0ne
Registered User

 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 288
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
volvo_0ne is offline  
Old 12 December 2015, 22:42   #8
Shatterhand
Warhasneverbeensomuchfun

Shatterhand's Avatar
 
Join Date: Jun 2001
Location: Rio de Janeiro / Brazil
Age: 35
Posts: 2,928
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.
Shatterhand is offline  
Old 12 December 2015, 23:02   #9
volvo_0ne
Registered User

 
Join Date: Mar 2015
Location: Sheffield UK
Posts: 288
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.
volvo_0ne is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Collision detection: 2 doubts nandius_c Coders. Asm / Hardware 6 30 November 2014 00:53
OCS collision and clx registers PiCiJi Coders. Asm / Hardware 9 17 August 2014 19:19
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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 23:32.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.
Page generated in 0.06895 seconds with 13 queries