3D Game Programming

(C. Jardin) #1
// This will draw what the camera sees onto the screen:
varrenderer =newTHREE.CanvasRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

// ******** START CODING ON THE NEXT LINE ********

varbest_movie = {
title:'Star Wars',
year: 1977
};

varbest_movie = {
title:'Star Wars',
year: 1977,
stars: ['Mark Hamill','Harrison Ford','Carrie Fisher'],
aboutMe:function() {
console.log(this.title +', starring: '+ this.stars);
}
};
best_movie.aboutMe();
// => Star Wars, starring: Mark Hamill,Harrison Ford,Carrie Fisher

vargreat_movie = Object.create(best_movie);
great_movie.aboutMe();
// => Star Wars, starring: Mark Hamill,Harrison Ford,Carrie Fisher

great_movie.title ='Toy Story';
great_movie.year = 1995;
great_movie.stars = ['Tom Hanks','Tim Allen'];
great_movie.aboutMe();
// => Toy Story, starring: Tom Hanks,Tim Allen

best_movie.aboutMe();
// => Star Wars, starring: Mark Hamill,Harrison Ford,Carrie Fisher

functionMovie(title, stars) {
this.title = title;
this.stars = stars;
this.year = (newDate()).getFullYear();
}
varkung_fu_movie =newMovie('Kung Fu Panda', ['Jack Black','Angelina Jolie']);
console.log(kung_fu_movie.title);
// => Kung Fu Panda
console.log(kung_fu_movie.stars);
// => ['Jack Black', 'Angelina Jolie']
console.log(kung_fu_movie.year);
// => 2013

Movie.prototype.aboutMe =function() {

Appendix 1. Project Code • 254


Prepared exclusively for Michael Powell report erratum • discuss

Free download pdf