CSD - Unit 3 Lesson 14

Help!! We are coding correctly as far as I can see, yet some classes it works and some it does not. I reported a bug and they wrote back to post here.

The leprechaun is not moving left to right as it should. Another period the ball is to hit the bat and it is not moving continually. Will only move 1 pixel even with holding down the key or repeatedly clicking.

This is happening with several students.
Also today code is disappearing. We are even getting white screens. This is new.

Thank you.

Try moving all your “var” statements before (outside) your draw loop. Several of my students had similar issues. By leaving your var statements in your draw loop, you are repeatedly creating a new variable (into the same position… overwriting any changes to position you may have made previously). Similarly, there’s no reason to have your setAnimation blocks in the draw loop unless your animation changes when your program is running (although I don’t think leaving it in the draw loop will break anything - unlike the var statements).

Oh… and same with the “scale” blocks… if the thing doesn’t need to be continually updated/checked, I would leave it outside the draw loop.

2 Likes

@ksimpson

Hi Kimberley,

I agree with everything that Frank said about the code, but I would also add that if code is disappearing, please definitely report that as a bug. The bug report you sent about the code disappearing was closed for another reason, and I’ll follow up with you in a direct message.

I think that the person who asked you to post it here just meant the question about the way the code worked itself, and not that code was disappearing on you. (It’s nice to have code discussions in the forum because usually multiple people are having the same issues.)

Thanks for taking the time to write in and post.

Elizabeth

My student, Catalino, can’t see his text on his project. We have tried to move the text from the middle to the top to the bottom but it still won’t appear. Below is the link to his project, please help us.

@cklabunde,

In this project, you have the text below the draw block. I’m thinking you may want it inside the draw block or it may never be displayed.

Also, you have two “drawSprites” blocks. One of them should be removed.

If you can move the text inside the draw function and remove one of the drawSprites (leaving the other one to draw the Sprites BEFORE the text is drawn, I’m guessing you will be able to get it to work.

Let us know!

Mike

Hi,

My student, Catalino, followed your directions and his text did appear. However, now his bear won’t move. We have tried everything we know. Would you look at it again, the link is below:

https://studio.code.org/projects/gamelab/hJMOY4uU3de8Y34yfpi5gyTQgIXaBfes9JVf53ImK6k

Thanks,

Cindy

Hi @cklabunde,

This is a fun one! I notice you’re calling drawSprites() both within the draw loop and outside it. As @mwood alluded, you should only call it one time.

I notice you also have the text being written outside of the draw loop. Think about what the draw loop does, and what needs to happen in order for the text to be visible.

Hint: your student has all the correct blocks in place. They just need to rearrange them!

Let us know if you still need help beyond that.

–Michael K.

1 Like