Linkworlds (WIP name) is a tildetown project to link several games together and pass player data around.
Let's say that there are different rooms. Each room is it's own independent webpage.
A player can move and play within a room, and when entering some kind of portal, the player goes to another room, giving that room the current player data.
Example setup (pseudo-javascript):
function main(){
gameData = JSON.parse(localStorage.getItem("linkworlds"))
player = new Player(storedData.player)
}
function changeToRoom(link){
save()
document.location = link
}
function save(){
gameData = Object.assign(gameData, {player: player.getData()})
localStorage.setItem("linkworlds", JSON.stringify(gameData))
}
class Portal {
link = "https://tilde.town/~troido/linkworlds/otherroom.html"
}
class Player {
constructor(playerData){
// playerdata in this case represends all data that is passed between rooms
// this is stuff like the inventory
this.inventory = playerData.inventory
this.x = START_X
this.y = START_Y
this.data = playerData
}
collidesWithPortal(portal){
changeToRoom(portal.link);
}
getData(){
return Object.assign({}, this.data, {inventory: this.inventory})
}
}