Sprite specific mouvement

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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?
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
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
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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 ==.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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~
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
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
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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?
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
EDIT : Nope is not working at all ....
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
What's this bit?

Code:
end if Sprite.x != pos
Get rid of the if and just leave the end on its own.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
Ho okai~ it is explain everything~
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
All working now?
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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 ?)
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
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
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
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.
 

Mike

Veteran
Veteran
Joined
Aug 28, 2013
Messages
316
Reaction score
36
First Language
English
Primarily Uses
Is that how RGSS parse ruby? I hope not. .-.

Edit:

I just tested it on ruby 1.9.2, it's parsing fine.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,072
Members
137,578
Latest member
JamesLightning
Top