i've been given this to program in but i cant o it to save my life
Place the sprite at x:0 and y:170
So long as the y position of sprite is greater than or equals to -175 it should move down the stage in 1 step intervals.
To my mind if the sprite's y position is equal to -175 it should continue to move and end up at -176.
Later on i am told that the sprite should not exceed -175
How can the sprite be equal to -175 and still move 1 place down but not exceed -175.
Offline
It can't move down from -175 and still not exceed -175. Minus that part, the script would look like this:
I always use the wait block when I am animating something or moving a sprite because otherwise it looks like it just jumps from place to place instead of actually moving there.whenclicked
go to x:0y:170forever ifory position>-175y position=-175change x by-1wait0.01secs
Last edited by shivadas (2013-03-30 21:35:41)
Offline
still cant get it to work
Offline
when you fall by more than 1 pixel per step, you have the possibility of overshooting -175; in that case, you would use an "if else" statement to set it back:
whenclicked
go to x:0y:170setfalling speed ▼to-1foreverify position>-175change y byfalling speedelseset y to-175
Offline
xlk wrote:
you just used a variable for no reason...
that would only be usefull to simulate gravity, if you added a "change falling speed by -1" block.
Still, he did say 1 step intervals, so why bother about overshooting?
sorry... i'm new here and am learning about the forum by trying it out. have mercy.
i had a couple reasons for the variable but i was probably directing my statements at the people who said the "do not exceed" instruction didn't make sense and less to the original question (i probably should have made that more clear).
i used it because variables can vary, even when they don't. so though it does nothing, it suggests a lot: it suggests other cases for which the variable takes other values (which is what i was trying to point out). i figured this was probably an early assignment (on simplistic gravity) and that more would follow (on realistic gravity).
i probably should have thought twice about that.
Offline
If this question is about a homework assignment for a class - please make sure that asking for help on the Scratch forums doesn't violate any agreements you have with the teaching institution.
Offline