Today I'm publishing a new open-source library for creating games: Replay.
I've built many indie games over the years (such as The Impossible Game). I've also built many web apps using React.
Replay takes the ideas and concepts that makes React such a great library for building user interfaces, and brings them to game development. Take a look at how Replay manages state and rendering through a declarative API:
const Player = makeSprite({
init() {
// Initial state
return {
posX: 0,
posY: 0,
};
},
loop({ state }) {
// Return new state at 60 fps
return {
posX: state.posX + 1,
posY: state.posY + 1,
};
},
render({ state }) {
// Draw a circle based on current state
return [
t.circle({
position: {
x: state.posX,
y: state.posY,
},
color: "#147aff",
radius: 10,
}),
];
},
});
Check out the docs on how to quickly get setup with a new JavaScript or TypeScript project, and then deploy to the web or iOS.
I hope you enjoy using it to build some new games!
Top comments (9)
Nice, any examples/live demos?
I’ve got a tutorial with a live demo coming soon, I’ll keep you posted :)
There’s now a tutorial here: replay.js.org/tutorial
And list of games here: replay.js.org/games
nice looks awesome thanks!
I've been searching my whole week for something like this!!!! Was studying (and enjoying) Phaser, but was kinda lost on how to organize the code and reason about the game loop. Will definitely check this out!
After searching for hours for the right JS game engine for our JS game hackathon that we are doing, I found replay, Damn what a great simplicty!
Everything is written pure and clean, really loved it!
I'm going to play with this a little.
Yes!!! Thank you!
This is very nice. I am working on a game with a canvas. Am certainly gonna give this a try when it's a bit further down the road. (Wanna see if I can make it myself first 😉)