Alien Onslaught

Hi!

I have recently made a game using the standard java libraries (no Jogl/Lwjgl) and thought i’d share it with you all for some valuable advice. The game is called Alien Onslaught(decided to change recently, since there are alot of space war games which are better)…

I have not tested the game on Linux or Mac, only on windows (and even then on some computers its different for some reason)
So it would be interesting to get feedback from linux and mac users.

Jerkiness should be fixed! ;D ;D ;D

You can play it here: http://www.tabish.me.uk/page7.html Feel free to click the google ads :wink:

The controls are in the help menu.
Currently there is no sound (used to be until flash drive went crazy…never worked properly since then…)

m can also be used and shoots bullets like the spacebar

And there are some controls not designed to be used normally which are:

c turns of particles for player, helps a bit in speed
g suggests garbage collection
d decreases the desired fps for the game
f increases the desired fps (which the game runs at)
holding down k shows the fps on the screen, and the amount of milliseconds the thread is sleeping for (shows up to right of player and down a bit)

Also I have another game which I have uploaded called Stickman Adventures.
Its a platformer.
There is currently no help menu for stickman but the controls are:

up,right and left arrow keys move.
m goes to menu
down changes the type of jumper(blue thing);

THere are only 5 levels at the moment which aren’t that good. I would be grateful if anybody could make some levels and send me them.

I’ll try and upload a help thing for the leveleditor as it is a little confusing.

You can play stick man here: http://www.tabish.me.uk/page13.html

EDIT: Tab Man is my other account since I cannot remember the password to this one, and will lose access to the laptop it is logged onto soon.

Uhm… the code is pretty bad. Mine isn’t all that great most of the time, but yours is even worse. Use more OOP… not necessarily the design pattern madness kind of OOP, but just a little bit to break things up a little and to capsule some data away. Also use proper indention. This saves lots of time - your time. Most IDEs have auto formatting capabilities or smart auto indention. Use it.

The game runs very jerky here… while only using a few % CPU. I guess the throttling code is flawed. I suggest to adapt lwjgl’s sync() method. That one works fairly well.

I’m not entirely sure how to fix the jerkiness. It only seems to happen on collisions and such when new Explosions/ Bullets/ Enemies are made. When the game does go jerky the game prints to the java console that it has done so, so at least I can tell when it is going jerky. Maybe when this happens I can make the thread sleep for 1 millisecond instead of the alloted time.

As for the code I will try and turn on auto indenting and smart indenting when I reformat the code. As for making it more OOP im not sure as to how to do this. Would making seperate classes to handle collisions and the levels make it better?

It is quite interesting but I consider that JOGL and even LWJGL are standard librairies, I don’t see what you mean.

It works under Linux, thank you very much.

You could use JOGG and JORBIS for the sound or JOAL. This jerkiness “spoils” the gameplay. I don’t understand the reason of your slowdown, maybe you do something “long” on the event dispatching thread and then you block it a few milliseconds. Sometimes, ennemies that are outside the field of view can shoot you, it is frustrating as you can’t shoot them. Good luck. Your game is quite fine, it is a good beginning.

runs really jerky here too, which is a shame since it looks interesting, nice and colorfull :slight_smile:

holy crap at code too, it looks like something a decompiler spat out :smiley:

Thanks for the input, i’m glad you like the code :stuck_out_tongue:

The sound used to work perfectly fine before the flash drive went crazy, which had all of my files and eclipse on it…
Morale of the story is always backup data.

Once the game works well and dosen’t lag ill look into finding sound files again and using them.

Oh and the not being able to shoot enemies outside your line of sight, don’t trust the minimap so much as it isn’t the best of mini maps. The bullets are destroyed once they are a reasnoble distance away from the player.

;D ;D ;D ;D ;D I think I fixed the problem with it being jerky. Im not sure exactly what fixed it but its one of 2 things:

  1. changing it so that explosions don’t load images everytime they are made, and that bullets are Ovals and not images.
  2. When the game ‘lags’ or goes jerky the thread sleeps for only 1 millisecond in order to compinsate.

But in doing this I lowered the ideal fps from 59 (don’t know why 59) to 50. Its easily changeable but at the moment I really need to do my homework…
Although you can manually change the framerate by pressing f and d. f increases the frame rate, d decreases.
The java console should then print the ideal fps for the game/

You are right, it runs smoothly now.
The only thing I would like to have now is a positive score :-\

I got this error? WinXP Java 1.5

java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

I got this error? WinXP Java 1.5
java.lang.UnsupportedClassVersionError: Bad version number in .class file

He used 1.6 as target. Well, upgrade. 1.6 is faster and more secure.

Yes! It works fine! Good job! You said that you load the image of the explosion each time you need it, I think it is an error of beginner and I’m happy to see that you fixed it.

The link to the source code doesn’t work anymore :frowning:

Works fine here. It looks nice and colourful :slight_smile:

[quote]I consider that JOGL and even LWJGL are standard librairies, I don’t see what you mean.
[/quote]
I suppose ‘standard libraries’ as in ‘no external jars, only using what’s available in the JRE’.

Having space as the shoot key with arrows as controls doesn’t work well. See: http://www.java-gaming.org/forums/index.php?topic=17883.0 for the explanation. Other then that, looks cool on my PC (Vista - JRE 1.6).

Sorry I havn’t replied in ages i’ve been kinda busy.
Alot of changes have taken place on the game:

  1. There is now a basic working high score
  2. Minimap should be a bit better
  3. “Cirlces” & “Spheres” now go to the correct position on the screen
  4. You can use ‘m’ to shoot just like the spacebar, but the mouse is still better for accuracy

Please could you give me an URL to a screenshot to add your game in the Java™ Game Tome?