Design aspects
In order to incorporate pedestrians into the game multiple aspects had to be considered:
- Roads should act as unit on which pedestrians are walking
- Existing plugins that use pedestrian road type should work with the new system as well
- Setting pedestrian flag automatically for roads would break these plugins (special "pedestrian cars" would use normal roads then)
- In any case, there has to be a way to detect whether a road is suitable for pedestrians, potentially with additonal support for different types of pedestrians which could be implemented by using road flags
Pedestrians themselves were implemented using a new plugin type called pedestrian. This plugin type basically consists of some frames that contain the people that will be drawn. These frames are special in regard to their size as people in TheoTown are supposed to have a size of 1x3 pixels. While other sizes may work, too, there is no rotational awareness for the frames. Furthermore, the pedestrian system was optimized around the idea that people have a width of exactly one pixel. Using different sizes may cause more graphical glitches.
Defining pedestrians
A new plugin type "pedestrian" was added to define pedestrians. Here's how a plugin may look like:
Code: Select all Reset
[ { "id":"$pedestrian_plugin00", "type":"pedestrian", "frames":[{"bmp": "imgage.png", "w": 1, "count": 8}] } ]
- residential
- commercial
- industrial
- level 1
- level 2
- level 3
Roads A single road tile offers four parcels which can be targeted by pedestrians.
Various attributes were added to roads to incorporate the pedestrian system and provide some control over its behavior:
Road decorations
Road decorations have the ability to set allow road crossing to true for the road they are placed on.
Spawning pedestrians
The game will spawn pedestrians automatically on roads that are suitable.
Unlike cars pedestrians don't follow a pre-calculated path. Instead they randomly change direction and eventually vanish. Also, unlike cars, only pedestrians that are currently within the viewport will be updated. This is crucial to maintain game performance while there are thousands of pedestrians.
Interaction with pedestrians
As of right now there are no functions to interact with the pedestrian system directly. Even if something like that will be added (e.g. pedestrians walking to/from stations) it would not have impact on the simulation of the city as only visible pedestrians will be updated.