问题标签 [roguelike]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
146 浏览

python - 在 Python 上的 .txt 文件上写一个字符串矩阵

我正在用 Python 做 RogueLike 游戏,我使用 DungeonGenerator.py。在我的游戏中,我从 .txt 文件中读取了地牢。

问题是我无法将我用 DungeonGenerator.py 制作的地牢写在 .txt 文件上,因为它是一个字符串矩阵。

这是 DungeonGenerator.py 的结果示例:

地牢示例

我尝试:

显然瓷砖不是字符串。

谢谢指教!

0 投票
4 回答
128 浏览

haskell - 当我尝试返回列表时出错

现在我对代码进行了一些改进,剪掉了一些东西,等等。
这是源代码:

所以现在,当我尝试编译它时,我变成了这个错误:

据我了解,它试图返回一个列表的列表,但它不会导致:

但如果我写

相反,我收到此错误:

当我在没有 的情况下编写它时$,我得到了这个:

那么我怎样才能将它作为地牢类型返回呢?

0 投票
0 回答
92 浏览

python-3.x - 将函数及其参数存储在字典中

我不喜欢 if/elif 语句看起来有多难看。switch/case 语句也好不到哪里去。我发现字典更容易阅读。现在我知道如果每个键绑定到不同的功能时如何处理它,这很容易。但这需要 8 个不同的移动函数(moveNE、moveN、moveNW 等)。所以我想要一个简单的 move_object 函数,它将方向作为参数。但是,我在让这段代码正常工作时遇到了问题,而且我不确定我做错了什么。这是有问题的代码。

一、字典:

现在,move_object 函数:

最后,应该调用 move_object 函数的代码:

键绑定在 Game Class init函数中定义,最后的代码块发生在 Game.main_loop()

我已经阅读了几次教程,但我无法弄清楚我做错了什么。我认为我在这里所拥有的会将 args 字典作为 **keywords 传递给 move_object() 函数,但它给了我一个参数错误(预期 2 个参数,收到 1 个)。

0 投票
0 回答
308 浏览

c - 为 roguelike 地牢生成实现 BSP 树时遇到问题

我正在尝试使用此处描述的 BSP 为 roguelike 制作地牢生成器:Basic BSP

我对树结构有点陌生,我已经研究了一段时间,似乎真的无法弄清楚我哪里出错了。现在我有了它,所以它只会打印出所有“#”来表示每个叶节点的房间尺寸,这样我就可以看到它是否正常工作。我不断收到分段错误,我真的不确定我现在哪里出错了。如果有人可以查看我的代码并给我一些建议,我将不胜感激。谢谢!

0 投票
1 回答
849 浏览

c++ - I don't know how to manage my classes sturctures with SDL2

I try to create some C++ "rogue-like" game with SDL-2. For this I followed the Lazy foo's tutorial to understand how work with SDL.

I've studied C++/C# for 3 year but now I study project management and don't have no more IT courses...

Here's the github for the code : https://github.com/Paingouin/Roguelike-SDL2-train/tree/master/

I created 2 class : LTexture to help managing loading and rendering of a picture and Glyph to manage the animation/scaling and the positioning of the picture...

Now, I wanted create a Entity class, composed of a Glyph Object, which I would use to represent a Wall, a monster, an item etc... but, I think if I do that I will use too much memory...

Maybe I should use an aggregation by initialize an Array of pointer of Glyph and associate it to my Entity's object... I don't know, I'm lost...

Can you help me? And, have you any tips or advice to help me structuring correctly?

0 投票
1 回答
88 浏览

arrays - haskell 中 RL 的数组或列表

我正在用haskell(使用hscurses)做一点强化学习,现在,我编写代码来制作/打印地牢。

我做的第一件事是
在 python(v3) 中创建一个带有“墙”的列表/数组,它会是这样的:

它会像这样打印:

所以我的问题是:我怎样才能在haskell中做到这一点?我知道那里有模块Data.Array,但据我所知,它们只支持二维数组。
此外,数组必须是可变的,因为我必须稍后“挖掘”其中的房间和走廊。

但我的问题也是我应该使用数组还是列表更好?

提前致谢!

0 投票
2 回答
411 浏览

lua - How can I get values from multiple instances of a class?

I am making a roguelike in Love2D as a hobby project. My approach is to try and use as much of the native capabilities of Lua and the Love2D (0.10.1) API as possible, without relying on fancy libraries like middleclass or HUMP, so as to learn more about the language.

After reading PiL's chapters on OOP and seeing the power there, I decided to set up a Mob class (using metamethods to emulate class functionality) that encompasses the players, monsters, and other NPCs (anything that can move). So, far, it's working beautifully, I can create all kinds of instances easily that share methods and all that stuff. But there's a lot of things I don't know how to do, yet, and one of them is holding my prototype up from further progress.

Setting up collision with the map itself wasn't too bad. My maps are tables full of tables full of integers, with 0 being the floor. The game draws "." and "#" and "+" and such to denote various inanimate objects, from each table. Player 1 moves using the numpad, and their position is tracked by dividing their raw pixel position by 32 to create a grid of 32x32 "tiles". Then, inside love.keypressed(key), I have lines like:

and so on, with elseifs for each key the player can press. This prevents them from walking through anything that isn't an open floor tile in the map itself.

But, I'm trying to implement some kind of "collision detection" to prevent MOBs from walking through each other and to use in writing the rules for combat, and this is trickier. I had a method in place to calculate the distance between mobs, but I'm told this might eventually cause rounding errors, plus it had to be written for each combination of mobs I want to test, individually.

What I'd like to know is: Is there a known (preferably elegant) way to get all instances of a particular class to pass some number of values to a table?

What I'd like to do is "ask" every Mob on a given map where they are, and have them "report" self.grid_x and self.grid_y to another layer of map that's just for tracking mobs (1 if self.is_here is true, 0 if not, or similar), that gets updated every turn. Then, I could implement collision rules based on coordinates being equal, or maybe a foo.is_here flag or something.

I have only vague ideas about how to proceed, however. Any help would be appreciated, including (and maybe especially) feedback as to a better way to do what I'm trying to do. Thanks!

0 投票
2 回答
73 浏览

lua - 如何动态检索用于初始化实例的变量?

我正在尝试为 roguelike 实现基于速度的转向系统。我已经使用元方法设置了一个 Mob 类,因此将以下内容分配给一个变量将在某些网格坐标处将一个暴徒生成到地图中:

完成后,我调用以下命令:

这会将暴徒的 self.turn_counter 放入表中。同时,在另一个模块中,我定义了这两个函数,这是问题的核心:

我已经决定要初始化的前两个 Mob 实例将始终是玩家 1 和 2,分别分配给变量 player1 和 player2。而且,事实上,它可以很好地在玩家之间来回传递控制!但显然,这对于一个功能齐全的游戏来说是不够的。我也需要怪物。

allTurnCounters 表按顺序从每个生成的生物中获取新条目(一个包含玩家和怪物的类,因此它们可以共享统计信息)。这是我的问题: 如何让 Lua 动态检索与该表中给定的 turn_counter/value 关联的表的名称,并使用它来获得轮流优先级,即使在我不知道程序产生了什么的情况下也是如此提前或它将在生成顺序中占据什么位置?

我有 3 个想法,但我都不知道如何实施。一种方法是将整个实例表发送到另一个表,而不仅仅是它们的 turn_counter,然后以某种方式获取一对值(表本身和表中的 my_turn),直接更新 my_turn 的值。

另一种方法可能是使用环境 _G... 以某种方式。我仍在仔细研究 PiL 的第 14 章,试图使其适应我的目的,但 value = _G[varname] 似乎是我可以使用的强大代码。不知道如何,只是还没有。

我的最后一个想法是编写某种字符串感应查找替换,它可以在每个暴徒的表中获取一些其他值,然后将其弹出到 my_turn 的前面。就像,为每种暴徒类型分配一些具有已知模式的值,我可以在 string.find 和 string.gsub 中使用,以喜欢...手动使代码行按预期读取。不过,似乎不优雅。

我很幸运在这里问了我以前的 Lua/Love2D 问题,所以我想在我思考的时候把它扔出去!

0 投票
2 回答
245 浏览

python - Python中的Libtcod访问冲突错误

所以,像许多人一样,我正在阅读关于在 python 中使用 libtcod 的 roguelikes 教程。 http://www.roguebasin.com/index.php?title=Complete_Roguelike_Tutorial,_using_python%2Blibtcod,_part_3

我终于让一切都运行起来了,但是我在某个特定命令上遇到了错误,我不知道如何修复它或者它到底有什么问题。它似乎在教程中使用相同的命令工作,据我所知,我的代码实际上是相同的,并且我使用的是作者提供的下载链接。我的项目文件夹中有 libtcodpy、dundalk12x12_gs_tc.png、libtcod.dll 和 SDL2.dll(复制并粘贴)。如果您需要查看 .py 的其余部分,则只需查看教程第 3 部分地牢生成中的代码。它和我的一模一样,唯一我看不到的是他的 libtcodpy 文件夹,但这是他的下载链接。错误是:

问题在于调用 libtcod.console_set_char_background(con, x, y, color_dark_wall, libtcod.BKGND_SET) 时的 renderall 函数

这是库函数

libtcodpy 与 libtcod.dll 和 SDL2.dll 一起位于我的项目文件夹中。都是 64 位的,包括 python 和我在 64 位 windows 10 上的 PyCharm IDE。早先尝试 32 位,找不到 SDL2.dll。虽然我自己已经修复了这些东西。现在我无法弄清楚什么是错误以及如何在教程 XX 中重写它。抱歉,第一次在这里发帖,没有在另一个线程中看到确切的解决方案,但还有其他一些关于 SDL 问题和 32 位与 64 位的问题。

请给我找一个关于如何在 python 中正确设置 libtcodpy 的非常详细、防延迟的 youtube 视频,或者让我知道我在搞砸什么。

0 投票
1 回答
186 浏览

c++ - 如何让玩家使用 ncurses 库与 Monster 交互?

我一直在尝试使用 ncurses 库为 C++ 创建我的 roguelike 类型的游戏。在学习了许多不同的教程之后,我能够创建玩家角色、地图、防止玩家穿过墙壁的代码以及怪物角色的随机移动。

我遇到的下一个问题是实现一个布尔值,所以每当玩家角色与怪物角色交互时,游戏就会退出(很像 roguelike 游戏)。但是,我似乎无法让它以我想要的方式运行。我认为这与我为玩家和怪物设置的坐标有关,但我仍然不确定。谁能帮帮我?

这是代码: