434 points · by huskyr · 12y ago · 81 comments
Simulation code here:
http://lo-th.github.io/3d.city/build/city.3d.js
Background worker (neat idea) that handles all user input and costly events, to keep the 3D animations consistently fast:
The simulation is from my own micropolisJS (http://micropolisjs.graememcc.co.uk and https://github.com/graememcc/micropolisJS) just stripped of the GPL License headers and attribution.
micropolisJS in turn is a port of Micropolis, the open-source release of Sim City 1989 for One Laptop Per Child.
Edit: edited the link. You'd think I should get links to my own site correct!
There are small details like laying out roads and making power lines go over them etc that are super-fiddly too.
I know this because I played around with my own simcity for a while, first in true 3D (making curvy roads look nice is damn difficult) and then a 2D grid.
Here's a screenshot I was particularly proud of - the effort to get to that point was more than it looks! http://media.tumblr.com/c9b51ca1eb2b3e89eb8d5af0f560ec34/tum...
More on my algos http://williamedwardscoder.tumblr.com/post/49797579721/willc...
I was going to procedurally produce the buildings using a variation on Eisenscript https://sites.google.com/site/williamedwardscoder/home/exten... with variables in the script based on things like price, distance to other zones, scores etc
I look at the files you link and think "yeah!". I put my city simulation into a Web Worker and the UI in the browser thread though.
After 10 minutes I hit a bug where adding more zones seemed to place an 'invisible' zone. Which deleted the trees that were there and could be connected to electricity but didn't draw anything on the ground and would never populate. Or at least I couldn't see if it was populated and I couldn't play anymore.
including other crazy stuff like this: http://3dflashlo.wordpress.com/2014/02/17/png-to-script/
The game, day/night, seasons, I would buy this. It might need to be converted to Java to lower CPU usage but even as JavaScript it actually uses less than I'd have thought.
Very nice work.
On "use strict" I can't believe all the stuff JavaScript allows when it's not used, so I'm glad it exists: http://www.w3schools.com/js/js_strict.asp
The only thing that seemed off for me was the "Drag", which I think somebody else mentioned. I found myself clicking and re-clicking it multiple times to pan around the map, which got old after a bit. That was in latest Chrome on Mac OSX.
Great work however!
At this point, my browser has ground to a halt, my retina macbook is running very hot, and the little green rectangle does not follow the cursor anymore to aim where i'm going to plant the next building: https://dl.dropboxusercontent.com/u/14314213/Screen%20Shot%2...
cheers!
(Found it http://www.darkroastedblend.com/2012/03/retro-future-gloriou... here and used it as a desktop wallpaper for ages!)
On my MacBook Air runs smooth on both Chrome and Firefox. Same on Windows 8.1. Unfortunately, I can't test it on Ubuntu because I don't have a GUI installation of Ubuntu (I use the server version).
what does about://gpu say in Chrome? There are bugs in the latest version of Chrome for Ubuntu in both the Intel and nVidia drivers.
Is WebGL evere going to really work?
The gameplay feels nice, and it reminds me of Caesar II, if that game is familiar to anyone. That being said, I think the game would benefit from introducing a few objectives.
About Caesar II/III, it was a nice city building game. But the 3DCity game is very similar to another game called SimCity/SimCity2000. Some mentioned in this thread that it even uses the open source code of the original SimCity 1 for its city simulation code.
A few observations about it: The drag view was buggy so I had to re-click it over and over again. It also crashed on me a a couple of times. Also placing objects was hard to do and it took me awhile to figure out how to drag the screen.
Exception { message: "", result: 2147746065, name: "NS_ERROR_NOT_AVAILABLE", filename: "resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/john/.mozilla/firefox/ifg18hmm.default/extensions/551f2920-3c19-11e1-b86c-0800200c9a66@jetpack.xpi!/bootstrap.js -> resource://gre/modules/commonjs/toolkit/loader.js -> resource://firefox-at-ghostery-dot-com/ghostery/lib/ui/desktop/button.js", lineNumber: 60, columnNumber: 0, inner: null, data: null, stack: "create@resource://gre/modules/addons/XPIProvider.jsm -> jar:file:///home/john/.mozilla/firefox/ifg18hmm.default/extensions/551f2920-3c19-11e1-b86c-0800200c9a66@jetpack.xpi!/bootstrap.js -> resource://gre/modules/commonjs/toolkit/loader.js -> resource://firefox-at-ghostery-dot-com/ghostery/lib/ui/desktop/button.js:60:11
Reported to Ghostery support.