Advertisement
otorp2

state machine godot

Mar 15th, 2016
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1.  
  2. extends Node2D
  3.  
  4. var x = 0
  5. var y = 0
  6. var speed = 1
  7. var state = 0
  8.  
  9.  
  10. func _ready():
  11. set_process(true)
  12.  
  13. pass
  14. func _process(delta):
  15. update()
  16.  
  17. func _draw():
  18. # x = x + speed
  19. draw_circle(Vector2(x,10),10,Color(255,255,255))
  20. if state == 0:
  21. x = x + speed
  22. if x > 200:
  23. x = 200
  24. state = 1
  25. elif state == 1:
  26. x = x - speed
  27. if x < 0:
  28. x = 0
  29. state = 0
  30.  
  31. print(x)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement