Everything in the Black★Rock Shooter franchise is based on the original concept art by Huke on Pixiv. These were fairly popular, but it really only took off after the supercell song Black★Rock Shooter, which quickly became one of the most popular vocaloid songs to date.
After that point, the franchise essentially split, and all of the following productions are different canons. There has been an OVA and a TV anime, which have similar characters but the plot is rather different. Both of these were criticized by some fans for including lots of content and knew characters which weren't really closely related to the original concept. The game took a more conservative approach by sticking to the action-themed post-apocalyptic mood of the original and only introducing a few new characters. In general, it's safe to say that based on how different the plots of these are, they all take place in different universes.
In addition to those, there have been several other releases, which also generally take place in their own universes. Black-rock chan is a 4-koma manga based on the original concept art. Black★Rock Shooter ~Innocent Soul~ is a manga, again based on the original and in a different universe. There was also a manga and a 4-koma related to the game.
So, to summarize, there is no direct connection between the anime and game, but they are both based on the same original work.