Skip to content

Commit

Permalink
blocks updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Maoyeedy committed Sep 22, 2024
1 parent aa99468 commit bae791b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ I have to admit that it's pretty painful to setup collision without [p5play](htt
- `O`
- `P`
- `R` to reload

<!-- ### Notes -->
<!-- I made a bug, which lead to player1 not able to push blocks, but turns out it works better. So now, player1 can only walk in shadow, and player2 can only push blocks. -->
10 changes: 6 additions & 4 deletions sketchTwoPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ function setup () {
player2Pos = createVector(-3, -3)

blocks.push({ position: createVector(0, -3), height: 4 })
blocks.push({ position: createVector(3, -2), height: 3 })
blocks.push({ position: createVector(2, 3), height: 5 })
blocks.push({ position: createVector(3, -1), height: 3 })
blocks.push({ position: createVector(2, 4), height: 5 })

targetPosition = createVector(3, 4)
targetPosition = createVector(4, 4)
}

function draw () {
Expand Down Expand Up @@ -156,7 +156,8 @@ function mouseDragged () {
let deltaX = mouseX - lastMouseX
rotationDelta -= deltaX * rotateSpeed

rotationDelta = constrain(rotationDelta, -PI / 4 + 0.001, PI / 4 - 0.001)
// rotationDelta = constrain(rotationDelta, -PI / 4 + 0.001, PI / 4 - 0.001)
rotationDelta = constrain(rotationDelta, -PI / 2, PI / 2)
lastMouseX = mouseX
}
}
Expand Down Expand Up @@ -335,6 +336,7 @@ function updatePlayerPosition (currentPos, nextPos, isPlayer1) {
}
}

// https://poe.com/chat/3lttxnlbs7wkmiybel1 to make collision work on the other player
function handleCollision (nextPos, pushDir) {
let collidedBlockIndex = blocks.findIndex(block => block.position.equals(nextPos))

Expand Down

0 comments on commit bae791b

Please sign in to comment.