Jump to content
IGNORED

DPC+ Virtual sprite collision trouble


Captain Spazer

Recommended Posts

I've figured out many things of the mysteries of DPC+ but this one I can't quite figure out. I'm having 6 enemies on screen and player0 is controlled by the player, and sprites 1-6 are the enemies. Player0 can shoot the ball as a projectice and I'm trying to figure out a good way to do collision detection between player1-6 and the ball. My question is: Do I need to put player2-6's x and y values into variables to detect a collision as with the old multisprite kernel? I atempted this code but it only works with player1, all other gives a compilation error.

 if collision (ball,player1) then score=score+5 : ballx=255 : bally=255 : player1x=255 : player1y=255

 rem THIS GIVES COMPILATION ERROR:
 if collision (ball,player2) then score=score+5 : ballx=255 : bally=255 : player2x=255 : player2y=255
Link to comment
Share on other sites

I'm also going to make an example program based on what iesposta posted a while ago:

 

atariage.com/forums/topic/253757-example-dpc-collision-detection-of-copies/?p=3531459

 

I haven't looked at it in detail, so I don't know if his code is perfect the way it is or if it needs to be adjusted.

  • Like 1
Link to comment
Share on other sites

I've experimented with collision detection on the DPC+ and for the most parts I can get it to do what I want, but now I managed to mess something up, any thoughts on this problem: The code below works perfectly, except for that player2-6x/y won't take effect, their y position won't go to 0 and their x position refuses to randomize,

 

BUT, if I switch the order of things and put playerx=rand : playery=0 just after trick=x then it works but whatever is put last on the row of code won't work, is the code to long for the 2600 to calculate or did I miss something?

   ;```````````````````````````````````````````````````````````````
   ;  Width of sprites.
   ;
   dim enemyP2=j
   dim enemyP3=k
   dim enemyP4=l
   dim enemyP5=m
   dim enemyP6=n

   dim trick=o



   if !collision(ball,player1) then goto SKIP

   if (bally+4)>=player2y && bally<=(player2y+4) && ballx >=player2x && ballx <= (player2x+64) then trick=0 : score=score+5 : s=0 : player2x=rand : player2y=0
   if (bally+4)>=player3y && bally<=(player3y+4) && ballx >=player3x && ballx <= (player3x+72) then trick=1 : score=score+5 : s=0 : player3x=rand : player3y=0
   if (bally+4)>=player4y && bally<=(player4y+4) && ballx >=player4x && ballx <= (player4x+64) then trick=2 : score=score+5 : s=0 : player4x=rand : player4y=0
   if (bally+4)>=player5y && bally<=(player5y+4) && ballx >=player5x && ballx <= (player5x+72) then trick=3 : score=score+5 : s=0 : player5x=rand : player5y=0
   if (bally+4)>=player6y && bally<=(player6y+4) && ballx >=player6x && ballx <= (player6x+64) then trick=4 : score=score+5 : s=0 : player6x=rand : player6y=0
SKIP
  

RacerTech0.5.bas

 

 

 

EDIT:

Nevermind, I found a solution, I just added in this and it works like a charm on this occasion too, sorry for being silly.

   if (bally+4)>=player1y && bally<=(player1y+4) && ballx >=player1x && ballx <= (player1x+64) then score=score+5
   if (bally+4)>=player2y && bally<=(player2y+4) && ballx >=player2x && ballx <= (player2x+64) then score=score+5
   if (bally+4)>=player3y && bally<=(player3y+4) && ballx >=player3x && ballx <= (player3x+72) then score=score+5 
   if (bally+4)>=player4y && bally<=(player4y+4) && ballx >=player4x && ballx <= (player4x+64) then score=score+5
   if (bally+4)>=player5y && bally<=(player5y+4) && ballx >=player5x && ballx <= (player5x+72) then score=score+5
   if (bally+4)>=player6y && bally<=(player6y+4) && ballx >=player6x && ballx <= (player6x+64) then score=score+5
Edited by Captain Spazer
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...