Skip to content

Commit

Permalink
hotfix device ratio
Browse files Browse the repository at this point in the history
  • Loading branch information
da-in committed Apr 6, 2024
1 parent 59d55da commit 0eca01f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/hooks/use-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const usePlayer = (

const addBlock = () => {
// currentBlock = createBlock(9, width / 2, 60, ratio, true)
currentBlock = createBlock(nextBlockRef.value, width / 2, 60, ratio, true)
currentBlock = createBlock(nextBlockRef.value, width / 2, 60 * ratio, ratio, true)
isSetBlock = false
World.add(engine.world, currentBlock)
setNextBlock()
Expand Down Expand Up @@ -178,7 +178,7 @@ export const usePlayer = (
if (!currentBlock || isSetBlock) {
return
}
Body.setPosition(currentBlock, { x, y: 60 })
Body.setPosition(currentBlock, { x, y: 60 * ratio })
}

const endGame = () => {
Expand Down
13 changes: 7 additions & 6 deletions src/utils/set-field.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
import {Bodies, Composite, World} from 'matter-js'
import { Bodies, Composite, World } from 'matter-js'

export const setField = (world: World, width: number, height: number) => {
const bottom = Bodies.rectangle(width / 2, height, width, 30, {
isStatic: true,
restitution: 1,
render: {fillStyle: '#81685A'}
render: { fillStyle: '#81685A' },
})
const left = Bodies.rectangle(0, height / 2, 1, height, {
isStatic: true,
render: {fillStyle: '#FFFFFF'}
render: { fillStyle: '#FFFFFF' },
})
const right = Bodies.rectangle(width, height / 2, 1, height, {
isStatic: true,
render: {fillStyle: '#FFFFFF'}
render: { fillStyle: '#FFFFFF' },
})
const line = Bodies.rectangle(width / 2, 120, width, 2, {
const ratio = height / 560
const line = Bodies.rectangle(width / 2, 110 * ratio, width, 2, {
isStatic: true,
isSensor: true,
label: 'line',
render: {fillStyle: '#FF6C6C'}
render: { fillStyle: '#FF6C6C' },
})
Composite.add(world, [line, bottom, left, right])
}

0 comments on commit 0eca01f

Please sign in to comment.