Jump to content

Mord's Blog

  • entries
    170
  • comments
    93
  • views
    98,663

P0/P1 Collisions

Sign in to follow this  
Mord

302 views

I've worked on that some more since the last time I looked at it. And I was apparently wrong with it being a problem with the Tick based code. (That might have been a problem as well, but fixing it didn't change the behaviour)

 

The real problem, (this time I'm pretty sure it's the case!) is that I was examining the P1P0 collision during the Vertical Blank of the following frame in AI routines. The problem is that, by necessity, the AI routines are processed after the Object Manager does it's work.

 

What does the Object Manager do again? It handles the object flickering of course. So basically, unless there was no flickering going on, by the time we examined the detected P0P1 collision, our key object would have been swapped out with a different object to be displayed. Because of this, when the key touched the gate it would fail to recognize it because it would be checking the new object loaded into the hardware sprite to see if it was the key - and of course it wouldn't be!

 

I could probably test this by having just 1 other object in the room touching the gate instead of the key. What would happen is that that object would be touching the gate and causing it to react as if it were the key - so long as the key was on the screen.

 

So I'm re-writing the approach and at the same time making the GateMovement routines generalized enough to handle all possible gates. There will be probably up to or more than 8 gates in total. (1 bit per gate to keep track of if it is currently open or closed)

 

Hopefully I'll have it done by the end of the weekend. The code is 2/3 written (just the AI to do) but you know there's going to be weird bugs all over the place.

 

*update*

 

As mentioned in comments below, here's a beta for 0.018. It's got all the physical changes I want to do - and the only thing anyone would notice by looking at it is the gate collisions aren't messed up by flickering - but still have to update to a 16k rom size to finish this version. :)

Sign in to follow this  


2 Comments


Recommended Comments

If you can spare a byte or two to keep track of what objects collided, that might be helpful, especially if you run the main game loop at 30Hz but can run the flicker routine at 60Hz.

Share this comment


Link to comment
If you can spare a byte or two to keep track of what objects collided, that might be helpful, especially if you run the main game loop at 30Hz but can run the flicker routine at 60Hz.

 

I ended up using two bytes to help track the gates afterwards. RoomGateKey, and GateMask. GateMask was used to help generalize the routine used for gate movement and key-gate collisions. All I have to do is have the gate's AI set their values. Loading a new room will (eventually) set both of those to 0 to make sure we don't have the code messing up objects it shouldn't be touching.

 

RoomGateKey equals the object ID of the key to trigger it. GateMask is essentially a bit selector to use on the CastleGates byte. (CastleGates keeps track of whether each gate in the world is open or closed.)

 

I just finished debugging the new code and the gate collisions now appear to be 100% reliable. I'll update the main blog entry with a beta for 0.018 - the next thing (and last thing for this version) is the conversion to a 16k rom format. Should be a lot easier to do this time now that I've separated different portions of the code.

Share this comment


Link to comment
Guest
Add a comment...

×   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...