I checked out the guys homepage and he is quite famous actually! He is the author of “Frozen Bubble” which is very well known in the Linux freeware gaming scene.
change sound/AI only works on alternate games.
the bullet sometimes goes through walls and doesn’t explode if hits a worm.
soemtimes is difficult to see the aiming cross, is it possible to make it red for example ?
test machine: athlon xp @3200+, xp pro and jre 1.5
I finally found back my password (Last post in 2003?)…
Seems that W4K needs still need some work… I made a stupid mistake (used jdk5.0 to compile with a -source/target 1.4), and I used a function that does not exist in JDK1.4 -AudioSystem.getClip()-. The reflective method needed to get a Clip in JDK1.4 is way too costy (+200 bytes) and I don’t want to use sun.audio package as it’s not a standard package, so I’ll probably have to remove explosion sound
That will give me some bytes for further gameplay improvment
Short answers :
Frozen Bubble is not my game, I just made the J2SE port and the J2ME port (microFB)
Red cross is harder to see than a white one… I’ll try to make it blink (As I said, I now have some spare bytes
The version -without sound- should be available next Monday
Arghhh… I tried it on several computers, and it worked fine each time (except that there is a little static after each explosion), I personally use 1.5.0_06-b05 under XP…
I’ll try to add some notes about sound in the javaunlimited.net wiki as soon as I’ll be able to find how to reduce its size (Silence gave me 500 more bytes )
The quintessential example of sampled sound in a 4K game is Defender 4000. The key parts of the source code are as follows:
byte[][] sounds = new byte[3][2000];
//Generate some sounds!
int step;
//Laser
step = 10;
for(int i=0; i<2000; i++)
{
sounds[1][i] = ((i%step > 0) ? 32 : (byte)0);
if(i%250 == 0) step += 2;
}
//BOOM
step = 25;
for(int i=0; i<2000; i++)
{
if(i < 500)
{
sounds[2][i] = ((i%step > 0) ? 32 : (byte)0);
if(i%25 == 0) step--;
}
else
{
sounds[2][i] = ((i%step > 0) ? 16 : (byte)0);
if(i%50 == 0) step++;
}
}
//Sound Support
AudioFormat format = new AudioFormat(8000.0f, 8 , 1, true, false);
SourceDataLine line = (SourceDataLine) AudioSystem.getLine(new DataLine.Info(SourceDataLine.class, format));
//Start the sounds
line.open(format);
line.start();
//Main Loop
while(true)
{
//Set the sound when an event happens by setting the variable
//"sound" to an index inside the "sounds[][]" array. Each sound
//is a 1/4 of a second clip. (8000 samples per second.)
sound = 2;
//Play the sound
if(System.currentTimeMillis() >= time+255)
{
line.flush();
line.write(sounds[sound], 0, 2000);
sound = 0;
time += 255;
}
}
The code above will produce very “electronic” sounds, but it’s SMALL. You can make the sounds more natural by computing them in a sine wave (I assume you’re probably doing this already), but it does cost something in code size. The other limitation is that only one sound can be played at a given time. Any new sounds wait up to a quarter of a second to play and may be supplanted by other sounds.
And the result (with JoGa + 7zip)
Without sound : 3697 bytes
With sound : 4260 bytes
I won’t use it in the final version, but it should be useful for someone else…
By the way, I encountered a strange problem with proGuard… My ‘proguarded’ code seems to use a lot more CPU than the normal version (5/10% >> 100%)… Is it a common problem?
Bullet works perfect now.
If you could make some space a little improvement on cpu’s IA would make it more challenging so on large distances they keep shooting at the same place, missing every shot.