Movesprite: Difference between revisions
Hunter byte (talk | contribs) mNo edit summary |
Velocity calculation example |
||
(6 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
movesprite < | '''movesprite''' <[[sprite id]]> <xvel> <yvel> <zvel> <[[clipmask]]> <returnvar> | ||
''This page is incomplete. Please help us by filling in additional information.'' | |||
movesprite gives the capability to move an [[actor]] along an arbitrary x, y, or z velocity and adjust the [[clipmask]] used, thereby changing what the actor will collide with. The variable <returnvar> will equal [[htmovflag]], which will be either 0 or the id of what was hit. This is sectioned by different areas of the struct. <s>Add 16384 to <returnvar> to get the result of the sprite structure member that may have been hit for example.</s> | |||
'''Critical notes:''' It is possible that <zvel> will be non-functional unless "fall" is called immediately before movesprite. Also movesprite and [[move]] commands do not mix well. You are likely to get unintended results. | |||
===Calculating appropriate velocity values=== | |||
With the regular move command we can simply pass in a horizontal speed value, but for movesprite we need to separate this into velocities on the x and y axis. | |||
Here's one method of doing this: | |||
<pre> | |||
defstate movesprite_state | |||
geta[].ang angvar | |||
cos my_cos angvar | |||
sin my_sin angvar | |||
// divide or multiply the cos and sin values to change the speed. | |||
// default result is already quite fast so you probably want to divide (shiftr) | |||
shiftr my_cos 4 | |||
shiftr my_sin 4 | |||
movesprite THISACTOR my_cos my_sin zvel CLIPMASK0 RETURN | |||
ends | |||
</pre> | |||
[[Category:EDuke32 specific commands]] | [[Category:EDuke32 specific commands]] | ||
[[Category:Sprite manipulation]] | [[Category:Sprite manipulation]] |
Latest revision as of 16:53, 3 December 2020
movesprite <sprite id> <xvel> <yvel> <zvel> <clipmask> <returnvar>
This page is incomplete. Please help us by filling in additional information.
movesprite gives the capability to move an actor along an arbitrary x, y, or z velocity and adjust the clipmask used, thereby changing what the actor will collide with. The variable <returnvar> will equal htmovflag, which will be either 0 or the id of what was hit. This is sectioned by different areas of the struct. Add 16384 to <returnvar> to get the result of the sprite structure member that may have been hit for example.
Critical notes: It is possible that <zvel> will be non-functional unless "fall" is called immediately before movesprite. Also movesprite and move commands do not mix well. You are likely to get unintended results.
Calculating appropriate velocity values
With the regular move command we can simply pass in a horizontal speed value, but for movesprite we need to separate this into velocities on the x and y axis. Here's one method of doing this:
defstate movesprite_state geta[].ang angvar cos my_cos angvar sin my_sin angvar // divide or multiply the cos and sin values to change the speed. // default result is already quite fast so you probably want to divide (shiftr) shiftr my_cos 4 shiftr my_sin 4 movesprite THISACTOR my_cos my_sin zvel CLIPMASK0 RETURN ends