jCtapuk
jCtapuk•4mo ago

joinplayroom

I have to use joinplayroom and convex. The reason for each function call is 60 fps is expensive. Are you planning such functions of rooms as before without a database to make it cheaper?
8 Replies
jCtapuk
jCtapukOP•4mo ago
PS Something like Nakama, you write the code and the state of the players, and on the site you will see all the state of the room and the players, and inside they can access the function that is mutating. I understand that it will be difficult, but there will be more demand 🙂 Such as card games or chess games, etc. Instead of constantly querying from the database which is not needed for the state of the game
v
v•4mo ago
Would be epic
jCtapuk
jCtapukOP•4mo ago
//convex/match.ts
export battle = match({
async init(ctx) {
ctx.runMutatuin(...)
return { state: {
players: []
},
tickRate: 60 // 60 tick / sec,
limitSessions: 10 // limit connect match
}
},
join(ctx) {
ctx.getSessionId() // or getUserId (auth valid)
ctx.state.players.push(ctx.getSessionId())
},
leave(ctx) {

},
tick(ctx) {
// update logic game match
}
})
//convex/match.ts
export battle = match({
async init(ctx) {
ctx.runMutatuin(...)
return { state: {
players: []
},
tickRate: 60 // 60 tick / sec,
limitSessions: 10 // limit connect match
}
},
join(ctx) {
ctx.getSessionId() // or getUserId (auth valid)
ctx.state.players.push(ctx.getSessionId())
},
leave(ctx) {

},
tick(ctx) {
// update logic game match
}
})
This is just a rough sample code. And the site will display all the status of the match that is active
v
v•4mo ago
my toes are curling
jCtapuk
jCtapukOP•4mo ago
and the client will simply connect to the match
import { match } from "../convex/_generated/match"
const room = client.match(match.battle)

room.onStateUpdate() // more idea
import { match } from "../convex/_generated/match"
const room = client.match(match.battle)

room.onStateUpdate() // more idea
ballingt
ballingt•4mo ago
There are no immediate plans for cheaper ephemeral state running at 60fps in Convx. Using playroom with Convex sounds great! As seen with things like https://www.convex.dev/ai-town you can certainly build game-y things with Convex but Playroom looks like it's built for this.
AI Town
A virtual town where AI characters live, chat and socialize
jCtapuk
jCtapukOP•4mo ago
@ballingt but that's the point when the player sends 60 times per second that 1 million functions are already exhausted in a couple of minutes. I already checked about ai-town)) otherwise I would have written long ago)
jCtapuk
jCtapukOP•4mo ago
Well, I almost did it and it works, but the authoritative one has to be given to the host client. But then I’ll make sure that I take over the authoritative match on the server
No description