Collision is wrong when I use DrawAnim but ok with DrawSprite

Previous topic - Next topic

spicypixel

This is where I load my animation file which has 8 frames
Code (glbasic) Select
nme  = GENSPRITE() ; LOADANIM "gold_coin.png", nme, 16, 16

This is where I setup my generic Spritetype
Code (glbasic) Select
TYPE Sprite
SprX
SprY
SprSpd
SprFrame
MaxSprFrame
ENDTYPE

GLOBAL Alien[] AS Sprite
DIM Alien[64]
FOR enemy = 0 TO 63
Alien[enemy].SprX = RND (800)
Alien[enemy].SprY = RND (288)
Alien[enemy].SprSpd = RND(2)
Alien[enemy].SprFrame = RND(7)
Alien[enemy].MaxSprFrame = 7
NEXT


This is my collision checking in the Update Logic subroutine (LevelX is a scroll offset pointer so the sprites are fixed to my background)
Code (glbasic) Select
// Check Player Enemy Collision
FOREACH enemy IN Alien[]
col = SPRCOLL(nme, enemy.SprX + LevelX, enemy.SprY, ball, PlayerX, PlayerY)
IF col = TRUE
DELETE enemy
col = FALSE
ENDIF
NEXT


Here's my draw sprites subroutine
Code (glbasic) Select
// Display Enemies
ALPHAMODE 0
FOREACH enemy IN Alien[]
DRAWANIM nme, enemy.SprFrame, enemy.SprX + LevelX, enemy.SprY
enemy.SprFrame = enemy.SprFrame + 1
IF enemy.SprFrame > enemy.MaxSprFrame THEN enemy.SprFrame = 0
NEXT


Now the Sprites get deleted when you collide with them but sprites on the left get deleted too??? However when I use exactly the same code but with DRAWSPRITE instead of DRAWANIM the collision is perfect and only the collided object gets deleted.

I'm really stumped, help please lol.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

MrTAToad

Its been mentioned before that there seems to be a problem with animated collision.  Hopefully this will get moved to the Bugs Report forum.

spicypixel

I can only presume the collision is being done based on the width and height of the animstrip and not the individual cell then??? Guessing really. I may try a vertical anim strip to see if the collision is deleting objects vertically instead of horizontally as it's doing now. After that I may try to use two rows or columns instead of just one, see what works...

Thanks for the reply I've just started with GLB so I'm double checking my code incase I'd missed something lol ;)
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

spicypixel

I have tested it with a vertical animstrip and indeed the collision is now deleting objects vertically so it's definitely a GLB bug. I tried a 1x8, 8x1, 2x4 and 4x2 cells. Each time it seems the collsion is based on full height and width of the animimage and not the individual cell. I could load my frames into an array and cycle through them with DRAWSPRITE but it is an annoying bug.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Kitty Hello

Sorry. Can you make a small reproducible example for this?

spicypixel

I meant to update my post but had guests yesterday. The problem I had was that I was referencing the anim png by using SPRCOLL not realising there was a comman ANIMCOLL. Now that I've put the collectible coins into an array of separate sprites the collision works perfectly :) However I'm gonna just load an animation in again and retest using ANIMCOLL.

I do however have another problem now which I'm gonna post shortly. So hopefully someone can shed some light on what my problem is, I'm pretty stumped to be honest. I will post project and source (including gfx and sound) so people can test it properly and enlighten me somehow as to where I seem to have gone wrong.
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

spacefractal

Here I can't confirm its a GL bug, since its does works here and return what I excepted.

odd, here its does works as inteded.

howover here I use a sprite (a 1x1 pixel, act like a mouse pointer) vs a anim tile (where the tiles I use is just 2 color image, one color, and one alpha, just using for collision use). Howover alpha col also might break webOS 1.4.5 too (hoping there is a software fix).

Mightbeen you forget to tell which tile its should use or such thing? If you set it to 0, its of course use the whole image.

So wierd problem?
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/