Most actual game content is in cut_set() (dialogue and story events), calculate_height() & calculate_height_after() (terrain shapes), generate_objects_array() & generate_objects_array_after() (trees, houses, etc) and create_3d_meshes() (textures for the terrain, trees, houses, etc). Also, a lot of sprites for characters, and sound effect mp3's, are listed outside of functions in basic.js (for now). Races and roads are created in ascend.js with race_create().

cut and frame_counter are two numbers that control what happens in the game at any given moment: Where characters are going, what they're saying, which music plays, and so on.

the cut concept: I have one number variable (cut) that says where in the game you are. I have one number for "paused", "intro menu" and then one for every event in the game. Then one function that runs in the main loop (cut_set()) does whatever needs to be done depending on that number. If the number is divideable by 100 you're in "freeroam", if it's divideable by 50 you're in a race, and all other numbers are dialogue. Freeroam and race has same physics but race has some additional rules for the actual race, dialogue has no physics. When in dialogue, a mouseclick adds 1 to the story number, which means next dialogue.

the frame_counter concept: frame_counter starts at 0 and increases with 1 every frame. At 20 000 it wraps around. That's one whole day. This controls how bright the sun is and the rhythm of what people do and say in more detail. Divide the time number by 834 and you get the current hour. Convienient for visualizing when during the days things actually happen.

car AI: I have an accelerate factor and a max speed. Then I set a goal position that the npc tries to go towards. Then now and then i randomize a part-goal so it doesn't go straight all the time. Then if this part-goal gets too far from the straight path towards the goal I steer it back to the straight path. (I've also realized that rather than trying to simulate real human errors and inconsistencies for the npcs, I instead make the npcs 100% consistent but just a bit slower)

cars: I have an array of cars, with one place for each character, and an array that keeps track of which characters are in the current scene, so I can stop calculating AI & physics for the ones that aren't. I can use constant values to avoid having to remember the number of every character (for example "const CAR_ADELE = 0;"). And these variables control if the characters are in the current scene or not: "car_turned_on[CAR_ADELE] = 0|1".

camera: The camera has three modes: splash screen (shown at game start & in the pause menu), free roam/race (for when you drive around in the 3D terrain) & cutscene (for when you're in the "rooms"). One single function (camera_set()) handles the camera position and rotation for these three modes.

save function: Progress (cut value and position) automatically gets saved in a browser cookie and in the URL. If you want to continue the game in another browser, just copy and paste the URL into the new browser.