用express.js和socket.io托管游戏
#javascript #gamedev #socketio #express

我最近创建了一个模板,您可以在Socket.io的帮助下在Express.js中托管游戏。

GitHub logo VulcanWM / host-game-expressjs

用socket.io在express.js中托管游戏的模板

Hosting Games with Express.js and Socket.io

This is a template where you can host games in Express.js with the help of Socket.io.

All Pages

  • koude2: has a link to the join game page and the host game page
  • koude3: generates a game id and creates a game which others can play the game. The host can decide when to start the game and this triggers a change in Socket.io which changes. the content on the player's screens
  • koude4 contains a form in which you have to enter your game id
  • koude4 (koude6): redirects you to koude7
  • koude7: renders a page where you enter your nickname for the game
  • koude9 (koude6): the user's game id and nickname gets saved to the session and then they get redirected to koude11
  • koude11: the play screen is rendered, and the screen is updated whenever a new…

这些都是模板具有的所有页面:

  • /:具有指向加入游戏页面和主机游戏页面的链接
  • /host:生成游戏ID并创建一个游戏可以玩游戏的游戏。主机可以决定何时开始游戏,这会触发更改socket.io的更改。玩家屏幕上的内容
  • /join包含您必须输入游戏ID
  • 的表格
  • /joinPOST):将您重定向到/join/[game_id]
  • /join/[game_id]:渲染一个页面,您可以在其中输入游戏的昵称
  • /join/[game_idPOST):用户的游戏ID和昵称将保存到会话中,然后将其重定向到/play1111
  • /play:播放播放屏幕,并且每当触发新的插座事件时,都会更新屏幕

确保检查一下,如果您有任何建议,请通过下面的评论让我知道!