Sprite specific mouvement

Hello I just Wonder if it will be possible to use this kind of way for make a specific movement to a place to a another place

okai for be more clear I want it to move until a certain sector

def update_somethingSprite.x += 10 Case Sprite.x when sprite.x == 20 sprite.x = 20 else Sprite.x += 10endendI know it is a way to do but i am not sure...

I know you can also have the moghunter ways

def update_somethingSprite1 += 1Sprite2 =0case Sprite2if Sprite1 == 10Sprite2 +=10 if sprite1 == 20Sprite2 -= 20 else Sprite2 = 0 sprite1 += 1end end



























it is the way I know but I have a little bit difficulty with specific mouvement

















for me it is really something I have problem
well, possible...

btw, this makes no sense

Code:
when sprite.x == 20 sprite.x = 20
the .x is already 20 if the case is true so there's no sense in making it 20 again
well, possible...

btw, this makes no sense

when sprite.x == 20 sprite.x = 20the .x is already 20 if the case is true so there's no sense in making it 20 again
Well I notice that after I checked xD  but what I need to correct for make it work well?
What exactly do you want to do anyways? make sure that he cannot go past 20 X?

Code:
def update_somethingSprite.x += 10 Sprite.x = 20 if Sprite.x > 20end
What exactly do you want to do anyways? make sure that he cannot go past 20 X?

def update_somethingSprite.x += 10 Sprite.x = 20 if Sprite.x > 20end
yep because I want the sprite to move to a certain place to a another place (i want to make like a a a Robotic door who open but i don't want to make Animation to much time and it is annoying me to do this I just  want to put two sprite

and aniways it is a opening for a shop scripts
If your sprite is at 15, he'll jump up to 25, and the sprite.x == 20 condition will never be met.


Use >= instead of ==.
If your sprite is at 15, he'll jump up to 25, and the sprite.x == 20 condition will never be met.

Use >= instead of ==.
ho this is make more sense..thank shaz and engr for the help I will check if the method work~
I would suggest making position and velocity to be dynamic.

And from my experience, RGSS does funky stuffs inside parameter assignment of certain classes, so it might be worthwhile to be 1 step ahead before assigning the value.

Code:
def getToPosition(velocity, pos)  if (Sprite.x + velocity) < pos    Sprite.x += velocity  else    Sprite.x = pos  end if Sprite.x != posend
I would suggest making position and velocity to be dynamic.

And from my experience, RGSS does funky stuffs inside parameter assignment of certain classes, so it might be worthwhile to be 1 step ahead before assigning the value.

def getToPosition(velocity, pos) if (Sprite.x + velocity) < pos Sprite.x += velocity else Sprite.x = pos end if Sprite.x != posend
Hoooo okai so in simple i need to add a another variable for make it more softer?
EDIT : Nope is not working at all ....
What's this bit?

Code:
end if Sprite.x != pos
Get rid of the if and just leave the end on its own.
Ho okai~ it is explain everything~
All working now?
Ho sorry I don't had the time to check it! (dammit school stuff)

I will check it tomorow !

what it was surprising Zal Also show me a another way to do it ~

@sprite.x += ((400 - @sprite.x)/Graphics.frame_rate).ceil

I think it is a good way for move the sprite to a certain location ?)
What's this bit?

end if Sprite.x != posGet rid of the if and just leave the end on its own.
It's the 'different' flag.

If the sprite position is not equal to the desired position, then do the assignment, else do nothing.

The 'different' flag is there to avoid re-assignment since assignment has more potential processing power usage than comparison.

You would often see assignment operator overload

alias a_mp= mp=def mp=(mp) do_more_stuffs(mp) a_mp=(mp)endrather than comparison operator overload

Code:
alias a_mp> mp>def mp>(mp)  do_more_stuffs(mp)  a_mp>(mp)end
There is no assignment. The statement says 'end if the condition is true'. That means sometimes you want to end, and sometimes you don't? The script works fine without that bit - I don't see any reason to have it there. TBH I didn't even think it was a valid statement - I'd have expected an error when running it.
Is that how RGSS parse ruby? I hope not. .-.

Edit:

I just tested it on ruby 1.9.2, it's parsing fine.

Original thread: https://forums.rpgmakerweb.com/threads/sprite-specific-mouvement.26310/