开发者

Building a Roguelike in Silverlight (or WPF)

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):

Building a Roguelike in Silverlight (or WPF)

(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.


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

http://roguedotnet.com


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜