I'm planning to make a simple, HTML5 game, that would use some elements of the Half Life universe. Basically, it would be a 2D Portal clone, but it would have it's own story, and portals would be different, along with the mechanics of making and using them. Also, how far can I go with this? If possible, I'd like to have Gman, a character from Half Life, walk by a few times, and maybe even use some of the sounds from Half Life or Portal. It's also important to note that I wouldn't be making any kind of profit.
Using characters, ideas or other assets from another game is illegal if you do not have permission. As @Kylotan said: whether or not the game is non-profit does not change anything, either way you would be breaking laws around copyright and possibly patents too. That being said, there are games and other media based around Valve titles that have been created for which Valve have taken no action against. Doing what you described in your question would probably be OK with them too. However, I am not a lawyer and am in no way legally responsible if you do get a knock on the door about the game you intend to create. It's up to you if you want to take the chance.
Using their characters is not legal at all, nor is using their sounds (or graphics, or unique names). Your game being non profit makes no difference (except to the amount of damages you'd pay).
Copying gameplay is allowed, however. They don't own the concept of portals, but they are likely to own a trademark on the name 'Portal' in the context of computer games.