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 dec_to_bin(num) { | |
const bin = []; | |
while (num >= 1) { | |
bin.push(Math.floor(num%2)); | |
num = Math.abs(num/2); | |
} | |
bin.reverse(); | |
console.log(bin.join('')); |
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
//TEST IT: https://jsfiddle.net/nkt9wd28/ | |
import * as THREE from 'three'; | |
const scene = new THREE.Scene(); | |
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); | |
const renderer = new THREE.WebGLRenderer(); | |
renderer.setSize( window.innerWidth, window.innerHeight ); | |
document.body.appendChild( renderer.domElement ); |
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
startTurnBasedGame(5, 3, 4); | |
function startTurnBasedGame(num_players, num_rounds, turn_time, init_player=1, init_round=1) { | |
let [elapsed_time, player_turn, round, actual_player] = [0, 0, init_round, init_player-1]; | |
const getPlayer = () => actual_player === num_players ? num_players : actual_player % num_players; | |
const printTimeInfo = remaining_time => console.log( | |
`Next turn in: ${remaining_time}s`, `Player: ${getPlayer()}`, `Round: ${round}/${num_rounds}` | |
); |
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
FromObjectToJson = object => { | |
try { | |
if (typeof object !== "object") | |
throw "It has to be an object!"; | |
let json, cierre; | |
if (!Array.isArray(object)) { | |
json = "{"; |