Jump to content
  • entries
    34
  • comments
    88
  • views
    26,199

bBasic - Adding some collision detection


Robert M

689 views

Goals:

-> Implement player collision detection and hit point tracking.

 

Design:

-> Start from last entry.

-> Life and Shield strength bars at the bottom of the screen. Life is on the left, shield strength is on the right.

-> Collision detection of enemy shots and sprites hitting the player using hardware collision detection.

-> Shots hitting the player must be reset to bottom of screen to prevent hitting the player multiple times.

-> The shield protects the player from hits but loses its own strength.

-> The bottom most Enemy bat swoops down at the player by simply mulitplying the Ycount factor by 2.

-> A swooping bat can hurt the player only while descending. This is actually easier to implement since the sprites involved are on the screen together allowing use of hardware collision detection.

-> Make the player's shot looks different from shield.

-> Some color changes.

-> The player's color flashes when he is hit. The player is invulnerable while flashing. The upper nybble of the playerStatus byte is set to %1111 when the player is hit. It is decremented every odd frame and added to the player's base color on even frames to make the flashing effect.

 

Implementation:

main014.txt

main014.txt.bin

 

Lessons learned:

-> I must remember to ues the built in bit operators to test/set single bits rather then coding them myself with bitwise instructions.

-> BUG? The bBasic compiler does not like the bitwise-& operator in the expression for a if-statement. It compiles to a CMP instructon with no branch, rather than a AND instruction followed by a conditional branch. I posted about this in the bBasic bug report thread.

 

Recommendations for improving bBasic:

-> None.

 

Up Next:

-> Adding more collision detection.

0 Comments


Recommended Comments

There are no comments to display.

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