尽可能轻松地创建 Java 平台游戏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2894661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Creating a Java platform game as easily as possible
提问by directx
I need to create a Java-based platformer gamefor a high school project (not computer science related), and I want to spend as little time on technical stuff as possible.
我需要为一个高中项目(与计算机科学无关)创建一个基于 Java 的平台游戏,并且我想在技术方面花费尽可能少的时间。
I'm already experienced in Java, and I already have most of the gameplay, graphics, etc. All I need to do is code it. I've looked and I'm considering one of two options that do not involving coding a game from scratch:
我已经在 Java 方面有经验,而且我已经拥有大部分游戏玩法、图形等。我需要做的就是编写代码。我已经看过并且正在考虑不涉及从头开始编写游戏的两个选项之一:
- Copy an existing Java platformer (best option, but I can't find an open source Java platformer)
- Use a Java game engine to avoid coding from scratch. I've looked at JGame but I'm not sure if it's the best bet for a platformer.
- 复制现有的 Java 平台游戏(最佳选择,但我找不到开源 Java 平台游戏)
- 使用 Java 游戏引擎避免从头开始编码。我看过 JGame,但我不确定它是否是平台游戏的最佳选择。
回答by Andy White
There's a book called "Killer Game Programming in Java" that has an example of a 2D platform game using the Java 2D Graphics API. I think the source code for the book is available on the author's site here: http://fivedots.coe.psu.ac.th/~ad/jg/
有一本书名为“Killer Game Programming in Java”,其中有一个使用 Java 2D Graphics API 的 2D 平台游戏示例。我认为这本书的源代码可以在作者的网站上找到:http: //fivedots.coe.psu.ac.th/~ad/jg/
It's a decent book, but the code examples are a little messy. It might give you enough to get started though.
这是一本不错的书,但代码示例有点乱。不过,它可能足以让您入门。
回答by Ricket
Developing Games in Javais a great book, and the first half of it goes in detail about creating a 2D platformer game. Overall I found the book's explanation to be excellent, and the full game is on the CD so you could mod it to fit your needs. [edit: wait a second... it doesn't come with a CD... the source is on the website, see below!]
《用 Java 开发游戏》是一本好书,前半部分详细介绍了如何创建 2D 平台游戏。总的来说,我发现这本书的解释非常好,完整的游戏在 CD 上,所以你可以修改它以满足你的需要。[编辑:等一下......它没有附带CD......源在网站上,见下文!]
I don't feel like it's a super fully-developed platformer; it feels more like a demo. But you could use the game as a starting point and add anything else you need. And the code, being a book example project, is well documented and commented. It has a level format too, so if you find it fits all your needs you should be able to just drop in your images and make your own level files, and then load them in-game.
我不觉得它是一个超级成熟的平台游戏;感觉更像是一个演示。但是您可以使用游戏作为起点并添加您需要的任何其他内容。代码是一个书籍示例项目,有很好的文档和注释。它也有一个关卡格式,所以如果你发现它符合你的所有需求,你应该能够放入你的图像并制作你自己的关卡文件,然后在游戏中加载它们。
By the way, the rest of the book dives into creating a software 3D engine from scratch using Java 2D. It's really awesome. Just a bit of a bonus after this project is done, eh?
顺便说一下,本书的其余部分将深入探讨如何使用 Java 2D 从头开始创建软件 3D 引擎。真是太棒了。这个项目完成后只是一点奖励,嗯?
Also a downside, the book is now almost 7 years old. It uses Java 1.4 though, and the book websiteis still online, so I'd say it's still a viable resource! In fact, it looks like the book website has a demo of the game AND all of the source code, so you might not even need to buy the book. Go check it out!
还有一个缺点,这本书现在快 7 岁了。虽然它使用 Java 1.4,而且图书网站仍然在线,所以我认为它仍然是一个可行的资源!事实上,这本书的网站似乎有游戏的演示和所有源代码,所以你甚至可能不需要购买这本书。去看看吧!
回答by liamzebedee
I am in the exact same boat as you. There just aren't enough (free, opensource) resources around to help start Java game developement. http://www3.ntu.edu.sg/home/ehchua/programming/java/J8d_Game_Framework.htmlI think this is one of the best tutorials I have seen around. It basically gives youa template for the game.
我和你在同一条船上。没有足够的(免费的、开源的)资源来帮助开始 Java 游戏开发。http://www3.ntu.edu.sg/home/ehchua/programming/java/J8d_Game_Framework.html我认为这是我见过的最好的教程之一。它基本上为您提供了游戏模板。

