The Road to Alpha, Week 2 - Camera, Action!
Discussion on /r/CityboundSupport Citybound on
Real life still hasn't fully adapted to the fact that I'm doing Citybound now, but I got some small visible things and some bigger invisble things done.
What I did:
Keyboard camera controls
- WASD = move
- Q & E = rotate left/right
- R & F = zoom in/out
- I tried to make the movements as smooth and responsive as possible
- Using one hand for camera, one on the mouse for manipulation (FPS style) feels great.
Cursor snaps to existing roads
Existing roads are automatically split
- So far, this only works up to one road, dragging across multiple roads is planned.
- Parallel, 45 degree and 90 degree guidelines relative to existing roads are also planned.
Code cleanup. Messy prototype slowly becomes modular game/engine with clean interfaces.
Implemented a system for handling and rendering large mostly-static geometries.
- useful where many small geometries cause too many drawcalls (even worse in JS!) and one huge, merged geometry is too expensive to update.
- works by grouping sub-geometries on a grid and only merging geometries in the same grid cell.
- this means you only need to update one grid cell to make changes and you only have as many drawcalls as grid cells. You can even do occlusion culling on grid-cells and avoid having to always draw everything like you would for one huge merged geometry.
- the first use-case is the road geometry. As you can see in the gif, arbitrary portions of a huge road network (~2500 roads) can be updated in realtime.
- the system will also be used for buildings and vegetation. Drawing lots of similar things seems to be a reoccuring problem in a city sim.
Thought of a simple conceptual "Needs & Resources" framework for the core game mechanics.
- You can model almost everything in a city as an entity that has needs and/or can produce resources. Some examples:
- Citizen: Needs food, generic goods, generic services, education. Produces workforce.
- Farmer: like Citizen, but self-sufficient with food, works for himself. Sells abundant food.
- Market/Vendor: Needs workforce & food or goods. Distributes and sells them with a margin.
- Service business: Needs workforce. Produces generic service out of thin air.
- Workshop/Industry: Needs workforce & maybe raw materials. Produces generic goods.
- School: Needs workforce. Produces education. Has a minimum required pre-education (to model different stages of schools).
- Neighboring cities / "The Region": can offer all kinds of resources and can have all kinds of needs. This allows you to bootstrap your city in the first place and maybe specialize it later.
- The player's job is to be aware of these needs and resources, zone accordingly and create an infrastructure that allows for efficient transport/acquiral of needed resources for everyone.
- The only thing that doesn't really fit this model is emergency services like police, ambulance and firestation. They will get their own event-based model.
What I'll probably do next:
- Make building generation fully dynamic (at the moment it can only be triggered once)
- Ability to remove roads
- Zoning UI
- Implement basic Needs & Resources system
Be excited for more next week!