Oh yeah food can absolutely affect your moods!!
Sugar and refined crap can give us an instant high, and then once it starts digesting you go thru the blood sugar swings and feel crappy and miserable not to mention fatigued.
When you have crap, get back to plan at the very next snack! Or even follow your carb fest with some protein to mitigate the damage.
The more treat meals you give yourself ESP in the beginning the more opportunity there is to fail.. As sugar begets sugar. So I would try to remove it from your life as much as possible and always have a plan b on food.
Be full when going out for longer periods or to events and tuck some protein fat combo into your purse.
Good luck and don't let negative self talk set in. None of us got chubby from one bad meal