View jsbin.gateloje.css
This file contains 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
body { | |
background-color: black; | |
font-family: Lucida Sans Unicode; | |
color: #ffffff; | |
} | |
div { | |
border: 1px solid black; | |
} |
View closure1.js
This file contains 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
function pai (umNumero) { | |
var metadeDoNumero = umNumero / 2 | |
function filho () { | |
console.log(umNumero) | |
console.log(metadeDoNumero) | |
} | |
filho() | |
} |
View closure2.js
This file contains 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
function pai (carro) { | |
var comida = 'pizza' | |
function filho () { | |
console.log(comida) | |
function neto () { | |
console.log(carro) | |
} |
View closure3.js
This file contains 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
function contador () { | |
var valor = 0 | |
return { | |
incrementar: function () { | |
valor += 1 | |
}, | |
getValor: function () { | |
return valor | |
} |
View closure4.js
This file contains 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
function player (forca, stamina, agilidade) { | |
var hp = stamina * 10 | |
function umaFuncaoPrivadaGrande (que, recebe, varios, parametros) { | |
// essa função é um método privado de um objeto. | |
// você pode chamar ela quando precisar ou até torná-la pública | |
} | |
return { |
View declarativeGame.js
This file contains 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
// example of what this code would produce => http://worms.io/pocDeclarative | |
const makePlayer = () => { | |
return { | |
initial: { | |
size: [50, 50], | |
position: [10, 10], | |
physics: true | |
}, |
View declarativeGame2.js
This file contains 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
// | |
// Motivations: | |
// | |
// * bring accessible functional programming to game development | |
// * handy and easy default options for quick game prototyping | |
// * flexibility for advanced game developers | |
const W = { | |
getAngle: (pointA, pointB) => null, | |
emit: (channel, message, data) => null |
View channels.js
This file contains 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
const Immutable = require('immutable') | |
const add = (channels, name) => { | |
return channels.set(name, Immutable.List()) | |
} | |
const addAction = (channels, name, action) => { | |
return channels.set(name, channels.get(name).push(action)) | |
} |
View mini-redux.js
This file contains 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
function createStore (reducers) { | |
var state = reducers() | |
const store = { | |
dispatch: (action) => { | |
state = reducers(state, action) | |
}, | |
getState: () => { | |
return state | |
} | |
} |
View index.html
This file contains 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
<html> | |
<head> | |
<meta charset="utf-8"/> | |
</head> | |
<body> | |
<div id="root"></div> | |
<script src="main.js"></script> | |
</body> | |
</html> |
OlderNewer