Demo entry 2398196

Test

   

Submitted by anonymous on Aug 18, 2015 at 20:05
Language: JavaScript. Code size: 745 Bytes.

import { foodFactory } from 'game/food-factory';
import { StructureBuilder } from 'game/structure-builder';

const town = game.town;

game.onPopulationUpdate.addListener((details) => {
	
	console.log(details); // => { type: 'add', person: Person() }
	
	if (type === 'add') {
		let person = details.person;
		
		person.name = 'Christopher';
		
		person.onHunger.addListener(() => {
			person.eatFood(foodFactory.getRandomFood());
		});
	}
});

// At the 1000th tick
game.schedule(1000, () => {
	var builder = new StructureBuilder();
	
	builder.buildHouse({ width: 100, height: 200, length: 2038 }).then((house) => {
		town.findVacantSpot(house).then((spot) => {
			spot.placeItem(house);
		});
	});
});

game.run();

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).