Will these bad grades affect my chances of getting into the college I want?

I am currently a Sophomore in High School, I am taking all honors (and 1 AP) classes and I do quite well A’s and B’s except for the first semester in the first quarter I got a D in Algebra 2/Trigonometry, then second quarter I got another D in Algebra 2/Trigonometry and an F in Chemistry. This just happened for those two quarters, I currently have all A’s for 3rd quarter and I plan on keeping it this way for the rest of the year and the rest of high school. I am usually a very good student and I did very well in middle school and good in my freshmen year. Will those two quarters haunt me for the rest of high school or will be ok as long as I keep my grades up. I am hoping to go to a good college (UCLA or USC) USC is looking to be less likely but I hope it is not. So basically all I am asking is, have I completely ruined my life or will I still have a chance at one of these colleges? (I understand there are other factors that are a part of applying for a college but just grade-wise do I have a chance?)

Ok so I just went and calculated my GPA and I currently have a 3.52 GPA (yes this includes the terrible grades I mentioned)

You have to leave your options open and pay some attention to other schools as well… such as mid/low-tiered UCs (in case USC/UCLA did not work out for you)?

Keep up your GPA and you’ll be good. If you can stay around 3.9 it will help and your cumulative gpa raises in junior year you’ll be fine.

Thank you both for replying. @uclaparent9 I do have other colleges as backups but USC and UCLA are definitely my first picks as they are have a very good program for my “to-be” major. @nocontest Thank goodness I thought those two grades would screw me over. I definitely learned my lesson from that and I am going to make sure my grades dont drop lower than an A ,or B at the lowest.