Skip to content

Commit

Permalink
Importing source code for MicropolisJ, the Java rewrite of Micropolis.
Browse files Browse the repository at this point in the history
This edition of Micropolis, written for the Java desktop platform,
is fairly feature complete. I believe the only missing functionality
is that of loading the built-in scenarios, and this can be implemented
if there is any demand for it.

I will soon update the home page at http://code.google.com/p/micropolis/
with downloadable packages of this edition of the software.
  • Loading branch information
jason@long.name committed Feb 14, 2013
1 parent 6925322 commit 2b8f979
Show file tree
Hide file tree
Showing 189 changed files with 13,184 additions and 0 deletions.
674 changes: 674 additions & 0 deletions micropolis-java/COPYING

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions micropolis-java/INSTALL
@@ -0,0 +1,28 @@
Prerequisites
=============

To build MicropolisJ you will need
* Java Development Kit (version 7), get it from http://oracle.com/technetwork/java
* Apache Ant, get it from http://ant.apache.org


Building the Package
====================

1. `cd' to the directory containing the package's source code.

2. Type `ant' to compile the package.


Installing MicropolisJ
======================

Everything you need to run the program is contained within the micropolisj.jar
file, so just copy that file to wherever you like.


Running MicropolisJ
===================

Type `java -jar micropolisj.jar` to run the program.

85 changes: 85 additions & 0 deletions micropolis-java/README
@@ -0,0 +1,85 @@
========================================================================

MicropolisJ (Micropolis in Java)

========================================================================

MicropolisJ is Micropolis for the Java platform.
Copyright (C) 2013 Jason Long (jason@long.name).
Portions Copyright (C) 1989-2007 Electronic Arts Inc.

MicropolisJ is based on Micropolis, Unix version, which was developed by
Don Hopkins (dhopkins@DonHopkins.com, http://www.DonHopkins.com) for
DUX Software under license from Maxis, in or around 1990. This version
was later modified for inclusion in the One Laptop Per Child (OLPC)
program, and released as free and open source software under the GPL in
2008.
Copyright (C) 1989-2007 Electronic Arts Inc.

The original Micropolis game was designed and implemented by Will Wright.
Copyright (C) 2002 by Electronic Arts.

========================================================================

See the INSTALL file for instructions on building the program from this
source code release.

See the COPYING file for the full text copy of the GNU General Public
License.

If you need assistance with this program, you may contact:
Jason Long (jason@long.name)

========================================================================

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details. You should have received a
copy of the GNU General Public License along with this program. If
not, see <http://www.gnu.org/licenses/>.

ADDITIONAL TERMS per GNU GPL Section 7

No trademark or publicity rights are granted. This license does NOT
give you any right, title or interest in the trademark SimCity or any
other Electronic Arts trademark. You may not distribute any
modification of this program using the trademark SimCity or claim any
affliation or association with Electronic Arts Inc. or its employees.
Any propagation or conveyance of this program must include this
copyright notice and these terms.

If you convey this program (or any modifications of it) and assume
contractual liability for the program to recipients of it, you agree
to indemnify Electronic Arts for any liability that those contractual
assumptions impose on Electronic Arts.

You may not misrepresent the origins of this program; modified
versions of the program must be marked as such and not identified as
the original program.

This disclaimer supplements the one included in the General Public
License. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, THIS
PROGRAM IS PROVIDED TO YOU "AS IS," WITH ALL FAULTS, WITHOUT WARRANTY
OF ANY KIND, AND YOUR USE IS AT YOUR SOLE RISK. THE ENTIRE RISK OF
SATISFACTORY QUALITY AND PERFORMANCE RESIDES WITH YOU. ELECTRONIC ARTS
DISCLAIMS ANY AND ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES,
INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY QUALITY,
FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT OF THIRD PARTY
RIGHTS, AND WARRANTIES (IF ANY) ARISING FROM A COURSE OF DEALING,
USAGE, OR TRADE PRACTICE. ELECTRONIC ARTS DOES NOT WARRANT AGAINST
INTERFERENCE WITH YOUR ENJOYMENT OF THE PROGRAM; THAT THE PROGRAM WILL
MEET YOUR REQUIREMENTS; THAT OPERATION OF THE PROGRAM WILL BE
UNINTERRUPTED OR ERROR-FREE, OR THAT THE PROGRAM WILL BE COMPATIBLE
WITH THIRD PARTY SOFTWARE OR THAT ANY ERRORS IN THE PROGRAM WILL BE
CORRECTED. NO ORAL OR WRITTEN ADVICE PROVIDED BY ELECTRONIC ARTS OR
ANY AUTHORIZED REPRESENTATIVE SHALL CREATE A WARRANTY. SOME
JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF OR LIMITATIONS ON IMPLIED
WARRANTIES OR THE LIMITATIONS ON THE APPLICABLE STATUTORY RIGHTS OF A
CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY
NOT APPLY TO YOU.
32 changes: 32 additions & 0 deletions micropolis-java/TODO
@@ -0,0 +1,32 @@
Autodoze-
*Do not autodoze for roads,rails, or wire if not enough money to actually
build it

Budget dialog-
*Press escape to close

Coal powerplant-
*When third tile of second row is on fire, something appears to revert it to
the animated smoke stack.

On Game Load-
*All zones are unpowered for the first several ticks. I'd imagine there
are similar problems with the landValueMap, pollutionMap, tfDensity,
policeCoverage etc. I think what should happen is that the various methods
that update these maps should be called at load time.
*Evaluation data is not available.
*cityTime may not match history.cityTime

Mouse pointer-
*Would be nice if tool dragging would help keep lines straight

Disasters-
*When running FAST or SUPER_FAST, automatically pause or slow down the
simulation when a disaster occurs.

City size notifications-
*Pause and pop up a message the first time the city reaches 2000, 10000,
50000, etc. people.

Code janitor-
*Rename fireZone() to killZone()... (I think that name might be better description.)
96 changes: 96 additions & 0 deletions micropolis-java/build.xml
@@ -0,0 +1,96 @@
<!--
// This file is part of MicropolisJ.
// Copyright (C) 2013 Jason Long
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
//
// MicropolisJ is free software; you can redistribute it and/or modify
// it under the terms of the GNU GPLv3, with additional terms.
// See the README file, included in this distribution, for details.
-->
<project name="micropolisj" default="all">

<property name="package-version" value="1.0" />

<property name="srcdir" location="src" />
<property name="builddir" location="build" />
<property name="distfile" value="${ant.project.name}.jar" />
<property name="zipfile" value="${ant.project.name}-${package-version}.zip" />

<path id="build-classpath">
<fileset dir="extlib">
<include name="*.jar" />
</fileset>
</path>

<target name="init-builddir">
<mkdir dir="${builddir}" />
<mkdir dir="extlib" />
</target>

<target name="copy-resources" depends="init-builddir">
<copy todir="${builddir}">
<fileset dir="resources"
excludes="**/*.xcf **/Thumbs.db"
/>
</copy>
<copy todir="${builddir}/micropolisj">
<fileset dir="strings" />
</copy>
</target>

<target name="compile" depends="init-builddir">
<javac srcdir="${srcdir}"
destdir="${builddir}"
classpathref="build-classpath"
includeantruntime="false"
debug="true" debuglevel="lines,vars,source"
source="1.7" target="1.7"
>
<compilerarg value="-Xlint:unchecked" />
<compilerarg value="-Xlint:deprecation" />
</javac>
</target>

<target name="build" depends="copy-resources,compile">
<pathconvert property="runtime-classpath" pathsep=" " refid="build-classpath">
<map from="${basedir}" to="." />
</pathconvert>

<jar destfile="${distfile}" basedir="${builddir}">
<manifest>
<attribute name="Main-Class" value="micropolisj.Main" />
<attribute name="Class-Path" value="${runtime-classpath}" />
<attribute name="Implementation-Version" value="${package-version}" />
</manifest>
</jar>
</target>

<target name="all" depends="build">
</target>

<target name="clean">
<delete dir="${builddir}" />
<delete file="${distfile}" />
<delete>
<fileset dir="." includes="${ant.project.name}*.zip" />
</delete>
</target>

<target name="dist" depends="build">
<zip destfile="${zipfile}">
<fileset dir="." includes="${distfile}, ${ant.project.name}.ico, README, COPYING" />
</zip>
</target>

<target name="javadoc">
<mkdir dir="docs/api" />
<javadoc sourcepath="src" destdir="docs/api"
classpathref="build-classpath"
Private="true"
>
<link href="http://docs.oracle.com/javase/7/docs/api" />
<link href="http://docs.oracle.com/cd/E17802_01/j2se/javase/technologies/desktop/java3d/forDevelopers/J3D_1_3_API/j3dapi" />
</javadoc>
</target>

</project>
Binary file added micropolis-java/micropolisj.ico
Binary file not shown.
Binary file added micropolis-java/resources/airport.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/coal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/com.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/demandg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/fire.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grcom.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grcomhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grcrim.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grcrimhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grind.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grindhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grmony.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grmonyhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grpoll.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grpollhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grres.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/grreshi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/icairp.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/icairphi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/iccoal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/iccoalhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/iccom.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/iccomhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/icdozr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/icdozrhi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added micropolis-java/resources/icfire.png
Binary file added micropolis-java/resources/icfirehi.png
Binary file added micropolis-java/resources/icind.png
Binary file added micropolis-java/resources/icindhi.png
Binary file added micropolis-java/resources/icnuc.png
Binary file added micropolis-java/resources/icnuchi.png
Binary file added micropolis-java/resources/icpark.png
Binary file added micropolis-java/resources/icparkhi.png
Binary file added micropolis-java/resources/icpol.png
Binary file added micropolis-java/resources/icpolhi.png
Binary file added micropolis-java/resources/icqry.png
Binary file added micropolis-java/resources/icqryhi.png
Binary file added micropolis-java/resources/icrail.png
Binary file added micropolis-java/resources/icrailhi.png
Binary file added micropolis-java/resources/icres.png
Binary file added micropolis-java/resources/icreshi.png
Binary file added micropolis-java/resources/icroad.png
Binary file added micropolis-java/resources/icroadhi.png
Binary file added micropolis-java/resources/icseap.png
Binary file added micropolis-java/resources/icseaphi.png
Binary file added micropolis-java/resources/icstad.png
Binary file added micropolis-java/resources/icstadhi.png
Binary file added micropolis-java/resources/icwire.png
Binary file added micropolis-java/resources/icwirehi.png
Binary file added micropolis-java/resources/ind.png
Binary file added micropolis-java/resources/legendmm.png
Binary file added micropolis-java/resources/legendpm.png
Binary file added micropolis-java/resources/micropolism.png
Binary file added micropolis-java/resources/nuclear.png
Binary file added micropolis-java/resources/obj1-0.png
Binary file added micropolis-java/resources/obj1-1.png
Binary file added micropolis-java/resources/obj1-2.png
Binary file added micropolis-java/resources/obj1-3.png
Binary file added micropolis-java/resources/obj1-4.png
Binary file added micropolis-java/resources/obj2-0.png
Binary file added micropolis-java/resources/obj2-1.png
Binary file added micropolis-java/resources/obj2-2.png
Binary file added micropolis-java/resources/obj2-3.png
Binary file added micropolis-java/resources/obj2-4.png
Binary file added micropolis-java/resources/obj2-5.png
Binary file added micropolis-java/resources/obj2-6.png
Binary file added micropolis-java/resources/obj2-7.png
Binary file added micropolis-java/resources/obj3-0.png
Binary file added micropolis-java/resources/obj3-1.png
Binary file added micropolis-java/resources/obj3-10.png
Binary file added micropolis-java/resources/obj3-2.png
Binary file added micropolis-java/resources/obj3-3.png
Binary file added micropolis-java/resources/obj3-4.png
Binary file added micropolis-java/resources/obj3-5.png
Binary file added micropolis-java/resources/obj3-6.png
Binary file added micropolis-java/resources/obj3-7.png
Binary file added micropolis-java/resources/obj3-8.png
Binary file added micropolis-java/resources/obj3-9.png
Binary file added micropolis-java/resources/obj4-0.png
Binary file added micropolis-java/resources/obj4-1.png
Binary file added micropolis-java/resources/obj4-2.png
Binary file added micropolis-java/resources/obj4-3.png
Binary file added micropolis-java/resources/obj4-4.png
Binary file added micropolis-java/resources/obj4-5.png
Binary file added micropolis-java/resources/obj4-6.png
Binary file added micropolis-java/resources/obj4-7.png
Binary file added micropolis-java/resources/obj5-0.png
Binary file added micropolis-java/resources/obj5-1.png
Binary file added micropolis-java/resources/obj5-10.png
Binary file added micropolis-java/resources/obj5-11.png
Binary file added micropolis-java/resources/obj5-12.png
Binary file added micropolis-java/resources/obj5-13.png
Binary file added micropolis-java/resources/obj5-14.png
Binary file added micropolis-java/resources/obj5-15.png
Binary file added micropolis-java/resources/obj5-2.png
Binary file added micropolis-java/resources/obj5-3.png
Binary file added micropolis-java/resources/obj5-4.png
Binary file added micropolis-java/resources/obj5-5.png
Binary file added micropolis-java/resources/obj5-6.png
Binary file added micropolis-java/resources/obj5-7.png
Binary file added micropolis-java/resources/obj5-8.png
Binary file added micropolis-java/resources/obj5-9.png
Binary file added micropolis-java/resources/obj6-0.png
Binary file added micropolis-java/resources/obj6-1.png
Binary file added micropolis-java/resources/obj6-2.png
Binary file added micropolis-java/resources/obj7-0.png
Binary file added micropolis-java/resources/obj7-1.png
Binary file added micropolis-java/resources/obj7-2.png
Binary file added micropolis-java/resources/obj7-3.png
Binary file added micropolis-java/resources/obj7-4.png
Binary file added micropolis-java/resources/obj7-5.png
Binary file added micropolis-java/resources/obj8-0.png
Binary file added micropolis-java/resources/obj8-1.png
Binary file added micropolis-java/resources/obj8-2.png
Binary file added micropolis-java/resources/obj8-3.png
Binary file added micropolis-java/resources/police.png
Binary file added micropolis-java/resources/res.png
Binary file added micropolis-java/resources/seaport.png
Binary file added micropolis-java/resources/sounds/bop.wav
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added micropolis-java/resources/sounds/heavytraffic.wav
Binary file not shown.
Binary file added micropolis-java/resources/sounds/honkhonk-hi.wav
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added micropolis-java/resources/sounds/honkhonk-med.wav
Binary file not shown.
Binary file added micropolis-java/resources/sounds/layzone.wav
Binary file not shown.
Binary file added micropolis-java/resources/sounds/monster.wav
Binary file not shown.
Binary file added micropolis-java/resources/sounds/siren.wav
Binary file not shown.
Binary file added micropolis-java/resources/sounds/sorry.wav
Binary file not shown.
Binary file added micropolis-java/resources/sounds/uhuh.wav
Binary file not shown.
Binary file not shown.
Binary file added micropolis-java/resources/stadium.png
Binary file added micropolis-java/resources/tiles.png
Binary file added micropolis-java/resources/tilessm.png
21 changes: 21 additions & 0 deletions micropolis-java/src/micropolisj/Main.java
@@ -0,0 +1,21 @@
// This file is part of MicropolisJ.
// Copyright (C) 2013 Jason Long
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
//
// MicropolisJ is free software; you can redistribute it and/or modify
// it under the terms of the GNU GPLv3, with additional terms.
// See the README file, included in this distribution, for details.

package micropolisj;

import micropolisj.gui.MainWindow;

public class Main
{
public static void main(String [] args)
{
MainWindow win = new MainWindow();
win.setVisible(true);
win.doNewCity(true);
}
}
87 changes: 87 additions & 0 deletions micropolis-java/src/micropolisj/engine/AirplaneSprite.java
@@ -0,0 +1,87 @@
// This file is part of MicropolisJ.
// Copyright (C) 2013 Jason Long
// Portions Copyright (C) 1989-2007 Electronic Arts Inc.
//
// MicropolisJ is free software; you can redistribute it and/or modify
// it under the terms of the GNU GPLv3, with additional terms.
// See the README file, included in this distribution, for details.

package micropolisj.engine;

public class AirplaneSprite extends Sprite
{
int destX;
int destY;

// Note: frames 1-8 used for regular movement
// 9-11 used for Taking off
static int [] CDx = { 0, 0, 6, 8, 6, 0, -6, -8, -6, 8, 8, 8 };
static int [] CDy = { 0, -8, -6, 0, 6, 8, 6, 0, -6, 0, 0, 0 };

public AirplaneSprite(Micropolis engine, int xpos, int ypos)
{
super(engine, SpriteKind.AIR);
this.x = xpos * 16 + 8;
this.y = ypos * 16 + 8;
this.width = 48;
this.height = 48;
this.offx = -24;
this.offy = -24;

this.destY = this.y;
if (xpos > engine.getWidth()-20) {
// not enough room to east of airport for taking off
this.destX = x - 200;
this.frame = 7;
}
else {
this.destX = x + 200;
this.frame = 11;
}
}

@Override
public void moveImpl()
{
int z = this.frame;

if (city.acycle % 5 == 0) {
if (z > 8) { //plane is still taking off
z--;
if (z < 9) { z = 3; }
this.frame = z;
}
else { // go to destination
int d = getDir(x, y, destX, destY);
z = turnTo(z, d);
this.frame = z;
}
}

if (getDis(x, y, destX, destY) < 50) { // at destination
//FIXME- original code allows destination to be off-the-map
destX = city.PRNG.nextInt(city.getWidth()) * 16 + 8;
destY = city.PRNG.nextInt(city.getHeight()) * 16 + 8;
}

if (!city.noDisasters) {
boolean explode = false;

for (Sprite s : city.allSprites()) {
if (s != this &&
(s.kind == SpriteKind.AIR || s.kind == SpriteKind.COP) &&
checkSpriteCollision(s))
{
s.explodeSprite();
explode = true;
}
}
if (explode) {
explodeSprite();
}
}

this.x += CDx[z];
this.y += CDy[z];
}
}

0 comments on commit 2b8f979

Please sign in to comment.