想学写2D游戏

发布于 2024-08-06 11:18:35 字数 399 浏览 4 评论 0 原文

嘿 stackoverflow 社区! 我学习了 C# 的基础知识(我可以编写一些表单应用程序),现在我想学习如何编写 2d 游戏。我不知道从哪里开始。 有适合 2d 游戏的引擎吗?在学习了 2d 的基础知识之后,我想编写在 Windows 和 Linux 下运行的简单游戏(这应该很酷,Linux:))。

我问了一位热衷于编程的朋友,他说我应该将 XNA 与 C# 一起使用(但这只能在 Windows 上运行)。经过谷歌搜索后,我发现使用 C++ 的 OpenGL 应该是为 Linux 编写游戏的最佳选择,因为没有 DirectX/XNA。而且我还没有使用过 C++,这需要一些时间来重新学习。

您有什么可以建议的吗?也许是其他引擎?我刚刚安装了 XNA 并查看了演示游戏(Platformer),该代码一点也不难。 XNA 适合 2d 游戏吗?

Hey stackoverflow Community!
I learned the basics of C# (i can write some Form-Applications) and now I want to learn how to write 2d games. I don't know where to start.
Is there a engine that's good for 2d games? After learning the basics of 2d I'll want to write simple games which work under windows and linux (that whould be cool, linux :) ).

I asked a friend who is into programming and he said I should use XNA with C# (but that would only work on windows). After googleing I found out that OpenGL with C++ whould be best to write games for linux, since there is no DirectX/XNA. And I haven't used C++ yet, that whould take some time to learn, again.

Is there something you can suggest? Maybe an other engine? I just installed XNA and took a look at the demo game (Platformer), that code isn't hard at all. Is XNA good for 2d games?

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

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

发布评论

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

评论(7

软糖 2024-08-13 11:18:35

一次迈出一步。当您开始时,您并不需要您的代码能够在每个平台上运行。使用 OpenGL 还是 DirectX 并不重要,因为您将全心全意地创建一个在一个平台上使用一个图形 API 运行的游戏。

其次,不要太担心“引擎”。您不需要引擎来制作游戏,而且通常会带来更多麻烦而不是其价值。对“引擎”的痴迷从根本上来说是个坏主意。如果您试图让一个软件组件来支持游戏所需的所有功能,那么它对于其中任何一个都不值得使用。

您需要的只是:

  • 一种编程语言你很舒服。听起来这是 C#,所以坚持下去。
  • 将图形显示在屏幕上的某种方法。 .NET 库可以在某种程度上做到这一点,但一些更高级别的库可能会让它变得更容易。您可以使用 XNA 或 SlimDX 或其他 Direct3D 包装器。或者您可以尝试 SDL.NET。或者您可以自己编写。您需要的功能非常基本,每个图形库(2d 或 3d)都可以让您做到这一点。

您尤其不需要任何“适合 2D 游戏”的东西。 XNA 能够将图形显示在屏幕上,因此它可以满足您的需要。如果您还了解使用它所需的代码,那么 XNA 就足够了。不要费心去寻找“最好的”,或者以“对于 2D 游戏来说很棒”为卖点的东西。

Take one step at a time. When you're starting out you don't need your code to work on every platform. It doesn't matter whether it uses OpenGL or DirectX, because you're going to have your hands full creating a game to run on one platform with one graphics API.

Second, don't worry too much about "engines". You don't need an engine to make a game, and often, it'll be more trouble than it's worth. The whole obsession with "engines" is fundamentally a bad idea. If you try to get one single software component to support every bit of functionality you need for a game, then it's not going to be worth using for any of them..

All you need is:

  • a programming language you're comfortable with. It sounds like this is C#, so stick with that.
  • Some way to put graphics on the screen. The .NET library can do that to some extent, but some higher level library will probably make it easier. You could use XNA or SlimDX or another Direct3D wrapper. Or you can give SDL.NET a shot. Or you can write your own. The capabilities you're going to need are pretty basic and every graphics library, 2d or 3d, will let you do it.

You especially don't need anything which is "good for 2D games". XNA is able to put graphics on the screen, so it does what you need. If you also understand the code required to use it, then XNA is good enough. Don't bother trying to find the "best", or something that has "awesome for 2D games" as a selling point.

錯遇了你 2024-08-13 11:18:35

最简单、最容易访问的平台可能是 Flash。游戏易于分发且学习速度相当快(从网络上可用的 Flash 游戏的绝对数量来看)。

我同意贾尔夫的观点。不要开始考虑引擎。引擎是一个复杂的野兽,考虑到您的编程经验很少,它很快就会变得令人难以承受。游戏中有很多东西,其中涉及的设计模式往往与典型应用程序的设计模式有很大不同。当你开始谈论诸如命中检测之类的事情时,OpenGL 类型的东西就会变得非常复杂。

您可以采取的另一个方向是,您可以尝试制作《半条命 2》或《虚幻》等游戏的模组,而不是从头开始制作自己的游戏。这为您提供了一个基本平台,您可以更改该平台并查看其行为方式。与此同时,您将查看其他人的代码并了解游戏开发的复杂性。

以下是我从 Google 搜索中获取的有关 Flash 游戏的快速链接。我确信网上可能有很多关于使用 Flash 和其他语言创建游戏的书籍。

Probably the easiest and most accessibly platform is Flash. Easily distributable and rather quick to learn for games (judging by the sheer amount of flash games available on the web).

I agree with jalf. Don't start thinking about engines. Engines are a complex beast and considering your programming experience is small, it can get very overwhelming very quickly. There's a lot of stuff that goes into games and the design patterns that are involved in them tend to be much different from those of say a typical application. And OpenGL type of stuff gets very complex when you start talking about things such as hit detection.

Another direction you could take is instead of starting your own game from the ground up, you could try making a mod to something like Half-Life 2, or Unreal. That gives you a basic platform that you can change and see how it behaves. In the mean time you'd be viewing other people's code and seeing the intricacies of game development.

Here are a quick links I pulled off of a Google search with regards to flash gaming. I'm sure there are probably quite a few books available online as well with regards to creating a game in flash and other languages.

离笑几人歌 2024-08-13 11:18:35

有人提到Flash,这是一个很好的建议,但有点贵。如果您想免费进行一些 Flash/AS3 开发,我建议使用 Flixel。您还需要 FlashDevelop,这是一个很好的(也是免费的) )IDE。 Flixel 网站有很多很好的资源可以帮助您入门。

Someone mentioned Flash, which is a good suggestion, but a bit expensive. If you'd like to do some Flash/AS3 development for free, I'd recommend playing with Flixel. You'll also need FlashDevelop, which is a nice (also free) IDE. The Flixel site has a lot of good resources to get you started.

笑叹一世浮沉 2024-08-13 11:18:35

如果您正在考虑追求图形编程的未来,我会选择 OpenGL,原因如下:

  • OpenGL 在 Windows、Mac、Linux 甚至 PlayStation 3 上实现。(用途极其广泛)
  • 一旦您熟悉 2D 编程,您可以转向 3D 并继续使用 OpenGL。
  • 与 DirectX 相比,OpenGL 在性能方面同样快
  • C++ 是每所大学级编程课程的一部分。*
  • 我认为雇主比任何其他语言都更尊重 C++ 知识。

学习曲线可能会更高,但你的时间会花得很值。

* 如果您的大学没有将 C++ 作为其编程课程的一部分,那么您就是一个异类。

If you're thinking about pursuing a future in graphics programming, I would pick OpenGL for the following reasons:

  • OpenGL is implemented on Windows, Mac, Linux, and even PlayStation 3. (extremely versatile)
  • Once you're comfortable with 2D programming, you can move onto 3D and stay with OpenGL.
  • OpenGL is equally as fast in terms of performance compared to DirectX.
  • C++ is a part of every collegiate-level programming curriculum.*
  • I think employers respect knowledge of C++ more than any other language.

The learning curve may be higher, but your time will be well-spent.

* If your college doesn't have C++ as a part of their programming curriculum, you are an outlier.

心意如水 2024-08-13 11:18:35

根据我的经验,最好先以简单应用程序的形式(可能基于文本)编写游戏的基础,然后通过尝试教程中的点点滴滴来构建图形。这样,您将始终拥有一个可以使用的工作框架,并且不会立即使所有图形调用变得复杂。

另一点是动机:如果你总是有一个工作应用程序,那么看着它慢慢成长和发展会更令人满意,而不是因不断的“工作/不工作转换”而感到沮丧,并总是等待所有的部分组合在一起形成某种东西远程完成。

就引擎而言:现在的 DirectX 和 OpenGL 本身就是引擎。它们可以让您非常轻松地完成许多原始工作(从 3ds Max 获取模型并通过 1-2 行代码将其加载到您的应用程序中),对于小型游戏,您不需要任何其他东西。

我也同意 MunkiPhD 的观点:Flash 对于 2d 游戏来说是一个非常好的平台。它非常简单,让您摆脱所有无聊的图形编程。然而,ActionScript 编程与使用 C 系列语言和适当的开发的“重型”编程相差甚远。平台。每次看到 ActionScript 都会让我感到沮丧。

From my experience it's far better writing the basis of your game first in a form of simple application (perhaps text based) and then building graphics on top of that just by trying out bits and pieces from tutorials. That way you will always have a working skeleton that you can play around with and you don't immediately complicate yourself with all the graphics calls.

Other point is motivation: if you always have a working app it's far more satisfying to watch it slowly grow and develop rather than being frustrated by constant "works/doesn't work transitions" and always awaiting all the bits to come together to form something remotely complete.

As far as engines go: DirectX and OpenGL these days are kind of engines themselves. They let you do a lot of primitive work very easily (get a model from 3ds Max and load it into your app in 1-2 lines of code), for a small game you won't need anything else.

I also agree with MunkiPhD: Flash would be a very good platform for a 2d game. It's very simple and lets you get away with all the boring graphic programming. However, ActionScript-programming is not anywhere near "heavy-duty" programming with C-family languages and proper dev. platforms. ActionScript frustrates me every time I see it.

梦开始←不甜 2024-08-13 11:18:35

如果您现在想专注于 2D 游戏并继续使用 C#,并且能够让您的朋友在 Mac 和 PC 上玩您的游戏,您是否考虑过使用 Silverlight?

使用 Silverlight 可以解决一些问题,例如安装。

您可以尝试在 Silverlight 中创建一些游戏,然后在上手后您就可以更好地决定接下来要学习哪些其他工具。随着 Silverlight 3.0 最近发布,实际上有大量的人试图了解它可以在游戏中发挥多大作用,这可能会帮助您找到问题的答案。如果您决定采用此路线,您可以在此处或 Silverlight.net 等网站上发布

免责声明:我不确定 Silverlight for Linux 的状态如何

If you want to focus on 2D games and keep using C# for now, AND be able to have your friends play your games on Mac and PC, had you thought about using Silverlight?

Using Silverlight would get around some issues such as installation.

You might try a creating a few games in Silverlight and then after getting your feet wet you'd be in a better position to decide what other tools you'd like to learn next. With Silverlight 3.0 being recently released there is actually an influx of people trying to see how far it can be pushed for gaming, which might help you get questions answered. If you decide on this route you can post here or on sites like Silverlight.net

DISCLAMER: I'm not sure what the status of Silverlight for Linux

浅笑依然 2024-08-13 11:18:35

Flixel 确实很强大——您可以使用最少的代码来启动并运行 2D 游戏。您可以找到详细的教程,指导您完成使用 Flixel 创建简单平台游戏的过程 此处

替代文字

Flixel does rock - you can get a 2D game up and running with a minimal amount of code. You can find a detailed tutorial that steps you through the process of creating a simple platform game using Flixel here.

alt text

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