
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
screen-shake
Advanced tools
Screen shake for JavaScript / TypeScript games
Based on this GDC talk by Squirrel Eiserloh
Perlin noise and exponential trauma for a more satisfying shake700b and 0 dependenciesYou first need to create an instance by using the default export
import createScreenShake from 'screen-shake'
const screenShake = createScreenShake()
Configuration options
createScreenShake({
// The maximum amount of angle movement.
maxAngle = 12,
// The maximum amount of x offset movement.
maxOffsetX = 70,
// The maximum amount of y offset movement.
maxOffsetY = 70,
// The amount of updates until trauma goes from 1 to 0
duration = 28,
speed = 0.4,
// Set this for a predictable screen shake (useful for tests)
seed,
})
The screen shake instance has two methods:
(trauma: number) => void
How much trauma to add between 0 and 1 (equal to 100% trauma).
(time: number) => ({ angle: number, offsetX: number, offsetY: number })
Call this on every update of your game loop.
Has one argument, the time since update was first called. (This is used to smoothly interpolate the noise)
Returns an object with the values to add to your camera:
angle - Add it to the cameras angleoffsetX - Add it to the cameras x positionoffsetY - Add it to the cameras y positionimport createScreenShake from 'screen-shake'
// Create the instance. Configuration is optional.
const screenShake = createScreenShake()
if (projectileHit) {
// Add 10% trauma when hit
screenShake.add(0.1)
}
let time = 1
gameLoop(() => {
const { angle, offsetX, offsetY } = screenShake.update(time)
camera.angle = camera.angle + angle
camera.position.x = camera.x + offsetX
camera.position.y = camera.y + offsetY
time++
})
npm install screen-shake
FAQs
Screen shake for JavaScript / TypeScript games
The npm package screen-shake receives a total of 0 weekly downloads. As such, screen-shake popularity was classified as not popular.
We found that screen-shake demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.