Hurt my knee a few years back playing b-ball. Knee was swollen, black and blue and warm to the touch. What could have been the injury?

Agree and...... You need to be seen by an orthopedic surgeon, or get a mri, i'm order to find out the nature and extent of damage, if any, to your knee. If this is your x-ray then it shows, what looks like a patellar fracture.
See an orthopedist. And do this asap. You could have blood in the joint space, may have torn ligaments or tendons and this needs to be examined, diagnosed and treated by an expert. See an orthopedic surgeon soon, and good luck.