Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
universal-game-controller
Advanced tools
Readme
Simple game input for 💻 keyboard, 📱 touchscreen and 🎮 gamepad through a unified API. Made for game jams.
Current game inputs are:
Constraining? That’s where creativity starts! Never underestimate the power of simplicity – easy to learn is easy to love.
Demo: https://ugc.bloat.app
See importing instructions below.
All user inputs are provided as a state of the controller – no events as of now. These are meant to be read in the game update loop.
controller.move
: { x, y }
controller.trigger
: boolean
controller.type
: InputType
<script src="https://cdn.jsdelivr.net/npm/universal-game-controller@1.3.2/dist/main.js"></script>
const { controller } = UniversalGameController
npm install universal-game-controller
import { controller } from 'universal-game-controller'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/universal-game-controller@1.3.2/dist/main.js"></script>
</head>
<body>
<div id="instructions" style="font-family: sans-serif; width: 100%; text-align: center; font-size: 2em; padding-top: 0.3em;"></div>
<div id="container" style="border: 2vmin solid rgb(15, 31, 46); width: 80vmin; height: 80vmin; border-radius: 50%; position: absolute; left: calc(50% - 40vmin); top: calc(50% - 40vmin); display: flex; justify-content: center; align-items: center;">
<div id="output" style="border: 2vmin solid rgb(15, 31, 46); width: 40vmin; height: 40vmin; border-radius: 50%; transform: translate(0vmin); background-color: rgb(15, 31, 46); box-sizing: border-box;"></div>
</div>
<script>
const { controller, InputType } = UniversalGameController;
const output = document.querySelector('#output');
const instructions = document.querySelector('#instructions');
const gameLoop = () => {
const move = controller.move;
output.style.transform = `translate(${move.x * 25}vmin, ${move.y * 25}vmin)`;
if (controller.trigger) {
output.style.width = '60vmin';
output.style.height = '60vmin';
} else {
output.style.width = '30vmin';
output.style.height = '30vmin';
}
if (controller.type === InputType.KEYBOARD) {
instructions.innerText = 'Use WASD to move and space to trigger';
} else if (controller.type === InputType.TOUCH) {
instructions.innerText = 'Use one finger to move and another to trigger';
} else if (controller.type === InputType.GAMEPAD) {
instructions.innerText = 'Use the left stick to move and button 1 to trigger';
}
requestAnimationFrame(gameLoop);
}
gameLoop();
</script>
</body>
</html>
FAQs
Simple game input for touch screen, keyboard, gamepad and mouse
The npm package universal-game-controller receives a total of 4 weekly downloads. As such, universal-game-controller popularity was classified as not popular.
We found that universal-game-controller demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.