Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web applet game design [closed]

I making web games in java and having troubles each time when getting to the GUI design, usually I'm looking at others codes and copy most of the design, and I can't decide which design I should use. I used Applet, Canvas, JFrame. What I need is the main loop and draw function that changing between different games. So what class should I use and what design, which is better, why, maybe links to useful tutorials and examples... Please explain your suggestion. Thanks.

like image 207
Vladp Avatar asked Mar 12 '11 00:03

Vladp


2 Answers

If you want some code to dissect, you should check out Killer Game Programming in Java

It's a good book, even if it now uses old libraries. I bought it a few years ago. If you don't fancy buying it, you can still download all the source code from the website

You can pretty easily abstract away the choice between using an Applet or Java Web Start. If made to choose, I'd go with JWS, purely because I find it easier to setup a development environment to debug.

These two links demonstrate how to use JFrame v Canvas:

  1. JFrame http://download.oracle.com/javase/tutorial/uiswing/components/frame.html

  2. Canvas http://en.wikibooks.org/wiki/Java_Programming/Canvas

like image 147
colinjwebb Avatar answered Oct 07 '22 00:10

colinjwebb


  • An Applet (or JApplet) is embedded in the web-page, and thus has only the space given to it by the browser. It stays there as long as the page is shown.
  • A proper (J)Frame is its own window, thus can be as big as the windowing system (and screen size) allows - and it can be closed without closing the browser page (and the applet in it).

This is the main difference. You could simply do your drawing in a own Canvas (for AWT) or JPanel (for Swing) and put this inside the (J)Applet or (J)Frame, thus abstracting the difference between both away until you are ready to decide.

like image 23
Paŭlo Ebermann Avatar answered Oct 06 '22 22:10

Paŭlo Ebermann