You need an entire pc, case, mobo, cpu, gpu, power supply, ram and an os for gaming for under $400? Do you also need a monitor, keyboard and mouse? I'm not sure what games you're looking to play, that will be part of the equation.
For something like a gaming pc assuming you're looking to keep it for awhile (1-2yrs) it might be better to save just a bit more and put the money to good use. Rather than investing $400 to try and get something right this minute, find out it's not what you expected or were hoping for and having to upgrade it right away with your money already put into it.
The trouble with amd's current fx platform, it's about to be replaced. Say you invest in a 970a mobo, fx 6xxx or 8xxx cpu, ddr3 ram etc. To get more performance out of it you have two options, intel or amd zen. Either will mean a new motherboard, ddr4 ram, a new cpu. It's not all that much bang for your buck in terms of performance.
If you go with an i3 you'll have similar performance to an fx 8350 at slightly less cost, ddr4 that newer platforms (both intel and amd) are moving toward and the ability to upgrade just the cpu without having to replace half the system you just invested in. Even then an i3 or 8350 is going to exceed your $400 budget.
Yes you could try and go cheap as possible but there are issues to that. Say you buy a cheap mobo then run into issues with low power phases or vrm that can't handle the load and overheat causing you thermal throttling. The $40-50 cheap mobo will need replaced by an $80-100 mobo and now your inexpensive board ultimately costs you $130-140. If you buy a cheap low end power supply for $25, assuming it doesn't overload, short and kill half the components it's connected to - come to find out your system starts shutting down under load in the middle of games. Now you're replacing it with a better $60 power supply, that 'cheap' $25 psu now has cost you $85.
At the end of it all you could potentially have invested $800 into a $600 pc and still only have a $600 pc. It's not a great way to save money.