CSD - Unit 3 Lesson 14

csdunit3

#1

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.


#2

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.


#3

@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