TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How do I best learn Java in order to build a multiplayer game?

2 点作者 DesignerJoel超过 13 年前
I have an idea for a project I'm really interested on working on. It's a pretty large mass multiplayer game, based mostly on text with some minimal graphics.<p>I have some coding knowledge, some barely remembered C, slightly more ruby and php, and a bit of processing (which is based on Java, I guess).<p>Basically, I want to start from scratch, but do it right. I don't want to hack this game together, I want to make it work. How would I go about that? Could I do it as I build the game?<p>Also, which aspects of Java, and possibly what other tools would I need to build a multiplayer game? Are there any libraries geared towards this stuff?<p>Thanks!

2 条评论

dkuntz2超过 13 年前
So have you ever used Java before?<p>I ask because if you haven't that the logical place to start is with learning the basics, followed by the building blocks to a multiplayer game.<p>If I were to start building a multiplayer game (preface: the main language I write in is Java, due to it being the main language in my high school's cs classes and my current cs course), I would start with building a really simple single player game. Start with just the world and one player.<p>After getting a single player game working (as best you can with just one player if the game is designed solely for multiple players), start trying to decouple the world from the gui, start making the world a server and the gui a client.<p>After that, you've got most of the pieces you need to start adding more players.<p>----<p>Additionally, I was in a class where the final project was to create a very simple multiplayer world. Our process in leading up to that project was simply working with the individual aspects of the project beforehand and adding it together for the final.<p>We started off the class working with graphics, making a ball bounce using relative gravity on the screen, animating sprites, creating and modifying images (taking a jpeg with the color white meant to be transparent and making it transparent on the screen, fading an image in and out, really simple sounding things that would be used to form the basis of more complex, fun things).<p>The second part was mostly networking. Starting with reading and writing text files (which was done before the graphics, to let us read and write images) and moving towards sending and receiving text from other machines. One of the more complex projects in the class started with our teacher building a number guessing server: his computer would pick a random number from Integer.MIN_INT to Integer.MAX_INT, and we would have to guess it. The first of the three projects with the random number server involved creating a simple client that would have users enter a number. The second part required us to automate the server. The third had us take the server and add user authentication to it.<p>After the random number projects, we moved on to sending and receiving objects over the network, specifically images, and having them show up on another computer's screen.<p>All of that lead into the final project, which had us build a server that received icons from a computer, give each of those icons a position, and track changes in position. The client for the server would pick an image, send that image to the server, and move the icon around using the arrow keys. The client would also display other icons from other clients connected to the server. Essentially a really simple multiplayer game.<p>----<p>In my current class, there was just an assignment requiring us to use both the observer and proxy design patterns for a simple blogging application. Using the observer and proxy patterns would probably be beneficial to you when you get into the server/client part of the game. I don't really have any good resources for leaning about those because it was mostly a lecture coupled with an assignment and lab problem.<p>----<p>I'm not sure if that answered your questions, but I hope it helped give you an idea of where to start. I also acknowledge that I put down a lot in this comment, but I personally think it's at least somewhat helpful.
评论 #3242113 未加载
liquidcool超过 13 年前
It's an ambitious undertaking, but your timing is good. Stanford's Programming Methodology class is free online and teaches Java:<p><a href="http://see.stanford.edu/see/courseinfo.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111" rel="nofollow">http://see.stanford.edu/see/courseinfo.aspx?coll=824a47e1-13...</a><p>There are many technology specific classes at JPassion.com. It used to be free, so I'm not sure whether a subscription is required.<p>As for libraries, there are over 5,300 games written in Java on sf.net:<p><a href="http://sourceforge.net/search/?q=&#38;fq%5B%5D=trove%3A198&#38;fq%5B%5D=trove%3A80" rel="nofollow">http://sourceforge.net/search/?q=&#38;fq%5B%5D=trove%3A198&#...</a><p>I subscribe to their newsletter and Arianne and FreeCol are often listed as top projects, so you'll want to check them out.<p>BTW, Steve Yegge did something similar with Wyvern:<p><a href="http://en.wikipedia.org/wiki/Wyvern_(video_game)" rel="nofollow">http://en.wikipedia.org/wiki/Wyvern_(video_game)</a><p>I believe that contained hundreds of thousands of lines of Java. Given his bent towards dynamically typed languages these days, I don't think he'd do it in Java again.<p>(Note: I am in no way affiliated with any of the above resources/people.)