CSD Lesson 13 Bubble 2 Predict not working as I'd expect?

Am I mis-reading the code?
Seems to me that the balloon should only grow if I press the space bar.
If I just let it run and press nothing, it still grows.
If I press the space bar, it seems to shrink and then grow

1 Like

Hi Andrea,

When the program starts, the balloon will be flipped and scale up with a negative scale value. Once you press and hold the spacebar the balloon will decrease in size, flip upright and begin to increase in size. This happens when the condition is true. When you release the spacebar, the balloon decreases in size because the condition is false.

I hope this makes since,

1 Like

I’m afraid I’m still not following.
What part of the code is making it flip?
To me, the IF statement
if (keyDown(“space”)) {
balloon.scale = balloon.scale + 0.02;

would make the balloon grow - the else would make it shrink.

But if I do nothing it still grows.

You may need to provide more context.

function draw() {
if (keyDown(“space”)) {
} else {
balloon.scale=min(1, balloon.scale-0.02);

I too am not following this…

I just figured it out… when the space isn’t pressed, the scale is decreasing… so as soon as it starts running the scale is going down… when the scale goes negative, the balloon turns upside down… then it gets MORE negative when you’re not pressing the space bar which actually makes it just larger and upside down… this is a TERRIBLE example for students and I’m going to skip it!!! An additional condition inside of the negative block for scale greater than 0 would make more sense!

1 Like