Tuesday, March 24, 2009

Adding HUD to Asteroids 3D in JME #11



You now might want to add a HUD to your application so you can display game information to your user. I will show you how to create a simple menu bar at the top of your application using FengGui. FengGui can be used to add components to your application. In my prior post I showed you how to install it.

In your Asteroid3DGame.java class, you should add these as global variables.

private int asteroids=0;
private int ships=0;
private Display disp=null;
private FengJMEInputHandler input=null;
private Label statusbar=null;

We are going to display the number of asteroids and ships you have in the game. The asteroids and ships variable will keep track of the number of asteroids and ships. At each location where you add an asteroid or ship in your game, you should add this variable to increment the counters.

asteroids++;

or

ships++;

At the end of your initGame method, you should add this function call.

initGUI();

In your render(float interpolation) method, you should add this code:

statusbar.setText("Asteroids: "+asteroids+" Ships: "+ships+" ");
disp.display();

This code sets the label in your status bar and renders the FengGui display.

You should add this function to your class. This is the method that will create a label to display in your application using FengGui.

protected void initGUI()
{
disp = new org.fenggui.Display(new org.fenggui.render.lwjgl.LWJGLBinding());
input = new FengJMEInputHandler(disp);
statusbar = new Label("Asteroids: "+asteroids+" Ships: "+ships+" ");
statusbar .setX(20);
statusbar .setY(450);
statusbar .setSizeToMinSize();
statusbar .getAppearance().setTextColor(new Color(100,255,50));
statusbar .setVisible(true);
disp.addWidget(statusbar);
disp.layout();
}

Now when you run your application, you should see a status bar at the top that will display the number of ships and asteroids you have in the game.

(Step #12 Coming Soon)

Read more...

Installing Bugzilla on a Window's System Part 2

I am showing you how to install Bugzilla on a Window's Vista System. If you are just starting, you should see my Part 1 post.
Bugzilla Installation Part 1

You now need to install ActivePerl. You should download and install perl version 5.10 from this website. http://www.activestate.com/activeperl/

Make sure you have the installation add perl as an environmental variable.

On your C: drive, you need to create a directory called temp if you do not already have one. Make sure the system has full access.


You should make sure that your active perl is upgraded. To do this, go to a command prompt by selecting the start menu and type cmd in the text box. When your command prompt opens up, type c:>ppm upgrade.

You also need to install packages needed for Bugzilla.

You will do this from the command prompt by typing c:> ppm install TimeDate

Install these packages as well:

ppm install AppConfig
ppm install Template-Toolkit
ppm install MailTools
ppm install Chart
ppm install GDGraph
ppm install PatchReader
ppm install Convert-ASN1
ppm install Net-LDAP-Express


Active Perl version 5.10 doesn't allow you to install the mySQL driver by typing ppm install DBD-mysql. However, there is another site that you can install it from.

Type this command in the command prompt to install the mySQL driver. You might need to be logged in as an administrator though.
ppm install http://cpan.uwinnipeg.ca/PPMPackages/10xx/DBD-mysql.ppd

You can find out what modules you need to install by traversing to the bugzilla directory, and typing C:\mozilla\webtools\bugzilla>perl checksetup.pl --check-modules from the command prompt. You can change directory by typing cd and the directory name. To see a list of directories from the command prompt, you can type dir.

This command will give you a list of modules that are required, and a list of modules that are optional. You do not need to install the optional items unless you want to.

I noticed that I had a conflict from my oracle installation when running checksetup.pl. oracle\product\10.2.0\db_1\perl\5.8.3\lib. If you see that error, then you should delete the environmental variable PERL5LIB or the variable that contains your oracle installation. It is using a different version of perl.

Now you should install the Apache 2.x webserver to run Bugzilla.
You can download it from here: http://httpd.apache.org/download.cgi
I will download Win32 Binary without crypto (no mod_ssl) (MSI Installer), but if you
are concerned about security, you should download the one that includes ssl.msi.

You should run the windows installer and make sure All Users, on Port 80 is selected.

If you are going to run this service on your local machine, you should put localhost in the Network Domain and the Server Name, but otherwise, you should put in your domain name and server name that will be running bugzilla. Put in the email address you will be using as administrator. You probably will select typical install and then install the apache server.

Now you need to modify the httpd.conf file. Locate the file in this directory:
C:\Program Files\Apache Software Foundation\Apache2.2\conf and make a backup of it first (Or locate it to where you place it on your computer). Now open it up with a text editor such as notepad.

Locate the DocumentRoot and change it to your Bugzilla location like this:
DocumentRoot "C:\mozilla\webtools\bugzilla". If you have trouble saving the file after you have changed it, you need to change your permissions on the file first to give you full access.

Replace this: <Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/htdocs">
with this (the path to your instance of Bugzilla):
<Directory "C:\mozilla\webtools\bugzilla">

Locate this line of code: #AddHandler cgi-script .cgi
and remove the #. This will uncomment the line so you can use CGI scripts.

Locate this line: Options Indexes FollowSymLinks and add ExecCGI so it should look like this:
Options Indexes FollowSymLinks ExecCGI

change this line: AllowOverride None
to this: AllowOverride All

Locate the end tag: </Directory>
and above it, place this line of code: ScriptInterpreterSource Registry-Strict

Locate this line of code: DirectoryIndex index.html and change it to this: DirectoryIndex index.html index.html.var index.cgi

You should locate this path: CustomLog "logs/access.log" common and
replace it wit this: #CustomLog "logs/access.log" common
This will disable logging.

Locate this in the file and remove it:

<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>


Save all of your changes.

Now you need to modify your Microsoft Registry. You need to be careful when modifying the registry.

Open up the command prompt again and type regedit to open the Microsoft Registry Editor GUI.

Under the HKEY_CLASSES_ROOT, you should create a new key under this folder.
Rename it to .cgi. Under that folder, create one called Shell, and
under that folder, create one called ExecCGI, and under that folder,
create one called Command. Open the Default under Name for the Command key and
paste this into the value field: C:\Perl\bin\perl.exe -T if that is the path to your perl that you have installed. If it isn't, then you need to put the path to your Perl instance.

Now you need to configure Bugzilla. You should open the Localconfig.pm file
in your C:\mozilla\webtools\bugzilla\Bugzilla (or the location to your instance of Bugzilla).

You should locate this line: $db_user = "bugs"; and change the user to the user of your database.If you want to keep the user the same, create a user on the database called bugs with a password called 'sockmonkey' (or create a password of your own).
Give the user all access to the bugs database. Under the 'db_pass', change the default to be sockmonkey in the Localconfig.pm file.

You should run perl checksetup.pl again.
C:\mozilla\webtools\bugzilla>perl checksetup.pl
This should create your needed tables in your bugs database. You should see all the needed tables being created.

You need to input your SMTP server's host name. Since I am using comcast, I will put in smtp.comcast.net for the host name. You will need to input your email address for the administrator and the administrator password. I will use password for my password.

I would restart the computer, and then make sure your mysql and apache is re-started.
If you have trouble starting apache, that is because you messed something up with the http.conf file. Copy your backup back into that directory, and see if you can figure
out what you did wrong.

If you need any more help installing Bugzilla, you can reference their instructions at: https://wiki.mozilla.org/Bugzilla:Win32Install

If you get this error: client denied by server configuration:
then in your httpd.conf file, you didn't change your path to your instance of Bugzilla in two places. See above for instructions.




Go To Part 3

Read more...

Sunday, March 1, 2009

Conclusion J2EE Tutorial Step 62

This concludes this tutorial. I hoped you enjoyed my examples. If you are looking for more advanced Java, please see my Groovy and Grails tutorial I am starting on my Developer's blog. I have other tutorials that I am working on as well.


Thanks...

Developer's Blog

Read more...