Lightweight web game framework inspired by LÖVE.
LIKE is a cozy way to make 2d games for browser.
lineCap.Vector2 and Rect are just number tuples (arrays), but a pure-functional library makes them easy to work with and plays nice with map and reduce.Most package managers will work.
npm install like2d
# or ...
deno add jsr:@like2d/like
# or...
To try Like2D quickly, use this starter with hot reloading and a basic webpage.
npx degit likeOrg/Like2D/examples/starter my-game
HTML that puts LIKE in fullscreen.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
html {
margin: 0;
height: 100%;
overflow: hidden;
}
body {
margin: 0;
height: 100%;
display: grid;
place-items: center;
background: black;
}
</style>
</head>
<body>
<script type="module" src="./src/main.ts"></script>
</body>
</html>
TypeScript:
import { createLike } from "like2d";
const like = createLike(document.body);
like.load = () => {
like.canvas.setMode([800, 600]);
like.input.setAction("jump", ["Space", "BBottom"]);
};
like.update = (dt) => {
if (like.input.justPressed("jump")) {
console.log("Jump!");
}
};
like.draw = () => {
like.gfx.clear([0.1, 0.1, 0.1, 1]);
like.gfx.circle("fill", "dodgerblue", [400, 300], 50);
like.gfx.print("white", "Hello Like2D!", [20, 20]);
};
await like.start();
LIKE's API is not the same as LOVE, but similar in spirit. Notable differences:
[x, y]) instead of loose coordinates.input.setAction / actionpressed and actionreleased callbacks.MIT