Guest User

Untitled

a guest
Jun 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. ;; In the scene dsl:
  2.  
  3. ;; Put the stickpoint wherever you want the thing to be in the world.
  4. (@stickpoint
  5. ((transform :translation/current (vec3 <x> <y> <z>)))
  6.  
  7. ;; THis is the thing we're going to move around.
  8. (@ball ((transform)
  9. (ball-mover :scale 1))))
  10.  
  11.  
  12.  
  13. ;; Then we need a componnet on the @ball
  14.  
  15. (define-component ball-mover
  16. ((scale :default 1)
  17. (transform :default nil)))
  18.  
  19.  
  20. (defmethod initialize-component ((component ball-mover) (context context))
  21. (with-accessors ((actor actor) (transform transform)) component
  22. (setf transform (actor-component-by-type actor 'transform))))
  23.  
  24. (defmethod update-component ((component ball-mover) (context context))
  25. (let* ((x (get-gamepad-axis context :gamepad1 :left-horizontal))
  26. (y (get-gamepad-axis context :gamepad1 :left-vertical))
  27. (movement-vec
  28. (v3:scale (v3:make (* x (sqrt (- 1 (* y y .5))))
  29. (* y (sqrt (- 1 (* x x .5))))
  30. 0)
  31. (scale ball-mover))))
  32.  
  33.  
  34. ;; Then, just overwrite the ball's position in relation to the @stickpoint
  35. ;; parent. And it'll move like how you desire.
  36. (v3:copy! (translate (transform component)) movement-vec)))
Add Comment
Please, Sign In to add comment