Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 03:47 28 Nov 2024 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 : PicoMiteVGA: Sprite Collision Problems

Author Message
Calli
Regular Member

Joined: 20/10/2021
Location: Germany
Posts: 74
Posted: 01:00pm 06 Aug 2023
Copy link to clipboard 
Print this post

Hi,

I am on holiday and have the PicoMiteVGA with me, finally some time during rain to get some retro vibes.

Tried some old school game programming. However I am stuck with sprite collisions.

They does not work for me. I stripped down the example in the manual but either I dont understand or there is an error.

Attached the code and sprite of a stripped down version. No collisions...

I have some limited internet access here.

Cheers,
Carsten
D.zip
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 6798
Posted: 11:06am 07 Aug 2023
Copy link to clipboard 
Print this post

Bump

There must be someone who can help. Alas, it's not me as I've never used sprites.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1114
Posted: 12:39pm 07 Aug 2023
Copy link to clipboard 
Print this post

  Mixtel90 said  Bump

There must be someone who can help. Alas, it's not me as I've never used sprites.

I never used the intern Collision detection...
but I seen one possible Bug in Callis Sub SprI:

st$="booom: "+str$(sprite(S))+" : "+str$(sprite(C,S))

but Variable S (in "sprite(C,S)") in not set in your code, it will allways be 0...

  Quote   SPRITE(C, [#]n )
Returns the number of currently active collisions for sprite n. If n=0 then
returns the number of sprites that have a currently active collision
following a SPRITE SCROLL command

so I think this should be

st$="booom: "+str$(sprite(S))+" : "+str$(sprite(C,sprite(S)))

Had no time to test it but how about the Subroutine, from the Manual Page 134-135?

SUB collision
LOCAL INTEGER i
' First use the SPRITE(S) function to see what caused the interrupt
IF SPRITE(S) <> 0 THEN 'collision of specific individual sprite
'SPRITE(S) returns the sprite that moved to cause the collision
PRINT "Collision on sprite ", SPRITE(S)
process_collision(SPRITE(S))
PRINT
ELSE '0 means collision of one or more sprites caused by background move
' SPRITE(C, 0) will tell us how many sprites had a collision
PRINT "Scroll caused a total of ", SPRITE(C,0)," sprites to have collisions"
FOR I = 1 TO SPRITE(C, 0)
' SPRITE(C, 0, i) will tell us the sprite number of the β€œI”th sprite
PRINT "Sprite ", SPRITE(C, 0, i)
process_collision(SPRITE(C, 0, i))
NEXT i
PRINT
ENDIF
END SUB

' get details of the specific collisions for a given sprite
SUB process_collision(S AS INTEGER)
LOCAL INTEGER i, j
' SPRITE(C, #n) returns the number of current collisions for sprite n
PRINT "Total of " SPRITE(C, S) " collisions"
FOR I = 1 TO SPRITE(C, S)
' SPRITE(C, S, i) will tell us the sprite number of the β€œI”th sprite
j = SPRITE(C, S, i)
IF j = &HF1 THEN
PRINT "collision with left of screen"
ELSE IF j = &HF2 THEN
PRINT "collision with top of screen"
ELSE IF j = &HF4 THEN
PRINT "collision with right of screen"
ELSE IF j = &HF8 THEN
PRINT "collision with bottom of screen"
ELSE
' SPRITE(C, #n, #m) returns details of the mth collision
PRINT "Collision with sprite ", SPRITE(C, S, i)
ENDIF
NEXT i
END SUB


Edited 2023-08-07 22:58 by Martin H.
'no comment
 
Calli
Regular Member

Joined: 20/10/2021
Location: Germany
Posts: 74
Posted: 01:12pm 07 Aug 2023
Copy link to clipboard 
Print this post

I mixed that up with the arguments like in framebuffer f etc...

🧐🫨

Silly me.
Thanks πŸ‘
Carsten
 
Print this page


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

© JAQ Software 2024