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: GermanyPosts: 74 |
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 KingdomPosts: 6798 |
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: GermanyPosts: 1114 |
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... 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)) 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 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: GermanyPosts: 74 |
I mixed that up with the arguments like in framebuffer f etc... π§π«¨ Silly me. Thanks π Carsten |
||||
Print this page |