Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. this.state = {
  2. board: [
  3. [null, null, null, null],
  4. [null, null, null, null],
  5. [null, null, null, null],
  6. [null, null, null, null]
  7. ]
  8. }
  9.  
  10. // x & y are the coordinates of the 2d array
  11.  
  12. this.setState({
  13. board: update(this.state.board, {
  14. [x]: {
  15. [y]: { $set: { id, player, x, y, waitingToBeSelected } }
  16. }
  17. })
  18. });
  19.  
  20. this.state = {
  21. board: [
  22. [null, null, null, null],
  23. [null, {id: 21, player: "p1", waitingToBeSelected: false, x:1, y:1}, null, null],
  24. [null, {id: 42, player: "p1", waitingToBeSelected: false, x:2, y:1}, null, null],
  25. [null, null, null, null]
  26. ]
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement