How can I fix this?

helpwithcode

#1

I am making like this story thing, I want to make star girl move right 100 and then flip like someone barges in and she looks at the person and moves back kind of. But, instead what happens is she redoes it over and over again, quickly moving across the screen flipping back and forth, why is this happening? This is the very simple code I put in:


#2

By the way, I tried switching the blocks but the same thing happened. HELP


#3

You Have To Do Negative 100 Like This -100 :wink:


#4

I Think... Hmmmmmmmmmmm


#5

No, she goes to the right, and I believe that would make her go left. But I'll try it anyways!


#6

Nope, she does the same thing, just going to the left. I want her to turn and back up. As in go to the right. NOT the left.


#7

I can help with this @Hoppertoscotch! The Change X by and Change Y by blocks do not work with the flip block, as flipping does not affect what increasing or decreasing the X or Y position of a character means, and that is exactly what the Change X by and Change Y blocks do. However, the Move Forward block does work with the flip block, so if you replace your Change X by block with a Move Forward block, it should work. :blush:


#8

Will star girl still go to the right when she flips?


#9

@Mathgirl I tried doing that, it still doesn't work. Star girl just kind runs back and forth. Left, right, left, right. HEEEELLLLPPP!!!!


#10

Oops, I thought that was what you wanted it to do, but I must have misread your post. I reread it, but I don't see what went wrong, your code looks fine to me.


#11

@Hoppertoscotch this is a great question and great description of the problem. And @Electronixguy and @Mathgirl good points with the -100 and Move Forward block and I was thinking the same thing.

Let's look at it in more detail and plan it step-by-step :smiley: This makes it easier for us to know what we have to code and see what could be going wrong.

I just have one question though: What is the When at the top of the rule? e.g. When the play button is tapped, When iPad is tapped, When __ equals __ etc. It looks like you've got something that keeps repeating and keeps getting triggered, and that's why the code keeps repeating.

So is this what you want Star Girl to do:

Star Girl starts facing right
She moves forward to the right 100
She flips and faces the left, to where someone has barged in
She moves backwards to the right, but still faces left to the person

#12

When a value equals 1


#13

No, I don't mean that, I meant in to discriptions. #1: star girl is facing right and moves right then flips #2 star girl flips and moves right, as in, walking backwards. There was a typo in my first question.


#14

So pretty much want her to do what anyone would do if they were suddenly interrupted, or some barged in. Sorry about the typo.


#15

Oops, meant to say someone, not some.


#16

@t1_hopscotch here is a better picture of the code:


#17

That's okay, that's why I wanted to make clear :smile:

So the code for that would be:

Change X by 100
Flip

And the next step:

Flip
Change X by 100

And ah yes I thought it would be something like When ___ equals ____. It's because the whole time while the Value equals 1, Star Girk will repeat this code. If you only want her to run this code once, add this to the bottom of the rule:

Repeat Forever
    Wait
End

That means Star Girl will run the code once and wait forever, and she won't run it again.

Let me know if you need to clarify something


#18

thanks so much! Let me see if that works....


#19

Ok it works, thanks again, @t1_hopscotch! You're such a big help! Now I can finally continue this!


#20

For Star Girl to move to the right make a rule that does what the screenshot does