123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|593|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> On Topic -> Java?

Fri, 31 Jul 2009, 06:38
cthug
Is it any good. I have been having a looking and playing around with it, so far I am impressed. Looking at it mainly from RAD 2D game development perspective, I like it, especially the in-built net, math and geometry (mainly 2d transformations) libraries. Normally I don't like interpreted languages but java's compiled bytecode, seems to have the best of both worlds. Any thoughts?

|edit|
Also I like the idea of applets, I hate flash.
|edit|


-=-=-
CTHUG.co.nr
Get Ubuntu
Fri, 31 Jul 2009, 06:51
Phoenix
There's only one way to find out: try it. Some people hate Java, others love it.
Fri, 31 Jul 2009, 07:02
cthug
Well I like it so far, playing around with graphics commands. Although I don't really like OOP I like OO programming with java.

-=-=-
CTHUG.co.nr
Get Ubuntu
Fri, 31 Jul 2009, 07:03
Jayenkai
I'm sure DD/JL235 will be happy to give you a bunch of pointers. Works fine for him.

-=-=-
''Load, Next List!''
Fri, 31 Jul 2009, 08:09
JL235
Java is very clean and strict about how it does object-orientation. It's Java2D library is one of the best I've seen because it's progressively improved on every release. Lots is still performed on the CPU, but they moving more and more over to use OpenGL and Direct3D instead. I've had programs I've built literally double in speed between a release because of this.

However it's not all perfect. The OpenGL stuff is way too undocumented for my liking. As you can see from my site it's also not as cross-platform as Sun like to claim. The main issue with this is that it will brake in very alien environments, outside of your target domain, where it should normally work. I've seen plenty of errors on other Java projects because someone is running X obscure window manager on Y Linux distro.

Also bear in mind that it's bytecode is trivial to decompile by hand and there are plenty of free tools online which can convert your compiled classes back to Java source code. Sun even bundle a simple command-line decompiler with the JDK! There is nothing to stop people working out how your code works (I've done it a few times myself).

cthug Normally I don't like interpreted languages but java's compiled bytecode, seems to have the best of both worlds.

Fyi, it compiles to bytecode which is interpreted the first time it is run. When the Java virtual machine encounters the same section of code again, it will compile it to native code. It can also re-compile the code at a later date with different and more aggressive optimisations based on it's run-time performance. Compiling bytecode on the fly is called just-in-time compilation, and the analysis and recompilation technology is called HotSpot.

In theory Java can be better optimised then C/C++ because it's more strict (pointers are hard to optimise) and it has added runtime knowledge about how your program performs (which C/C++ don't). You can also find plenty of benchmarks online where Java outperforms the equivalent C code. But in practice it's close, but not quite as fast.
Fri, 31 Jul 2009, 12:01
steve_ancell
Not sure if this is of use to anyone, but some may find it useful

www.csd.abdn.ac.uk/~dritchie/teaching/CS1014/information/JavaKid8x11.pdf
Fri, 31 Jul 2009, 12:50
JL235
A few points you might be interested in:

IDEs

There are lots of IDEs you can use, but the two main choices are:
Eclipse by IBM. This is the popular IDE used by the vast majority of Java developers. It's an excellent editor at the cutting edge, one you should definitely try. But personally I don't like it.
NetBeans is by Sun Microsystem and is what I use. It's slower, less popular and has typically less features then Eclipse but I find it's better designed and more stable.

Links

Java API, this is the link you need bookmarked. You can also download it so store it locally, which I do. It contains TONNES of stuff from Swing for making GUIs, to JDBC for talking to databases, to the collections framework which contains various different types of maps, sets and lists.
DocJar a personal favourite of mine, essentially it contains the source code to the Java API.

Graphics

Java 2D - This is already included in the Java API, and is the easiest and best supported way to build graphics. I've used this for years and although it's big and confusing at first, you soon realise that means it's incredibly powerful. In some implementations it uses Direct3D or OpenGL for some tasks, but even then it's no where near on par with doing it yourself in OpenGL.
JMonkey - Never used it, but it's one of the most popular engines for building games in Java. I've seen some Java game courses at universities use JMonkey for teaching, and it's typically quite highly rated.
Java 3D - A framework for building scenegraphs and rendering 3D environments. This is what all the big companies (like Sun) support and is expected to be eventually included in the Java API. I haven't used this.
Lightweight Java Game Library - LWJGL - Another game library for Java, again I've not used it but lots do,
Java OpenGL - JOGL - The Java OpenGL bindings, this is what I use. Bear in mind that those above are engines and frameworks, this is not.
Fri, 31 Jul 2009, 16:18
cthug
Hey thanks JL235, I like the sound of JOGL I will try it later. One problem say Test.java:


where OtherClass.java:

Why can't can't I draw to 'screen' in OtherClass, it won't even compile.
Or am I going about this in the wrong way?

|edit|
https://java.sun.com/javase/6/docs/api/ is very handy too, ty DD
|edit|


-=-=-
CTHUG.co.nr
Get Ubuntu
Fri, 31 Jul 2009, 18:38
cthug
Fixed my own problem


where OtherClass.java:



-=-=-
CTHUG.co.nr
Get Ubuntu
Fri, 31 Jul 2009, 18:41
JL235
I've just ran this myself. The error I received was:

This breaks down as:

>> C:\Users\Joe\Desktop\java>"C:\Program Files\Java\jdk1.6.0_14\bin\javac.exe" ./Test.java ./OtherClass.java
This line was typed by me to compile the code at the command line.

>> .\OtherClass.java:6: cannot find symbol
First it says the the error is in OtherClass.java on line 6. The symbol bit is the type of error. A symbol is what the compiler uses to represent a class, method or variable name. In this case it is looking for one of those on this line and could not find it.

>> symbol : method drawText(java.lang.String,int,int)
This explains the symbol it is looking for. A method called drawText which takes a String and then two ints.

>> location: class java.awt.Graphics
and this is where it is looking for the symbol. In the Graphics class.

>> screen.drawText("Why Won't This Work?", 256, 256);
A print out of the statement which caused the error (from OtherClass.java). The ^ on the next line is pointing at the location of the error in that statement. In this case it is pointing at the method call.

So on line 6 in the OtherClass class it wants to call the method drawText on a Graphics object, but cannot find the method.

If you then take a look at the API for the Graphics class you'll see that the method does not exist! That is why it could not be found.

You should be calling drawString instead.



A few more pointers:

Until you've learnt the difference between the different access modifiers, you should always write 'public class Test' rather then just 'class Test'.

For instance variables (don't need it for local variables) you should also always write 'private OtherClass other' rather then 'OtherClass other'.

You should set a colour to the Graphics before drawing text, there is no guarantee about what colour it will have set when it is given too you.

Finally what you are doing should work, but bear in mind that by default Applets (and other Swing components) paint on demand, and not continuously. For example it will only repaint if it is resized, moved, maximized or if the component changes in some way.

This is exactly what you want for GUIs, not very good for games. But there are ways of setting up buffer strategies and getting Swing components into a state where you can draw whenever you want to.



Would there be interest for me releasing the framework I use for my games? It would mean that essentially all this work would be done already.
Fri, 31 Jul 2009, 20:07
cthug
Thanks for your help, I found some sources to fix problem with applets only updating on demand, double buffering, and using update method.

-=-=-
CTHUG.co.nr
Get Ubuntu
Sat, 01 Aug 2009, 04:44
cthug
Been having a look through java swing, awt documentation, I like what I see, GUI programming always was annoying to me, eg being OS specific, or having to spend more time installing libraries like GTK and compiling on each platform than programming, but java's idea of WORA (Write Once Run Anywhere) is great. I Downloaded NetBeans 6.1 and Eclipse. I much prefer NetBeans. I think I will start using more and more often .

-=-=-
CTHUG.co.nr
Get Ubuntu
Sat, 01 Aug 2009, 16:40
JL235
NetBeans is currently at version 6.7. This is the version that should be offered on the official site, and the one you should be using.
Sat, 01 Aug 2009, 17:05
cthug
Yeah I will update it today; 6.1 was the one in the Ubuntu 8.10 repository

-=-=-
CTHUG.co.nr
Get Ubuntu