Captain Spazer Posted August 28, 2016 Share Posted August 28, 2016 (edited) I'm trying out the multisprite kernel and it's super awesome. It's so neat that you can have alot of sprites just like real atari games =D However, I'm wondering about calculating collision, just how do you do it? EDIT: I've heard it's easier to use the DPC+ Kernel for multisprite collision detection. But I'm a bit intimidated. Is it hard to convert an existing project to work in DPC? Edited August 28, 2016 by Captain Spazer Quote Link to comment Share on other sites More sharing options...
Captain Spazer Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) Well, I'm gonna start with DPC+ and see if it's any easier then the multisprite kernel. But at the moment I'm kind of stuck on grasping banking. Can I use any bank for anything or is each bank for certain stuff? Also, a question on the multisprite kernel: MY enemy sprites are 8x8 and stretched with nusiz#=05. Is there a way to calculate so that if missile0 is in within those parameters an enemy is hit? Kinda like this? "if missile0x=player2x+8 then player2x=255 : player2y=255 "if missile0x=player2x-8 then player2x=255 : player2y=255 "if missile0y=player2y+8 then player2x=255 : player2y=255 "if missile0y=player2y-8 then player2x=255 : player2y=255 if missile0x = player1x && missile0y=player1y then player1x=255 : player1y=255 if missile0x = player2x && missile0y=player2y then player2x=255 : player2y=255 if missile0x = player3x && missile0y=player3y then player1x=255 : player1y=255 EDIT: Actually, it kinda worked! I managed to get hit detection to work with the multisprite kernel! But only if you hit the enemy sprite dead center, any idea on how to expand so the hit detects no matter where the enemy sprite is hit? if missile0x = player1x && missile0y=player1y then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+1 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+2 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+3 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+4 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+5 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+6 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+7 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y+8 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-1 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-2 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-3 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-4 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-5 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-6 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-7 then player1x=255 : player1y=255 if missile0x = player1x && missile0y=player1y-8 then player1x=255 : player1y=255 Edited August 29, 2016 by Captain Spazer Quote Link to comment Share on other sites More sharing options...
Captain Spazer Posted August 29, 2016 Author Share Posted August 29, 2016 (edited) Major update. It seems to work perfect now, man that was a tough nut to crack. Anyway, ladies and gentlemen, this seems to be the way to do collision detection with the multisprite kernel. First, you need variables to keep track of the virtual sprites, like this: q=player2x-4 r=player2x+1 s=player2y+1 t=player2y-4 Put that in the main loop. Next is the code for the collision: if missile0x>q && missile0x<r && missile0y<s && missile0y>t then player2x=255 : player2y=255 And boom, there ya go =) Proof that this works: Multisprite collision.bin Edited August 29, 2016 by Captain Spazer Quote Link to comment Share on other sites More sharing options...
+Lewis2907 Posted August 29, 2016 Share Posted August 29, 2016 Captain Spazer, With the help of RT and other's I used this in my PacMan Eat and Run Game (I'm revamping it. looks a whole lot better and a few surprises) rem if collision must be after drawscreen or the player will get stuck if collision(playfield,player0) then player0x = xprevious : player0y = yprevious rem ***note*** if just player0 and player1 collision it afffects players 1-9 if player0x=player1x && player0y=player1y then Clock = 0 : if !b{6} && !b{5} then k=15 : m=31 : b{6}=1 : c=0 :goto __Pac_Man_Dies bank4 if collision(player0,missile0) then Clock = 0 : if !b{6} && !b{5} then k=15 : m=31 : b{6}=1 : c=0 :goto __Pac_Man_Dies bank4 if collision(player0,missile1) then Clock = 0 : if !b{6} && !b{5} then k=15 : m=31 : b{6}=1 : c=0 :goto __Pac_Man_Dies bank4 if collision(player0,ball) then Clock = 0 : if !b{6} && !b{5} then k=15 : m=31 : b{6}=1 : c=0 :goto __Pac_Man_Dies bank4 rem collison for PacMan and Fruits if (player0y + 10) >= player5y && player0y <= (player5y + 10) && (player0x + temp5) >= player5x && player0x <= (player5x + 7) then score = score + 1 : player5y=200 if (player0y + 10) >= player6y && player0y <= (player6y + 10) && (player0x + temp5) >= player6x && player0x <= (player6x + 7) then score = score + 1 : player6y=200 if (player0y + 10) >= player7y && player0y <= (player7y + 10) && (player0x + temp5) >= player7x && player0x <= (player7x + 7) then score = score + 1 : player7y=200 if (player0y + 10) >= player8y && player0y <= (player8y + 10) && (player0x + temp5) >= player8x && player0x <= (player8x + 7) then score = score + 1 : player8y=200 rem ghost collions and artificail intellegiance if collision(playfield,player1) then player1x = xprevious1 : player1y = yprevious1 : _Enemy_Counter = (rand&3)+1 if collision(playfield,missile0) then missile0x = xprevious2 : missile0y = yprevious2 : gosub __Pink_Ghost_Reset bank4 if collision(playfield,missile1) then missile1x = xprevious3 : missile1y = yprevious3 : gosub __Blue_Ghost_Reset bank4 if collision(ball,playfield) then ballx = xprevious4 : bally = yprevious4 : gosub __Orange_Ghost_Reset bank4 I have also attached the code to help. Hope this helps what you are looking for, thanks. Pac_Man_Eat_and_Run - 05 Mar 16 (DPC+).txt 1 Quote Link to comment Share on other sites More sharing options...
Captain Spazer Posted August 29, 2016 Author Share Posted August 29, 2016 Thank you, always nice to see more ways of doing things =) Quote Link to comment Share on other sites More sharing options...
+Lewis2907 Posted August 29, 2016 Share Posted August 29, 2016 Captain Spazer, Roger. I got this code from RT. I still don't fully understand how it works. I have an idea per say, but as long it does what I need it to do I'm okay with it. if (player0y + 10) >= player5y && player0y <= (player5y + 10) && (player0x + temp5) >= player5x && player0x <= (player5x + 7) then score = score + 1 : player5y=200 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.