基于文本的浏览器游戏

发布于 2024-08-05 08:58:49 字数 124 浏览 7 评论 0原文

我想创建一个基于文本的浏览器游戏,那么我应该怎么做呢?我可以用 asp、jsp 或 php 进行编程,这不是障碍,但我不知道在尝试制作此类游戏时需要遵循哪些步骤。所以请指导我。

还请推荐我一种编程语言来制作同样的东西。

I wanted to create a text based browser game, so how should I go about? I can do programming in asp or jsp or php that is not a barrier, but I am unaware of what steps that one needs to follow while attempting to make such games. So please guide me.

please also recommend me a programming language for making the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

っ左 2024-08-12 08:58:49

最简单的浏览器游戏之一只是一系列静态页面,每个页面上都有指向其他页面的链接。页面上通常会出现一些“故事”,然后您可以做出一些选择。不同的选择会导致不同的页面。

下一步是使用动态页面。当加载新页面时,浏览器可以向服务器发送一些变量,服务器可以动态生成页面。这节省了您手动创建大量相似页面的精力,并且还允许您执行诸如随机结果之类的操作。

但是,如果您想保留大量用户状态(例如库存、技能或其他内容),那么不断地将其从服务器传递到浏览器再到服务器就会变得很麻烦(并且不安全)。这就是会话处理的用途:它会记住用户一段时间,并让您记住服务器端的一些变量。

如果您想要一个更具交互性的游戏,您需要研究 Javascript,也许还有 AJAX,它们允许在浏览器中更改内容,而无需加载新页面。

就语言而言,我建议使用Python CGI,因为我喜欢Python。从简单的事情开始,这样您就可以在设计大型项目之前更好地了解正在处理的内容。

玩得开心!

One of the simplest browser games is just a series of static pages with links on each page leading to other pages. Often there will be some "story" on the page followed by a few choices you can make. Different choices lead to different pages.

The next step up is to use dynamic pages instead. When loading a new page, the browser can send some variables to the server and the server can generate a page on the fly. This saves you the effort of creating lots of similar pages by hand, and also allows you to do things like random outcomes.

However, if you want to keep a lot of user state (such as inventory, skills, or whatever), it becomes cumbersome (and insecure) to continually pass this from server to browser to server. This is what session handling is for: it remembers a user for a while, and lets you remember some variables at the server side.

If you want a more interactive game, you would need to look into Javascript and perhaps AJAX, which allow things to change in the browser without needing to load a new page.

In terms of language, I would suggest Python CGI, 'cause I like Python. Start with something simple so you can get a better idea of what you're working with, before you design something large.

Have fun!

北风几吹夏 2024-08-12 08:58:49

听起来你可以使用状态机(以你选择的任何语言)来映射它......可能是一个有趣的小项目(:

Sounds like you could map it out using a state machine (in any of your chosen languages)...could be a fun little project (:

稀香 2024-08-12 08:58:49

创建一个地图 - 基本上是一个二维的“房间”数组 - 或者,如果你需要让你的角色上下移动,你也可以将其制作成三维......

然后在游戏中,当玩家将角色移动到南方时,只需在数组中找到该房间即可。

数组可以包含与房间相关的所有必需内容(描述、对象、NPC 等)

create a map - basically a two-dimensional array of "rooms" - alternatively you can make it three dimensional if you need to have your character go up and down as well...

then in the game when the player moves character to the south, just find that room in the array.

array could contain all required things related to the room (description, objects, NPCs etc.)

以可爱出名 2024-08-12 08:58:49

就我个人而言,我会用 python 制作一个基于文本的游戏,然后让它与网络服务器对话。这样你就可以轻松地测试游戏。

您想写什么类型的游戏?

您还必须考虑用户可能会做什么。他们可以复制窗口并发送相同的信息两次。他们可以点击返回,这可能会扰乱游戏。您可以让用户在每次单击“提交”时提交时间和会话 ID。

ps 连续传递样式是模拟调用返回功能的一种方法。但这并不是一种简单的写东西的方法。

Personally I would make a text based game in python and then get that to talk to a webserver. that way you can test the game without so much hassle.

What kind of game are you looking to write?

you have to think about what the user might do as well. They can duplicate their window and send the same information twice. They can click back which might mess up the game. You could get the user to submit the time and a session ID each time they click submit.

p.s. continuation passing style is one way to emulate the ability to call an return. It's not an easy way to write things though.

無處可尋 2024-08-12 08:58:49

设计。实施。测试。玩。

如果是基于文本的浏览器游戏,则应该使用 HTML。 :)

Design. Implement. Test. Play.

If it is a text-based browser game, you should go with HTML. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文