Games in Javascript #
A few weeks ago Google Maps got me thinking about writing simple games in Javascript. In particular, how much of The Silver Kingdoms could I implement in a browser? If I drop the terrain and make it a 2D overhead game (or possibly isometric, but that might be harder to implement), what I would need from the browser is (a) AJAX support (so the simulation can run on a server and send updates to the browser) and (b) transparent overlays for sprites. There are some nice advantages of writing in a browser. The basic graphics code is already there (image display, animation, positioning, layering) and the basic UI code is already there (mapping clicks to objects, overlapping windows, form controls). The real question is whether it's feasible—can the browser smoothly animate lots of sprites on the screen at once?
A few days later I read that someone had created a Star Wars hack on top of Google Maps. And then I saw someone had created an animated Microsoft campus invasion hack. There's now a wiki page with a list of Google Map hack game ideas.
There are only 9 sprites on the animated invasion hack, but it feels rather choppy. I'm not sure if this is a browser issue, an issue with the demo, or an issue with the Google Maps API. If it's a browser issue then it's unlikely that any nice games are going to be written on top of Google Maps. If it's a Maps issue, then a game using its own map might be feasible.
Some links I've collected while looking for ways to implement a simple game (SimCity-ish) in Javascript:
- Examples for drag and drop of objects in Javascript
- A drag and drop map, like Google Maps, but with your own maps
- A description of the canvas element in Firefox 1.1 and Safari, which could be used for drawing graphics in the browser
- A library for special effects in Javascript (including drag and drop)
I hadn't been considering using Google Maps itself, because a SimCityish game where you can't actually modify the city would be boring. I think it might be feasible to build a war or transportation game on top of Google Maps, but the game would need some notion of what the objects on the map are, and that might take some image recognition heuristics. It's unlikely I'll actually implement a real game this way, but I might try a little demo game.
Update [2005-12-16]: Take a look at this game.
Labels: design
Guild Wars Friendliness #
There's something about Guild Wars that I don't see mentioned much: it has a very friendly interface that encourages casual play.
- The CD doesn't have to be in the drive. When I'm thinking of playing, I don't need to take the previous CD out of the drive, put the Guild Wars CD in, and then start the game. I can just start the game right away. Since it's no hassle, I play a lot more.
- When I start the game, it goes right to the login prompt. No publisher splash screen. No developer splash screen. No video card maker splash screen. No sound library splash screen. No introductory movie. No copyright screen. No disclaimer screen. No menu. No loading progress bar. It's really quick and easy to get into the game. This encourages me to play more.
- While you're playing the game there are Minimize, Maximize, Close buttons at the top right corner. This lets you easily switch to another application or run the game in windowed mode or just stop playing. It acts much more like a standard application, and it's very smooth. I feel like I can play at any time, and then switch back to whatever I was doing.
All of these seem very minor but I think they add up to something big: I'm playing Guild Wars a lot (over 200 hours). I wish all games would be this way.
Guild Wars #
After playing Neverwinter Nights for a few months, I got tired of it. I played the main campaigns and enjoyed them. The problem is that the mods are much harder to deal with than they should be. It takes a lot of effort to find mods that you can play (level restrictions, number of players, good ratings, etc.). It then takes more effort than it should to download and install them. They come in ZIP, EXE, and RAR formats. They come with multiple files, each of which may have to be put into a different folder. Bioware could have made mods easier by keeping all the mod files in a single folder and by standardizing on the distribution format. For example, if the game could read ZIP files, you could just download the file and put it in a particular folder and it would be ready, without unpacking it. In any case, the main problem I had was that it was hard for me to find and try out mods, so I didn't try many, and I didn't find many that I liked.
I've been playing Guild Wars this week (22 hours so far). This is an action RPG, much like Diablo, but it also has more quests. One thing that struck me was that Diablo 2 wasn't considered an MMORPG, but Guild Wars sometimes is, and the two games aren't substantially different in that respect.
Diablo 2 lets you play offline (one player) or online (one or multiple players). Guild Wars lets you play online only. This seems like a good idea. If you know that everyone's online, you can have a much quicker update cycle (those of you who waited over a year for the 1.09 Diablo 2 patch know why this matters). So far I've had 3 small updates in 4 days. Requiring online play also means you can learn how people play and make game balance adjustments frequently.
Diablo 2, in online mode, puts you in one of many chat rooms. The main purposes of this room are to chat, to find people to play with, and to trade. There are several chat rooms (presumably to avoid overcrowding), including some specifically for trading. When joining a game, you see a list of games that are at your level (Normal/Nightmare/Hell). People generally want to find a game that's not only at their level but in the same general areas. They sometimes do this by announcing their area (“Act III - Staff quest”) in the game name, but there's no easy way to filter or sort the games to find the areas you care about. Once you join a game, you don't see everyone anymore; you only see your party. Every time you join a game, the world resets—all the monsters are back, and the layout is randomized. When you leave a game, you abandon your party.
Guild Wars feels like an MMORPG because it puts you into the game right away. You're in a city, with lots of other people around, and you can see everyone walking around, talking, getting quests, etc. But these cities are essentially chat rooms. Their main purpose is for people to chat, find people to play with, and trade. Once you join a party and go out to play the game, you don't see everyone anymore; you only see your party. Every time you go out, the world resets—all the monsters are back (but the layout is not randomzied as it was in Diablo). When teleport into a city, you abandon your party.
There are of course other differences. In Diablo, you can only get quests once you go into the game. In Guild Wars, you can get quests in the chat area (cities). Since a party may want to go into a city to get quests, the party is not broken up if you walk into a city; it's only broken up if you teleport. In Diablo, if you want to trade with someone, you find them in the chat room and then you have to create a game to trade with them. In Guild Wars, if you want to trade with someone, you can trade with them in the city where you met them; there's no need to go anywhere. Also, Guild Wars has a special trading chat channel. You can tune in to both the regular and the trading channel; you don't have to go somewhere to find the traders. Guild Wars also makes it easier to find a party or to play PvP.
Why does Guild Wars keep the Diablo-style chat vs. game area distinction? I think it's for efficiency. Chat areas handle hundreds of people; game areas handle up to four. Chat areas are easier to make efficient because you don't need strict ordering of events. If you say something and I say something at roughly the same time, it doesn't matter so much which is heard first. And it doesn't matter so much if it takes 250 ms to show up. If you attack someone and I attack someone at the same time, it matters a great deal which one occurred first, and it needs to be decided and sent to all clients much quicker than 250 ms. By segregating the chat (lots of clients, loose ordering of events, high latency) and the game (few clients, strict ordering of events, low latency), you can make both efficient. If you tried to combine the two, you open up a new hard problem: what happens when you have lots of clients and you need low latency? Trying to tackle that rare but important case makes your life as a game developer more difficult. You're spending less time on other things that may have mattered more to the players.
Another thing that Guild Wars doesn't handle is massive persistence. You can only drop items in the game areas, not the chat areas. So if you drop an item, it only has to be seen by a few other clients, and it goes away as soon as you enter a city. That way you don't need to coordinate item locations among tens of thousands of clients. You can assign each city area and each game area to a separate server. Since city and game servers keep no state, you can add more servers transparently. You don't have to require players to choose a server ahead of time and then find that they can't play with their friends, who happen to live on a different server.
So far I've been really impressed with what I can infer of the design of Guild Wars. It's fast, has great graphics, and lots of fun. It's an incredibly addictive game.
Labels: review
Product placement and games #
Product Placement is a way to get your product seen without using traditional advertising. I think product placement could be used for market research too. Imagine an online game that doesn’t offer only Coca-Cola (product placement), but offers lots of drinks. You could then correlate the choice of drinks with demographic information you have about your gamers—age, gender, income, and so on. By watching activities within the game, you could correlate the choice of drinks with MUD personality types (Killers, Achievers, Socializers, Explorers); this might tell you what kinds of magazines you want to advertise in. You could see whether people who hang out together are more likely to drink the same sorts of drinks (energy boosters, soda, water, juices, etc.). You could pay some people to switch drinks and see whether others follow. You can measure correlations between products (do people who drink Red Bull also eat hamburgers?).
Does this creep you out? It should (unless you work in marketing). Product placement is what we have now, but I think in the future we’ll have people using virtual worlds as a way to run experiments on us. In virtual worlds you can measure behavior better. There is of course the question of whether product choice and behavior in the virtual world differs from the physical world, but having detailed data about a million players can complement having sparse data about a few thousand survey participants. Given that games—unlike movies—let players choose what to do, product placement in games seems like a waste. Market research seems to me to be a much more valuable way to use that opportunity.
Labels: design
Playing characters in games #
It’s actually very interesting in The Sims how the pronouns change all the time. I’m sitting there playing the game and I’m talking about, "Oh, first I’m going to get a job, then I’m going to do this, then I’m going to do that." And then you know when the character starts disobeying me, all of a sudden I shift and say "Oh, Why won’t he do that?" or "What’s he doing now?" And so at some point it’s me kind of inhabiting this little person, and I’m thinking, "It’s me, I’m going to get a job and I’m going to do x, y, and z." But then when he starts rebelling, it’s he. And so then I kind of jump out of him, and now it’s me vs. him. You know what I’m saying?
— from Celia Pearce’s interview with Will Wright
Labels: design
Road building applet #
A few months ago I had been thinking about a UI for building roads and rails. When I got Locomotion, I found that the building UI was a little bit annoying, and that inspired me to work on my UI some more. I tried Flash but couldn't find a free and easy way to get started, so I turned to Java instead. The Java documentation on Sun’s site is nice. For example, take a look at their Java 2D documentation.
After playing with it for half a day, I have an applet that lets me build roads. One of the most confusing things was figuring out how to write <object> and <applet>. Ick. (Let me know if it doesn’t work for you.)
The basic idea is that roads (or rails) should be between edges, not tiles. Road segments are cubic splines between two edges. It’s a little tricky to select the right edge; I need to think about that problem a little bit more. There’s a larger version on my other page.
This building UI isn’t directly usable for games like Locomotion. It would need length and angle constraints, diagonals, bridges, and tunnels. To make it more usable, I need to add pathfinding, so that you can drag across the grid and it will figure out which segments need to be built. I will probably get bored before finishing all of that, though.
Web languages: Java #
Given my failure to get started writing Flash code, I decided to try Java. I downloaded Java 5.0 (which comes after 1.4, believe it or not) and Eclipse 3.0. Both of those sites need to have a much easier way to download the software. Java led me down a maze of multiple versions, marketing material, and legalese. Eclipse led me to a page of international mirrors, none of them useful (when I clicked on them, I got a big file listing and had no idea what I needed to download).
Despite some glitches (like some dialog boxes being blank and some being far wider than the screen), I got a simple applet running. My next step is to learn how to draw lines on the screen so that I can start creating a small isometric map. After that I need to learn how mouse events work so that I can let the player select tiles on the map.
The main disadvantages of Java compared to Flash are: it’s not as widespread, and it appears to be a more verbose and cumbersome language. I'd really like to do something with Java3D, but it looks like that is not installed by default on anyone’s machine. I just installed Java and I don’t have Java3D. I don’t want to ask my readers to install new software just to look at my demos. I think Java3D would be much more popular if it were installed by default.
Update: I’m not the only one who had trouble downloading Eclipse.
Labels: project
God Games: Locomotion #
I got Chris Sawyer’s Locomotion two weeks ago. I love Transport Tycoon. I have played several games in the same genre (Transport Giant, Railroad Tycoon, Roller Coaster Tycoon, etc.). Here are my thoughts after playing roughly 10 scenarios of Locomotion. I don’t just want to complain about the game. I do enjoy playing it. It’s just that there are some things that I think would make it much more enjoyable.
- Summaries. I like the summary views: lists of stations, towns, trains, trams, planes, etc. In my post about Transport Giant, I mentioned that it was really inconvenient to get any summaries. Locomotion is much better. You can sort the lists too. Minor suggestion: it would be nice if the list sort order was preserved, so you don’t have to re-sort when you re-open the list.
- Pathfinding. Unfortunately the pathfinding is really frustrating. There should be no need to add waypoints for trains. Pathfinding algorithms are efficient enough, especially on simple graph structures like railroads, that entire networks can be scanned easily. Minor suggestion: for rail networks, a simple efficiency trick would be to add “lookahead” shortcut links in the graph structure that skips ahead from one node to a node 10 spaces ahead.
- Building. Even after playing 10 games, I still find the building to be cumbersome. To edit something you right click on the road or track, but it’s hard to predict which road or track you will edit when you right click on something. Editing needs to be predictable. Locomotion has a definite advantage over Transport Tycoon in that there are many more track/road possibilities available. However, I still think drag & drop is the better approach. Suggestion: make drag & drop building work. I plan to write more on this subject soon.
- Signals. I like the way the rail signals are built. They are put on a section of track, not on a single point. The arrows on the one-way signals and roads are very nice! I am still puzzled by the various colors on the signals. I think I can figure out red-red-red, and green-red-red, but what does yellow-green-red mean? Minor suggestion: when you mouseover the signal, it can show you which trains are interacting with that signal.
- Groups. I find that I often need several vehicles that go on the same route and carry the same type of cargo. When this happens, I would like to view information about the entire group instead of seeing them one at a time, mixed in with other vehicles of the same type. Suggestion: automatically detect groups by looking for trains that share a route and cargo, and offer operations on the group: upgrade vehicles, modify the route, or change the cargo.
- Reliability. I think reliability was an important part of Transport Tycoon. Unfortunately in Locomotion reliability is a factor but you really have no control over it. Suggestion: add a “maintenance depot” that can be added to a station. When the train reaches the station that has a depot and that train needs service, it will receive service there (which takes more time). It should also be possible to add stations that are entirely for maintenance and not for cargo.
- Look-ahead Pathfinding. I like the idea of trains “looking ahead” to reserve track that they want to go on. However, it’s hard to figure out how far they look ahead. Suggestion: add a “headlight” that shows how far the train scans. (Perhaps the headlight it shown only when the vehicle is selected.)
- Bridges. I like that bridges are not limited to height 1 and that bridges can have curves and slopes. The various bridge types don’t really appeal to me though. The best ones are the ugliest. Suggestion: add a “reinforced concrete bridge” option that is very clean and flexible, supporting all the curves and slopes. Of course, if I had that, I would not use any of the other options.
- Construction Mode. While working on tracks, I frequently find that trains do not stop right away. In Transport Tycoon, you could safely work on tracks and trains would not derail. In Locomotion, they frequently crash while I am working on a track. Suggestion: when in construction mode, put construction signs/cones around the track, and make trains travel very slowly. They should not crash while in construction mode.
- Track Layouts. The track layouts in Locomotion are much nicer than in Transport Tycoon. There are lots of curves available. However, at times it is hard to see the tracks. For example, take a look at the second to last picture on this page about station layouts. It is so hard to see all the tracks that the author created a separate diagram showing them. Suggestion: when in construction mode, add a bright line showing each track segment, with large dots at the endpoints. This would be an overlay on top of the tracks so that you can see the structure.
- Visibility. Transport Tycoon offered a way to hide buildings, or at least to make them transparent. Simutrans offers a way to show only the foundations of buildings. Locomotion offers a way to hide the foreground buildings without hiding the background buildings. I like the idea, but there is a problem: when in construction mode, the foreground buildings still affect your mouse, even though you can’t see them! Suggestion: If you hide something from the eye, it should be hidden from the mouse as well. If I see something and click on it (or right click to delete/edit), the click should affect what I saw, not the hidden object in front of it.
That’s all for now. I think I have a way to make drag & drop building work with Locomotion’s more extensive set of road and rail segments. I hope to make a demo of it (and this is why I wanted to learn Flash). The basic idea is that you drag from edge to edge instead of from square to square. In addition, you use a modifier key (like shift) to raise/lower the altitude. I won’t know whether I like it until I try implementing it.
Labels: review
Web languages: Flash #
I wanted to learn Flash so that I could build some simple demos illustrating various concepts on my game programming pages. Unfortunately it looks like it costs $500 to get the flash developer kit! I should try Java instead.
Labels: project
Textures for desktop backgrounds #
I really liked the Textures Archive. It’s not just that they have a large number of textures categorized into colors. They also allow you to customize the texture by modifying its color, contrast, etc. Yes, I could do this myself using The Gimp, but it’s much easier with this web site.