Advertisement
otorp2

state machine countdown from 20

Dec 25th, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1.  
  2. extends Node2D
  3.  
  4. var PLAYERSTATE_PREV = ""
  5. var PLAYERSTATE = ""
  6. var PLAYERSTATE_NEXT = "ground"
  7. var x = 20
  8. func _ready():
  9. set_process(true)
  10. pass
  11. func _process(delta):
  12. PLAYERSTATE_PREV = PLAYERSTATE
  13. PLAYERSTATE = PLAYERSTATE_NEXT
  14.  
  15.  
  16. if PLAYERSTATE == "ground":
  17. print(PLAYERSTATE)
  18. ground_state(delta)
  19. elif PLAYERSTATE =="air":
  20. air_state(delta)
  21.  
  22. func ground_state(delta):
  23. x -= 1
  24. print(x)
  25. if x < 10:
  26. PLAYERSTATE_NEXT = "air"
  27. x = 20
  28.  
  29. func air_state(delta):
  30. x = x - 1
  31. print(x)
  32. print("air!")
  33. if x < 1:
  34. PLAYERSTATE_NEXT = "ground"
  35. x = 20
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement