Metro4K

Metro4K

Webstart - http://javaunlimited.net/games/launch.php?type=jnlp&id=130

Homepage - http://www.nullterminator.net/java/metro4k/

[i] A small city building simulation. Construct as big of a city as you possibly can. Keep it powered with utilities and safe with emergency services. The higher a section goes, the bigger it gets and the more it helps to fuel the entire city system. The more successful your city becomes, the more money you get to build it even larger.

Plan your city. Make sure that industrial pollution won’t hinder the growth of residential areas. Make sure there is adequet transportation with streets. Use parks around the city and the waterline to make the city more beautiful for residential and commercial districts. [/i]

My 2nd contest entry (and game in Java). An inspired re-make of an old classic. More challenging trying to get the simulation working. If there’s one thing I wish I could squeeze in, it would be a system for communicating how well different areas of the city are doing (crime, pollution, utility, work, products, retail, etc). May take a 2nd look at it to see if there’s some more byte crunching I can do. But there’s only so much you can do in 4K, as you’re well aware. :wink:

See the homepage for more details and instructions.

Have fun!

B

Wow, a really well done game!

Looks nice and plays very nicely. Much more of a city sim than i would expect to be do-able in 4k.

If you have some more space tho, you could make it slightly harder, i ended up with so much money i couldnt spend it fast enough. Also you could give some more feedback to why areas are doing poorly.

Haha, wicked city.

You nailed it right on the head with your two comments…

Once you get enough momentum, you can keep going. Still trying to think of a way to balance it so it’s not as easy.

And I’d love to have more feedback. I had a feature for displaying bars over the zones to monitor the stats. But they had to get pulled out to slip under the size limit.

I just barely squeezed in the procedural water generation, which was a bigger plus than I thought it would be.

Really cool. ;D Even if it doesn’t make it under the size limit, I’d still like to play a version with more feedback and stats.

I never liked these Sim games, although I remember playing SimTower way back…and enjoying it a bit.

But this entry is amazing :slight_smile: Very nice achievement, I’m impressed.

some tips to reduce your jar size:

-use pngcrush or similar on your graphic file
-rename the graphic file to “m” instead of “m.png”
-convert all the static methods to non-static methods
-try to reduce the number of methods used (each method needs an entry for its signature in the resulting class file)
-I am not sure, but does your webstart version of the JAR selfexecuting? if so it is not necessary so remove the meta-inf directory to save space. (you will need to put it back in for your downloadable JAR version (which can be over 4k as long as the webstart version is under 4k)
-reduce the number of static and class variables as like with the methods, these variables’ signatures are recorded in the class file. Instread try to make ‘method scope’ variables where you can.

Ideally you will only have two ‘methods’ one main entry method which will call the constructor where all your code is.

The main trick to fit more into 4k is to NOT think OO and do nastry procedual code :slight_smile:

The final point is to run your .class through an optimiser (see 4KJO for a tool which attempts to find the best combination)

Easy to optimize more.

I used bjwflate on the contents of your jar, and it went from 4.090 bytes to 4.039 bytes.

Also, you don’t need that META-INF directory if your jar is webstartable. I deleted it and rezipped it, it’ s now 3.906 bytes., saving you 184 bytes.

I took a look at your code using jshrink, and I noticed few things that could be done differently that could probably save you up to 100 bytes. You should take a look :slight_smile:

You’re using a lot of methods, try inlining them instead.

I just ran your game through 4KJO to make an embedded pack200 self exectuing JAR.

The only changes i made was to remove the main() method from your m.class and to remove the manifest.

I was able to compress it down to: 3651 bytes! (see the attached file)

With optimistaions to the structure of your program I would imagine another 100-200 bytes could be saved.