在 Silverlight(或 WPF)中构建 Roguelike

发布于 2024-08-13 19:15:28 字数 1524 浏览 9 评论 0原文

我一直在考虑使用 Silverlight 构建基于 Web 的 Roguelike 游戏(或者可能只是使用 WPF 的桌面游戏)。

如果您不知道 Roguelike 是什么,它是一种图形角色扮演游戏,其中图形使用文本呈现。由于图形引擎相对简单,因此您可以花时间在游戏中构建功能,并且一个人可以快速构建一些有趣的东西。

例如,典型的屏幕可能看起来像这样(@是玩家,#是墙,其他角色是怪物、楼梯和物品等)

: net/xoJ0D.gif" rel="nofollow noreferrer">
(来源:thangorodrim.net

我'我是一名经验丰富的 ASP.Net 开发人员,但我刚刚开始使用 Silverlight。我应该为此采取特定的方法吗?

提供一些背景知识,在 Winform 中,大多数标准方法都太慢——文本最终以可见的、丑陋的闪烁结束更新。我认为与画布有关的东西可能是合适的,但更好的是以某种方式将屏幕绘制到缓冲区中,然后立即将其翻转到屏幕上,以便它立即可见。

但我现在真的不想摆弄 DirectX - 我希望 WPF 能够让我到达我需要的地方,而无需很大的学习曲线。

有什么想法吗?

更新:所以这非常具有挑战性。我尝试了很多不同的方法,我终于能够让它真正渲染得足够快,但我认为为了让它变得非常快,你可能应该构建一个你想要使用的字体的精灵图,并以此为基础进行工作尝试使用任何内置字体渲染的东西。我没有那样做。

当我完成核心渲染引擎时,我最终遇到了一些与字体渲染怪癖相关的恼人的工件(甚至固定宽度字体有时有点宽......),当我最终解决这个问题时,我发现libtcod,这是一个非常令人印象深刻的 Roguelike 引擎,具有 C# 包装器。这都是基于控制台的。我玩了一下它,我被震撼了。

从 1.5.1 开始,除了鼠标输入和其中一种键盘输入模式(我认为他们最近放弃了)之外,我在 libtcod 中接触到的所有内容都工作得很好,但是制作 Roguelike 所需的所有内容都在那里,并且其中包括多种视线、寻路,甚至地下城生成算法。视觉上相当先进。你见过这样的RL吗?

http://doryen.eptalys.net/files/screenshot0014.png

简而言之,使用 silverlight 构建 Roguelike 游戏是可能的,但我不会期望它会很容易,除非您已经拥有强大的 silverlight 或游戏开发背景。你将重新发明一些严肃的轮子,即使拥有一个可以专注于游戏玩法的强大工具包,也不乏要做的事情。

I've been toying with the idea of building a web-based Roguelike game using Silverlight (or maybe just a desktop game using WPF).

If you don't know what a Roguelike is, it's a type of graphical RPG where the graphics are rendered using text. Because the graphics engine is relatively simple, you get to spend your time building features into the game and it's possible for one person to quickly build something fun.

For instance, a typical screen might look something like this (the @ is the player, # is a wall, the other characters are things like monsters, stairs, and items):


(source: thangorodrim.net)

I'm an experienced ASP.Net dev and I'm just getting started with Silverlight. Is there a particular approach I should take for this?

To provide some background, in Winforms, most standard approaches are too slow -- the text ends up updating with a visible, ugly blink. I'm thinking something to do with the Canvas might be appropriate, but even better would be to somehow draw a screen into a buffer and then instantly flip that onto the screen so that it becomes visible instantly.

But I don't really want to mess around with DirectX right now - I'm hoping WPF can get me to where I need to be without a big learning curve.

Any thoughts?

Update: So this turned out to be pretty challenging. I tried a lot of different approaches and I was finally able to get it to actually render fast enough, but I think that to make it blazing hot fast you should probably build a sprite map of the font you want to use and work from that instead of trying to use any of the built in font rendering stuff. I didn't do that.

When I got the core rendering engine done, I ended up with some annoying artifacts related to quirks of font rendering (even fixed width fonts are sometimes a liiitle bit wide...), and when I finally worked that out I discovered libtcod, which is a very impressive roguelike engine that has a C# wrapper. That's all console based. I played with it a little and I was blown away.

As of 1.5.1, everything I've touched in libtcod works great except for the mouse input stuff and one of the keyboard input modes (which I think they recently ditched), but everything you need to make a roguelike is in there, and that includes several line-of-sight, pathfinding, and even dungeon generation algorithms. It's pretty advanced visually. Have you ever seen an RL like this?

http://doryen.eptalys.net/files/screenshot0014.png

In a nutshell, it's possible to build a roguelike with silverlight, but I wouldn't go in expecting it to be easy unless you've already got a strong silverlight or game dev background. You're going to be re-inventing some serious wheels, and even with a powerful toolkit that allows to focus on gameplay, there's no shortage of things to do.

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

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

发布评论

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

评论(3

最近可好 2024-08-20 19:15:28

这是迄今为止我在 .NET 中见过的唯一一个类似的流氓软件 - 看起来基于 WPF

http://roguedotnet.com

This is the only rogue like I've seen so far completed in .NET - looks WPF based

http://roguedotnet.com

奢欲 2024-08-20 19:15:28

WPF 应该能够非常轻松地处理这个问题。

Silverlight 可能可以工作,但它没有 WPF 提供的相同硬件加速,因此性能会较低。

实际实施有很多选择。您可以使用画布并自行渲染。或者,如果您遇到更新问题,画布网格(仅根据需要更新画布)可能会帮助保留模式渲染系统表现得更好一些,但我怀疑,使用标准屏幕分辨率,您会遇到任何问题WPF 中的文本量。

WPF should be able to handle this, pretty easily.

Silverlight would probably work, but it doesn't have the same hardware acceleration that WPF provides, so the performance will be lower.

There are lots of options for actual implementation. You could use a canvas and render yourself. Alternatively, if you're getting update issues, a grid of canvases (only updating the ones as needed) might help the retained mode rendering system perform a bit better, but I doubt, with standard screen resolutions, you'd have any issues with this amount of text in WPF.

满身野味 2024-08-20 19:15:28

您应该使用 silverlight 的 XNA 库很容易地做到这一点。它们应该允许您以可用于游戏的良好速度制作至少 2D 图形。

You should do it pretty easily with XNA libraries for silverlight. They should allow you to do at least 2D graphics in a good speed usable for games.

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