CSD U3 Lesson 22 Baseball/Softball game


I have a student that is so close to finish coding her softball/baseball game. Starting in Line 186, Function background2, if you select player2 = softball player, when background2 shows up after catching 25 or more softballs. The softball sprite shows up; however, when you select the baseball player and catch 25 or more baseballs, you still see the softball sprite instead of the baseball sprite.

We have tried different ideas, but always one sprite dominates the other. Meaning the baseball sprite shows up when it should be the softball and softball sprite when it should be the baseball. At this point, I have been staring at the code so long I keep going in circles. If anyone has any idea how my student can get the softball sprite to show up in background2 when player2 is selected and baseball sprite for player1 when you catch 25 or more balls would be greatly appreciated!



Very cool game. I assume you figured out the problem as it seems to work right when I play it(or am I missing something?)


Its working to a point, when you select baseball player, when the score gets to 25, the student wants to see the baseball instead of the softball. This is the part that is not working.


When I say baseball, I mean a baseball next to the score. Right now it shows the softball.


I see what you mean. I thought you were talking about the actual player, not the scoreboard.
I’m also pretty perplexed by it. I’ve even tried to change it’s visibility when it changes to the second background and it still shows up. It’s like something is making it visible but the only place in the coding that seems to make it visible is in the background1 function. I’ll keep looking.


Yes, that is what I was seeing too. Thanks for looking into this for us!


I think I got it!
The problem was in line 189. The if statement didn’t have a boolean statement so it really wasn’t working. I made it a boolean statement to check which player was chosen but then I also added a couple lines to the selectPlayer function which made the opposite player’s visible property false(since that’s the boolean I used in 189.

I think this will fix it.

1 Like

Awesome! Thank you…Thank you!!! My student will be so happy. Really appreciate you looking into this. It worked!

1 Like

Happy to help. I actually like looking into things like this. Luckily this is about my level of coding skills. Tell your student it’s an impressive program. I saved it to use as an example in the future.

1 Like