Created
July 16, 2013 21:43
-
-
Save femontanha/6015424 to your computer and use it in GitHub Desktop.
The first commented line is your dabblet’s title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The first commented line is your dabblet’s title | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- content to be placed inside <body>…</body> --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var myObj = function( name, lastName ) { | |
this.name = name; | |
this.lastName = lastName; | |
return this; | |
}; | |
myObj.prototype.getName = function() { | |
return this.name; | |
}; | |
myObj.prototype.getLastName = function() { | |
return this.lastName; | |
}; | |
myObj.prototype.getFullName = function() { | |
return this.name + ' ' + this.lastName; | |
}; | |
//console.log( myObj() === window ); | |
//console.log( typeof myObj ); | |
//console.log( myObj.length ); | |
//console.log( myObj instanceof Function ); | |
//console.log( myObj === Function); | |
//console.log( myObj.__proto__ === Function.prototype); | |
var myInst = new myObj( 'fellipe', 'azambuja' ); | |
//console.log( myInst.getName() ); | |
//console.log( myInst.getLastName() ); | |
//console.log( myInst.getFullName() ); | |
//console.log( myObj.prototype ); | |
// define the game object constructor | |
var GameObject = function( width, height ) { | |
this.x = Math.floor( (Math.random() * myCanvasWidth) + 1 ); | |
this.y = Math.floor( (Math.random() * myCanvasHeight) + 1 ); | |
this.width = width; | |
this.height = height; | |
return this; | |
}; | |
// (re)define the game prototype object | |
GameObject.prototype = { | |
x: 0, | |
y: 0, | |
width: 5, | |
height: 5, | |
draw = function() { | |
myCanvasContext.fillRect(this.x, this.y, this.width. this.height) | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"separate","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment