As mentioned above, the bear was looking for food. Get the food (including garbage, soap, deodorant or anything with a strong smell) out of the teepee and the bear will leave the teepee alone. You should have let that airhorn go. It would have scared the c__p out of the bear. Yosemite Rangers now chase bears out of campgrounds using fireworks and noise makers.

If you want to feel a bit more secure with your bear encounter, do some research on bear fatalities. They are quite rare.