PS - Somehow I broke the sound just now so it doesn't play part of the time. Looking into it, but Java MIDI sucks.

"Spoo4k" (pronounced just like spook) is my entry into the 4k competition (well, my unofficial just-for-fun entry because I'm a judge). The game is basically done but any suggestions for improvement would be great. I'll probably change the AWT-shapes to bitmap images at some point, by the way.

The basic idea is that you're a guy in a spooky house which is inhabited by ghosts. All of your friends are also in the house, but they've been paralyzed by the ghosts. Because you've got your full life energy, you're more tempting to the specters. So, your job is to go near the other people to lure the ghost off them, then bring the ghost to the bottom right corner where it will disappear. Careful, though, because the more a ghost touches you, the more life force you lose. If you get down to 0, you collapse just like your friends, and all hope is lost. Fortunately, however, ghosts are afraid of light, and you've got your lantern with you. Hold space to keep it on. While the lantern is on, you've got extra visibility and the ghosts will run away instead of coming close to you. By going back and forth between the lantern, you can keep the ghosts following you but also at a safe distance. Get all the ghosts away to win.

Your life is measured by the red bar, and your lantern batteries by the yellow bar. The green bar represents how many ghosts you've led away. When it gets full you win. If your red bar goes to 0 you lose.

Press <SPACE> to turn on your flash light, <ARROW KEYS> to walk around.Press <ESCAPE> to quit or <R> to restart.

Extra notes:This game actually went through a very interesting evolution. I wasn't at all sure what I wanted to do for the 4k competition, and finally decided (since I've been playing around with it so often lately anyway) that a velocity/attraction game would be pretty cool. I was thinking some sort of puzzler/action game where a missile gets shot at you and you need to arrange black holes intelligently so that the missiles get flung back at the rocket launcher. So I started coding that, and ended up with a pretty cool little gravity engine that could fling missiles around in a nifty fashion. Then I experimented with repelling fields as well, which were straightforward and would probably be good for the gameplay. Because at that time I was having one gravity well follow the mouse around, I realized that the missiles actually seemed to behave sort of like some sort of critter when I repelled them. So I decided maybe a game where you need to get a bunch of mice out of a maze would be cool, and your mouse would represent either cheese or a cat. But then I realized that I still had the possibility to have more than one "black hole" in the level at one time, so after noticing that the "mice" would sort of attract to the other ones until the stronger black hole got closer, it reminded of ghosts or something floating around a person. And the rest is history, of course.

Yeah the atmosphere is quite spooky. The flickering lantern is a good effect.

Maybe you could alter the game play a bit so you can kind of herd the ghosts towards the green dot with the flashlight, as well as lure them over using your own body?Also, for some reason the player moves slower with the flashlight on, maybe it's on purpose?The sound volume could be higher too on my computer.

@CommanderKeith- What exactly do you mean by herding them with the flashlight? Because currently it already does that, unless you mean that they automatically run towards the exit when the flashlight is on. Basically you can think of the ghosts as asteroids and the people as planets. The player has the most mass so the ghosts get pulled most towards him. When the flashlight is on, the pull is just turned negative, so it becomes a push instead. So if you, the exit, and a ghost are all on a straight line and the ghost is between you and the exit, then the flashlight will herd it directly to the exit. Do you mean some separate functionality from that? As for walking more slowly when the flashlight is on, that's not intentional at all actually, and is quite weird. My CPU doesn't seem to go any higher when I have it on, so it's not lag-based. I'll look into it. Literally all it does though is change the sign of your mass to negative (so you repel instead), draw a yellow rectangle with alpha, and stretch the light image wider.

@rdcarvallo- Yup, I knew that already, take a look above I posted it up there. Has to do with two people together having mass exceeding the player's. This should be fixed just fine if I randomize the level better/design levels.

A highly updated and improved version uploaded with the same webstart link. Now has an actual level you can play and has become a real game. Just like before, the goal is in the bottom right.

Please let me know if any of the sounds are annoying. Also this should be totally beatable. Any suggestions on tweaks would be great. I'm currently over by 800 bytes... we'll see if optimizers help. Still slowly but surely reducing my byte count, but I may need to eliminate something (although I don't know what).

just ran a cut down version of your jar (minus the metainfo) through the 4KJO tool and your compressed class size has been reduced from 4538 bytes to 3092 bytes. this means a jar with only your class + data has gone from 4873 to 3419 bytes. ( optimised Jar )

The Window looks misplaced on my WinXP (1280*800).The Bottom-Line is behind the Taskbar

But other than that, i won

Yeah to save bytes I was just moving it to position 200,200 on the screen and it's 800x600, so that means it'll get overlapped a bit on your smaller resolution. I'll put a fix for this at some point or I'll just make it an applet (more likely).

just ran a cut down version of your jar (minus the metainfo) through the 4KJO tool and your compressed class size has been reduced from 4538 bytes to 3092 bytes. this means a jar with only your class + data has gone from 4873 to 3419 bytes. ( optimised Jar )

Can you give me a quick step-by-step on exactly what you typed to do all this

no problems The tool was originally only going to be an in-house tool so is not very friendly. (or well made )

1. I removed the metainf directory from the your published JAR2. I ran 4KJO using default settings on this modified JAR: 4KJO -saveConfigFile c:\temp\out.xml -output c:\temp\spoo4k_opt.jar -verbosity 1 c:\temp\spoo4k_modified.jar This generated the first optmised jar ( you can simply use the script aboveusing the -config switch to generate that jar.

to run I just used java -cp c:\temp\spoo4k_opt.jar F

For the embedded version I used an undocumented feature of the tool: the "-addData" command line switch.

1. Decompiled your F.class2. modified the getResourceAsInputStream statement from "M" to "F.class" so that it will use the class itself as input.3. added a simple statement to move the inputstream pointer to the start of the embedded data:

The only seperate file i saw in the JAR you had published was the M data file, i did not see another file (text or image) but, yes you can embedd both, however only as one file so you will have to concatenate both files into one and then embed that file.

see the "-addData" section in my previous post on how i embedded data into the class file.

All you need to do is add two extra bytes to the start of your image data and then point the tool (using "-addData") to that image data. (you will need to add code to "seek" the input stream to the embedded data. (see previous post ) )

If you wand to add multiple discrete data files to the class i.e. a map and a image then you will need to read and output the bytes of each file sequentially into a new file. this new file will likewise need the magic number extra 2 bytes of "||" at the beginning.

You will of course need to then read the embedded data in your class in the same order as you appended the data files into one.

Nope, it is not done manually... it is actually quite an involved process... since Java 5 they do not allow you to simply append extra data to the end of the .class file. So the tool has to parse the class file and insert a valid Attribute containing the data. I learnt a lot about class files doing that i can tell you!

The magic number is just a unique 2 byte sequence which is used to make the process of seeking the input stream to the start of your embedded data simpler and thus better to compress.

Unfortunately this feature is undocumented for a reason... It does not automatically add a magic number to the data to embed. A silly over site. However a simple program to append a magic number is below:

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org