Help with Step 13 or Lesson 17

Help…
In Step 13 My score is not working when the character is touching the coin. I am following the Example Solution… could someone help me see what I’m doing wrong.

Thanks! Ms. G

Hello @tracy.d.grayson,

Sorry you are experiencing some troubles … unfortunately, the link you shared only takes me to the studio.code.org website and isn’t a direct link to your project.

If you can click on the “share” button at the top of the page or if it’s not there, click on “remix” and then “share”, you will get a link that will go directly to your project and then, one of us would be happy to take a look and see if we can help you troubleshoot it.

thanks!

Mike

1 Like

https://studio.code.org/projects/gamelab/WfkjZHAmRdg1HlAFA_nBbjued3oVET19a7h-uJSPYqY

thanks Mike, here is the correct link…

Tracy

Hello;

I just check your code, and I notice that you are not printing your variable score when is your sprite touches a coin.

I hope that helps.

1 Like

@gilrpadilla is correct. You are displaying the text “score:”, but you need to add another text block that displays the value of the variable score. (same as the text block you have, but have it display score with no parenthesis and that will show the actual value of the score.)

Mike

Sorry… I am confused… is this what you mean? I added a text block score in the IF statement… If not, could you show me what the line of code is?


Thanks,
Tracy

Thanks for your help…

You added the right block, but I would put it around line 16 (inside the draw loop, but not inside the conditional). You want to display the score at all times, not just when you are touching the coin. Also, you may need to move it to the right a little, but I think you are almost there!

Mike

https://studio.code.org/projects/gamelab/WfkjZHAmRdg1HlAFA_nBbjued3oVET19a7h-uJSPYqY

OK… I got the score to update, but the value is displaying over top of the S? How do I fix this… Also, what happens when my character goes off the screen? (y<0) He doesn’t come back down?

Thanks!

I’m still trying to figure out where the little guy goes when he leaves the screen, but lines 15 & 16 have the actual score and the word “score” starting at the same point. That is why they are on top of one another. If you just move the value on line 15 a bit, it’ll be separated.

OK… got score placement fixed… just need to figure out where the character goes. Should I decrease the character’s speed? Yay… I’m getting there!

Thanks for your help!

https://studio.code.org/projects/gamelab/WfkjZHAmRdg1HlAFA_nBbjued3oVET19a7h-uJSPYqY

What is happening is that he can leave the screen (top, bottom, left or right side). There are a number of ways to fix that. In my experience, the easiest is by using two blocks in the sprites toolbox (red/pink blocks). One is called “create edge sprites”. You can put that one at the very top (or near the top) of your code (not inside the draw loop). The other one needs to go in the draw loop somewhere. It is the “sprite.bounceOff” block. change the word sprite to character in your program and inside the box type “edges”. So, the final result would be character.bounceOff(edges);

The first one creates invisible rectangles (borders), just off the screen. The 2nd one tells your character to bounce off of them if it touches them.

There are other ways if you only want to fix one of the borders, but try that and see if that is what you are after.

Have a good day!

Mike