JAVAsteroids

Another asteroids clone, original eh? Well, I needed a game to write so I could practice my openGL so here it is!

http://www.cyntaks.com/projects/asteroids/webstart/asteroids.jnlp

the download is near two megs I believe, so if you want to see some screens first here they are: http://www.cyntaks.com/projects/asteroids

The game is only partially complete because it has 3 gameplay modes and only one is finished. Before I got too far I wanted to get some feedback on the game in general as well as the mode that I did complete: Classic Mode. Classic mode uses basically the same gameplay as the original but it is a bit faster paced it seems.

I’m also curious to see how its running on other people’s computers, the graphics are done with jogl and I’m using openal for audio, through lwjgl.

The only problem I’ve run into with jogl is that it doesn’t want to run on Intel graphics cards, its had a 100% failure rate on all Intel cards so be warned! The error I’m getting is something like: unable to enumerate pixel formats blah blah, I posted on it in the jogl forums but a solution was never found…

Audio has worked on all the computers I’ve tried except two, and I wasn’t able to get any details on the computer so I really have no idea what caused it. The funny thing is that Alien Flux sound worked on these computers (of course :slight_smile: ), and as far as I know we are both just using openAL via lwjgl. Perhaps Alien Flux falls back to javasound if its not supported… So any feedback on how audio works on your computer would be appreciated. When the program starts it will print out: audio initialized or audio not initialized depending on whether AL.create() was successful or not.

There is still a bit of work to be done, most important is to finish the two additional gameplay modes.

The first new mode I came up with is called Adventure mode. In this mode your ship, ufos, and asteroids all have shields so not everything dies on collision. I plan on adding some more evil monster type things as well as a shield which can be activated by pressing down and weapon powerups. The asteroids will get tougher as the levels go on and I’m thinking about adding some bosses every few levels, only real problem with that is coming by the graphics for them. Right now all I have is some broken collision physics and color changing to indicate asteroid health and a health bar to show the ship’s health.

The second new mode is called Deep Space mode. You are in deep space and don’t have an ambient light source so you must use the floodlight that your ship is equipped with to find the asteroids in the dark and avoid getting smashed. The changes that will be made for this mode are:
-ship has a shield
-asteroids will drop health powerups that will
dissappear after a few seconds.
-you will have a light flash (more like an expanding ring of light) that you have to charge but can be used to see all the asteroids.
-asteroids move slower.
-no ufos.
This mode is also only partially complete.

I plan on adding an options menu where you can change all this, but for now here are a few undocumented controls:

fire: spacebar
accelerate: up
turn left: left
turn right: right
floodlight toggle: L
spotlight toggle: K
sound toggle: S
explosion style 1: 1
explosion style 2: 2
use colorful asteroids: C //this will only be available for classic mode in the future
blow up all the asteroids: X //this won’t available for long :slight_smile:
bring up the game menu: escape

Let me know how it runs on your computer and what your specs are so I can get some idea of minimum requirements for the game. I would also like any feedback on adjustments you think should be made to classic mode, I’m still messing around with the speeds of the ship/bullets/asteroids and all that.

Thanks for testing!

I thought of a couple more things.

A few people on the forums have played this before and I have edited the jnlp since then, so if its crashing because it can’t find some class, its probably because you have the old jnlp cached.

I have only run this on windows up until now, so I have no idea how its going to run on mac and linux. This is the first time I have tried distributing jogl or lwjgl for the other OSs through webstart so hopefully I did everything right.

wow!
works perfectly (except for sound :(), the smoothest Asteroids I have played so far!

xp, 1800+, gf2, sound on board

runs great, but sound is missing…

mobile intel p4 2,4 ghz - geforce 440 go - jre 1.4.2_05

greetings,
holger

Runs fine here - no sound on first round (fullscreen). Subsequent launches ran with sound (fullscreen and windowed).

Crashes in displaymode stuff when exiting game:

[quote]Exception in thread “AWT-EventQueue-0” java.lang.IllegalArgumentException: Invalid display mode
at sun.awt.Win32GraphicsDevice.setDisplayMode(Unknown Source)
at com.cyntaks.asteroids.DisplayManager.disposeFullscreenWindow(DisplayManager.java:242)
at com.cyntaks.asteroids.MainClass.exit(MainClass.java:618)
at com.cyntaks.asteroids.KeyboardHandler.keyPressed(KeyboardHandler.java:157)
at java.awt.Component.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
[/quote]

Runs smooth and fast !

1.1 Ghz Athlon, Asus 8200 - Geforce 3 , 512 RAM

Nice work dude !

Dosenbier ;D

===========
Mac OSX

No sound or display here (black screen)

Dump:

Wow, every single person has had sound problems :o thats not good. I’ll start browsing the lwjgl forums and see if I can find out what I’m doing wrong, I must be initializing it incorrectly or something…

the error on Ribot’s computer appears to be different, this must be the part where I didn’t package everything correctly for the different OSs, looking into it.

heres what the mac section looks like in my jnlp:


<resources os="Mac OS">
<j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+"/>
<jar href="lwjgl_test-macos.jar"/>
<jar href="lwjgl-macos.jar"/>
<nativelib href="jogl-macosNative.jar"/>
<nativelib href="lwjgl_openal-macosNative.jar"/>
<nativelib href="lwjgl-macosNative.jar"/>
</resources>

I havn’t been able to find an example lwjgl jnlp, so I’m assuming thats correct.

Could I actualy be initializing it wrong or is openal just not widely supported? Initialization seems pretty basic and I’m not too sure how I could screw it up ;D this is the first bit of code that gets executed in my program:


try{
        AL.create();
    } catch (LWJGLException le) {
      WAudioClip.soundEnabled = false;
      le.printStackTrace();
      return;
    }

if lack of support is actualy the case, it looks like I could be switching to fmod, which is a shame because openAL is working wonderfully over here :frowning: . Anyone else care to share their experience with openal? I really have no idea whats going on.

openal works fine, it’s most likely some other weird issue. I hardly think that fmod will increase you’re chance of success (especially since the lwjgl version doesn’t work on os x yet)
Which lwjgl version are you using? - The mac version hasn’t been upgraded for some time…

I’m using .92 for linux and win32 and .9 for mac. I was prepared for stuff not working on mac, but it looks like three windows users have already had sound problems (sounds like its working for you now) plus two other computers I tried where sound wasn’t working. I looked at my code again and I was initializing openal on a seperate thread because I was loading all my sounds on it, that has been changed although I don’t see why it should make a difference.

You can’t use 0.92 code and expect it to work with the 0.9 mac version. However, since OpenAL for lwjgl hasn’t changed for a loong time, it might actually work - I haven’t tested that…

Not to steal your thread, but:
Can all those with openal sound issues please try:
http://lwjgl.org/jnlp/lwjgl-demo.php/examples.spaceinvaders.Game

Works perfectly here. And a damned fine implementation of Asteroids it is! I prefer classic mode meself.

Cas :slight_smile:

Matzon: no problem.

I had a thought yesterday about what could make Deep Space mode more fun. Your light could require a power source that is constantly draining and the light flash will just drain a particularly large amount. So instead of dropping health the asteroids could drop small amounts of energy. As the time it takes to find the last remaining asteroids increases, panic starts to kick in because your light source is fading to nothing :smiley:

Thanks to everyone for the positive feedback, I’ll keep you posted on major updates.

Could I make another request of anyone else who has sound problems? please let me know what gets printed to the console. If ‘Sound not initialized’ gets printed, that means AL.create(); failed, if it says ‘Sound Initialized’ and you still have no audio, the I can assume its something else in my program. Thanks.

Wow! Great stuff here! Now I have to be on the watch for your’s and kevglass games!

Here are some things I noticed -

  • No sound. Tried to toggle with the s key and didn’t get any changes

  • Excellent graphics! Asteroids are drawn very well.

  • Love the color change on the asteroids to indicate how close to exploding they are.

  • The shield threw me at first. I thought it was a front shield at first, because that’s where the indicator kept showing up when I was hit. The I slowly realized it was the strength indicator. I’d make it become a glowing type circle around the ship and have its brightness or thickness fade when you get hit.

  • The lighting is a very cool effect.

  • The lights seem to affect the shots you make. They get smaller as they leave the light. If you don’t have lights on you don’t notice this. Not sure if I prefer it or not.

  • The slow down I don’t like. :frowning: I prefer the accelerate and you have to reverse thrust to slow down concept, either by turning a 180 or having an actual reverse thrust option.

  • I’d make the thrust trail longer when you accelerate. It does grow, but it seems like when you thrust it should get longer faster.

  • The explosions are perfect.

  • Are you going to make the shileld have an option to be turned on automatically versus the user having to trigger it?

  • If you can swing it, add two player. Its always more fun when you can play two player cooperative. You could also add an option to enable/disable player shots hurting each other.

  • It would be nice to have autofire somehow as well. Maybe you could add some sort of upgrade option. Maybe some asteroids contain ‘metal or something’ if you get enough ‘metal’ you get to build an upgrade. (better shield, lazer that can fire off angle to the nearest target, autofire, etc.)

HTH!

Regards,
Dr. A>

Hey dranonymous thanks for the great feedback!

sound
This is a problem, I’m not sure whats going on. I’ve been looking around the lwjgl forums but havn’t found anything yet. I’ll certainly continue working on it though, since I think the sound is quite good :slight_smile:

shield
That is a good idea, the only reason I didn’t do it is because I was planning on having something similar for the manualy activated shield. So there would be a glowing ring when you pressed down or whatever key you use to activate the shield, and you just flash and see your health when you don’t have the shield activated. I may add the health bar to the top of the screen instead of where it is currently.

The lights seem to affect the shots you make.
Yeah, this has to do with the type of alpha blending I’m using, I’m not actually too sure how to get around it since both of the effects seem to require it.

The slow down I don’t like.
I’ll have to think about this one… The reason I’m using slowdown is because thats how it is done in the original. I could just keep it for classic mode though. Several people have actual suggested that I add a reverse thrust, so I’ll have to at least consider it :wink: Malohkan suggested that I add the reverse thrust as a ship upgrade, I think I like this idea best and will probably use it.

Short Thrust
I’ve thought this looked a bit funny for a while but never did anything about it, I’ll give it a change tonight.

Are you going to make the shileld have an option to be turned on automatically versus the user having to trigger it?

that sounds like good idea, hadn’t really put much thought to the manually activated shield yet. I think it would be pretty easy to use if it were activated by pressing the down butt, but if thats taken by reverse thrust than there isn’t another key where I would like it. So yeah, looks like auto-shield is in :slight_smile:

If you can swing it, add two player.
I’ve actualy considered multiplayer before, but not seriously since my network coding skills go about as far as writing a chatroom :slight_smile: Instead of just two player I was thinking of a deathmatch mode. This may not seem like a good idea at this point, but there are two things that could change it. First of all there would have to be a much larger playing feild and a radar. I’ve messed around with scrolling on asteroids before so thats a possiblility. Second would be lots of weapons/ship upgrades and possibly some kind of bombs. I had never thought of doing a coop mode though… I generally find coop games to be more fun then what I mentioned above and I think it could work well in Adventure Mode. All of this is highly unlikely though, I don’t think I’m going to learn the necessary networking skills :-/

upgrades
Ah yes, upgrades. I am definetely going to do ship upgrades for adventure mode. I got lots of good updrage ideas from Malohkan for this one, I’ll list a few:
Faster turn rate
Faster auto-fire rate
Shields
Stronger weapons
Auto-tracking weapons
mirv grenades :wink:
melee weapon?
I myself was thinking of rewarding small updrades from random asteroids and vital upgrades from level bosses. However, saving up for updgrades has been mentioned to me before and I never really took to it but getting metal from asteroids seems to just fit in too perfectly to ignore it. I think thats a great idea, thanks!

Your plans for two player are much bigger than mine! :slight_smile: I just meant add 2 player for the same machine.

I know I’ve played an asteroids version that had it, but I can’t remember where. I think it was on a console, rather than PC.

To make it really fun and more interactive for two players you could have 1 ship that takes two people to control. The first player would use the mouse or joystick to fire and steer.

The second player would control shields by making the shield come up in the direction they want. The shield wouldn’t cover the entire ship. This could be done from the keyboard. You could add in a really different upgrade system too. You would have a transport ship showup on the screen. When it does, the second player has to ‘dial’ in the right radio frequency to contact the other ship. The ‘frequency’ could be based on the color of the ship and its insignia. To get the frequency, use the number keys for the color and maybe tab for the insignia.

You could do something different than that and have the second player be the one that ‘harvests’ the metal from the asteroids. They could go out in a little ship and collect the metal and then either dock with the main ship or land inside it. Come to think of it, I like this idea better than the radio one. The little ship would not have any real weapons, but maybe tough shields. You could give it limited fuel so that if it ran out, the main ship would have to go get it.

As for the manual shields, I remember the Atari 2600 version used down on the joystick to activate the shield. If you didn’t, then you’d die instantly when hit. If you have reverse thrust, you could make it work by checking if the fire button is pressed.

Down - No button = shield
Down - With button = thrust

How can I get something to print out about the audio? I’ll send you the info if you let me know.

Regards,
Dr. A>