Java 遊戲程式設計:基礎篇 (Java Game Programming: The Basic)

若您覺得文章寫得不錯,請點選文章上的廣告,來支持小編,謝謝。
If you like this post, please click the ads on the blog. Thank you very much.

用Java寫遊戲的第一步驟就是要把東西在螢幕上顯示出來,那麼在Java裏頭有哪些類別可以用呢?答案是好多耶,像是AWT中的Frame,Swing中的JFrame、等。若是用Netbeans IDE的話,可快速拉好一些簡單的介面,所以本文選用Netbeans IDE來使用。
The first step in creating a Java game is showing something on the screen. How many classes can we use in Java? There are so many API. For example, Frame in AWT and JFrame in Swing.  However, we can create the game framework easily by Netbeans IDE.

遊戲的主要視窗為JForm、遊戲的畫面放在JPanel裡,程式碼的框架如下:
The main window class in a Java game application is usually a JForm. The game elements are on JPanel. And the code prototype are the following:


執行結果如下,只是顯示文字在畫面上。
The result is displaying some text on the screen.

沒有留言: