Advertisement
Runer112

Slide up

Apr 18th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Lbl Up
  2. .r₁=row scan offset
  3. .r₂=column scan index
  4. .r₃=column dest index
  5. .r₄=last value slid
  6. 0
  7. .For each row
  8. For(4)
  9. →r₁
  10. 0→r₄→r₃
  11. .For each column, starting from the right
  12. For(4)
  13. →r₂
  14. .If occupied by a tile
  15. If {+r₁+L₁}
  16. .Remove original tile
  17. Select(→r₅,0→{r₁+r₂+L₁})
  18. .If equal to the last slid tile
  19. !If -r₄
  20. .Increment merged tile value
  21. {r₁+r₃-4+L₁}++
  22. .If not equal to the last slid tile
  23. Else
  24. .Store tile to destination and decrement destination index
  25. Select(r₅,→{r₃+4→r₃+r₁-4+L₁})
  26. End
  27. .Store value last slid (or garbage if a merge occured)
  28. →r₄
  29. End
  30. r₂+4
  31. End
  32. r₁+1
  33. End
  34. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement