Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. the way i do it is
  2. hands are part of an array
  3. how you handle this array is up to you, really, but mine's defined like so
  4. for(var i = 0; i <= 1; i++)
  5. {
  6. handx[i] = 0
  7. handy[i] = 0
  8. handspd[i] = 0
  9. handgoalx[i] = 0
  10. handgoaly[i] = 0
  11. handrot[i] = 0
  12. handgoalrot[i] = 0
  13. }
  14. handx and handy are the position of a hand relative to the player's x and y position, rather than their position in the world
  15. handspd pertains to how fast a hand can move in a given animation, used in a lerp function
  16. handgoalx and handgoaly are the position the hands want to move to
  17. handrot is the hand's rotation
  18. handgoalrot is the rotation the hand wants to achieve
  19. setting a hand's position is handled with a script
  20. mine is ///hand_pos_set(hand_index,x,y,speed,rot)
  21. hand_index refers to which hand you're setting a position for, x and y set the goal x and y, speed sets handspd, rot sets handgoalrot
  22. if you really wanted you could add a handrotspd variable but i didn't find it necessary for my purposes here
  23. this entire code block handles hands
  24. //"hand"le hands hahaha
  25. for(var i = 0; i <= 1; i++)
  26. {
  27. if round(handx[i]) != handgoalx[i]
  28. {
  29. handx[i] = lerp(handx[i],handgoalx[i],handspd[i])
  30. handy[i] = lerp(handy[i],handgoaly[i],handspd[i])
  31. //handrot[i] = point_direction(handx[i],handy[i],handgoalx[i],handgoaly[i])
  32. }
  33. if round(handx[i] = handgoalx[i])
  34. handspd[i] = 0
  35.  
  36. var _diff = angle_difference(handrot[i],handgoalrot[i])
  37. handrot[i] -= 0.25 * _diff
  38. }
  39. there might be better ways of handling this
  40. but this is how i do it
  41. from here, drawing hands is simple
  42. i layer hand 0 behind the player, and hand 1 in front of the player
  43. //draw back hand and player
  44. draw_sprite_ext(_handindex,1,x+handx[0],y+handy[0],right,1,handrot[0],c_white,1)
  45. draw_sprite_ext(sprite_index,image_index,x,y,right*hsquash,vsquash,rot,c_white,1)
  46.  
  47. //draw front hand and weapon
  48. draw_sprite_ext(wep_sprt[wep],0,x+handx[1],y+handy[1],right,1,handrot[1],c_white,1)
  49. draw_sprite_ext(sprHand,0,x+handx[1],y+handy[1],right,1,handrot[1],c_white,1)
  50. i should note that _handindex is something that pertains to a hand's sprite index. there's only one case where a hand's sprite index changes for me so far, but it's probably smart to build a system around that too
  51. was that good enough of an explanation
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement