Friday, December 23, 2011

Hey there! Just wanted to wish all of you a fantastic happy holiday season; it couldn’t be more festive. For me, Christmas came a little early, though, because of the release of the Unity 3.5 Developer Preview, which is a Beta version of the soon-to-be-released Unity 3.5. The talk of the town in this grand new release? The new Flash export feature.
You see, Unity Technologies, the makers of Unity 3D, has added a capability to allow developers to export their games as Flash applications so they can be run without a Unity Web Player plugin or JavaScript activity the browser. Not only that, web games will run without a plugin in Google Chrome, thanks to Google’s Native Client API.
To quote Unity’s website:

Unity 3.5 is one of our biggest releases to-date. It’s packed full of new features and improvements that we think you are going to love. We can't wait to see what you will create with it, so we've decided to open our 3.5 beta program to the public. Starting today, you can download a time-limited beta version of Unity 3.5.
This release also provides a hands-on preview of Unity's upcoming Flash deployment add-on. Experience first-hand how Flash deployment in Unity opens up new publishing options, by enabling you to push your interactive 3D content to the web through Adobe Flash Player.

Some of those features happen to include a new Particle System (with Legacy particle support included, of course) and a built-in path finding system for Pro license holders (path can be run but not created under Unity Basic). They’ve re-written the occlusion culling system to allow for doors that open and close, dynamically changing the viewable areas, and has built in LOD support.
They’ve also added multithreaded rendering, which will give a performance boost on multi-core systems. To see all the new features, check here: link. Those of you who want to try the Flash should do it now, because once Unity 3.5 officially ships, you will be forced to upgrade and Flash support will require an additional license like the iOS and Android exports do.
Well, I’ll be playing on 3.5 Beta. See you soon. SevenBits

Monday, December 5, 2011

Today I’m going to show you all the neat little things you can do with Java. Java is a very versatile programming language, and tonight I’m focusing on Swing. Included in the package javax.swing and included on all versions of Java, it can be used to create interesting GUI applications. For those of you who think they know what Java is but are a little sketchy, here’s a small sample to entertain ye:

Being as it is, I’m not going to explain how to compile or run this code. If you don’t know how, find yourself a good Java book. I like Head First Java by Oreilly Publishing, as it includes interesting examples to help you learn Java, including a rudimentary drum beat player.

Anyhow, there are a lot of things Swing can do, namely that it is much simpler than the native Win32 API – heck, I suppose there are WYSIWYG Java GUI builders out there, but Swing (and the AWT) provide an easy way to build complex GUIs in code. Check this little snippet out, taken from this website.

1: // file: EmptyFrame.java

2: // Adapted from Core Java, vol.1, by Horstmann & Cornell

3:

4: import javax.swing.*;

5:

6: class MyFrame extends JFrame {

7: public MyFrame() {

8: setTitle("My Empty Frame");

9: setSize(300,200); // default size is 0,0

10: setLocation(10,200); // default is 0,0 (top left corner)

11: }

12:

13: publicstaticvoid main(String[] args) {

14: JFrame f = new MyFrame();

15: f.show();

16: }

17: }

This class extends the JFrame class, so it doesn’t have to create an instance of it and can call its public methods directly.

Deprecation Warning: If your Java compiler complains about line 15 being “deprecated”, and you want to shut it up, change it to f.setVisible(true);

Now that code snippet created a window with a size of 300 pixels by 200 pixels. However, it’s rather empty. Let’s add a small push button.

1: // file: EmptyFrame.java

2: // Adapted from Core Java, vol.1, by Horstmann & Cornell

3:

4: import javax.swing.*;

5:

6: class MyFrame extends JFrame {

7: public MyFrame() {

8: setTitle("My Empty Frame");

9: setSize(300,200); // default size is 0,0

10: setLocation(10,200); // default is 0,0 (top left corner)

11: Container pane = getContentPane();

12: JButton button = new JButton("CHANGE THIS TEXT");

13: pane.add(button);

14: }

15:

16: publicstaticvoid main(String[] args) {

17: JFrame f = new MyFrame();

18: f.show();

19: }

20: }

Now the entire window will be filled with a button. I hope now you see what Swing is capable of – in fact, you can obviously use Swing to create a GUI for a previously command line run application. And because it’s Java, it’ll work in every operating system that has a JVM, though the controls will look a bit different depending on your OS.

To demonstrate this point, here’s a simple terminal application using two text fields. It’s actually a small part of a large module I’m writing for yet another project called Tracker.

Now isn't that a good old fashioned pain in the ass? So, sure, you could use Visual C, which I hear has a drag and drop GUI builder (correct me if I’m wrong), but that requires .NET, which has dependencies and requires the system to be installed for the end user. Java, although it requires a JVM, requires no such other dependencies, so you’re set on a new PC install.

Also, you’ll notice just code size. The C Win32 implementation required 130 lines (the actual code is bigger due to trimming of irrelevant parts). That’s a lot of code for a programmer to write, debug, and maintain.

So, in essence Swing is a much easier GUI creation tool in nearly every way. If you want to full API docs, the version 7 link is here.

That’s all for tonight, folks. You can grab our RSS feed to subscribe and always stay up to date. Hopefully we’ll have more Java talks in the future! Thank you, and goodnight.