Jump to content
IGNORED

sprite collision questions (DPC)


Muddyfunster

Recommended Posts

Hi all,

 

I've been working on a new project and I've run into a problem that I'm struggling to work around.

 

I'm using the DPC+ Kernel and have an issue with sprite collision. I understand the constraints of working with virtual sprites in that they are all basically copies of p1.

 

My problem is to do with checking for collisions between these virtual sprites and player 0. I've drawn a little picture to illustrate :

 

post-61789-0-77868300-1545830285.png

 

Playfield is represented by the red box,

Green is "off screen"

Blue circles are "player8" virtual sprite and are used to show lives left

 

Player 0 enters from the top of the screen and exits the bottom and can move left and right. when player 0 re-enters at the top he inherits the X position where he exited. My problem occurs because player0 can hit player 8, triggering a collision and a loss of a life.

 

Player0 starts off with his Y variable set to -16 so that he is offscreen and uses an 8.8 variable for movement for both X and Y axis

 

I tried a simple : if player0y < 17 then goto skip_collision_check

 

My logic is this check should cover everything below 0 and everything up to y becoming = 17 (0 + the size of the sprite)

 

This works with the sprite is fully visible on the playfield but not when part of the sprite is offscreen.

 

i've tried gating the collision check every way I can think of but it looks like the IF statement isn't seeing a negative y co-ordinate as being less than 0.

 

Any ideas or suggestions would be appreciated.

 

 

 

Link to comment
Share on other sites

Hi all,

 

I've been working on a new project and I've run into a problem that I'm struggling to work around.

 

I'm using the DPC+ Kernel and have an issue with sprite collision. I understand the constraints of working with virtual sprites in that they are all basically copies of p1.

 

My problem is to do with checking for collisions between these virtual sprites and player 0. I've drawn a little picture to illustrate :

 

attachicon.gifsprite explanation.png

 

Playfield is represented by the red box,

Green is "off screen"

Blue circles are "player8" virtual sprite and are used to show lives left

 

Player 0 enters from the top of the screen and exits the bottom and can move left and right. when player 0 re-enters at the top he inherits the X position where he exited. My problem occurs because player0 can hit player 8, triggering a collision and a loss of a life.

 

Player0 starts off with his Y variable set to -16 so that he is offscreen and uses an 8.8 variable for movement for both X and Y axis

 

I tried a simple : if player0y < 17 then goto skip_collision_check

 

My logic is this check should cover everything below 0 and everything up to y becoming = 17 (0 + the size of the sprite)

 

This works with the sprite is fully visible on the playfield but not when part of the sprite is offscreen.

 

i've tried gating the collision check every way I can think of but it looks like the IF statement isn't seeing a negative y co-ordinate as being less than 0.

 

Any ideas or suggestions would be appreciated.

 

 

 

 

The processor (and therfore bB) doesn't really know about negative numbers
You can subtract and there is a flag for negative numbers. The flag reflects the state of of bit 7
(There's also an overflow flag which is (the carry from bit 6) ^ (the carry from bit 7))
(It's a pity that bB doesn't give you access to the flags)
But it's really how you interpret the numbers (go read about 2's complement (Wikipedia))
Your bytes go from 0..255
255 = -1, n + 255 = n - 1 (this is all MOD 256)
if you want a range of say -17 to +17, your if statement would be something like
If x >= 239 && x <= 17 then
and in bB you can write that as
if x >= -17 && x <= 17 then
239 = 256 - 17
Using 239 takes less time and code
Edited by bogax
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...