Unit 3 Lesson 19 - order of code

Doe it matter if the BACKGROUND is before an IF THEN or after it? In this case the student has the IF/THHEN conditional action taking place before the background is coded in the program. It does not make a difference when running, but it seems like it should. In the exemplar provided for the teacher it is the other way around.


In this case, it doesn’t matter as this is a fairly simple animation. The order of code in the draw loop does make a difference, though, especially if you have a lot going on. For example, if you have text, it should be drawn after the background or the background will cover it up.

I think it’s generally preferred that the background be first (the bottom layer), so if there are problem with the code, that’s one of the things I look at.

In this case, you are drawing a single sprite, than a background and then the sprite and then the background, so it doesn’t make that much of a difference.