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 perms = []; | |
function permAlone(str) { | |
var strArr = str.split(""); | |
//console.log(strArr); | |
// empty the answer array each time this function is called | |
perms = []; | |
permutator(strArr.length, strArr); | |
console.log(str + " - num perms: " + perms.length); | |
// console.log(perms.join(", ")); |
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
class MapScreen extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
showNamePrompt: false, | |
location: undefined, | |
name: undefined | |
}; | |
} |
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
componentWillMount() { | |
... | |
// periodically check device location and write the results to | |
// the location markers | |
setInterval( | |
this.performLocationChecking.bind(this), | |
1000); | |
} | |
performLocationChecking() { |
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
case 'WRITE_DISTANCE_RESULTS': | |
return locations.map((location) => { | |
if (location.ID === action.ID) { | |
let distances = [action.distance].concat(location.distances); | |
distances = distances.slice(0, action.locationArrayMaxLength); | |
let distanceAverage = distances.reduce(function (sum, value) { | |
return sum + value; | |
}, 0) / distances.length; | |
return Object.assign({}, | |
location, |
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
<Expo.MapView.Marker | |
key={this.props.key} | |
image={this.state.sprites[this.state.imageCounter % 3]} | |
coordinate={{ | |
latitude: this.props.location.loc[0], | |
longitude: this.props.location.loc[1], | |
}} | |
/> |
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
componentDidMount = () => { | |
this.animationLooper(); | |
} | |
animationLooper = () => { | |
this.setState({ | |
imageCounter: this.state.imageCounter + 1 | |
}); | |
setTimeout( | |
this.animationLooper.bind(this), |
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
const monster1 = require('../assets/sprites/monster/monster_walk01.png') | |
const monster2 = require('../assets/sprites/monster/monster_walk02.png') | |
const monster3 = require('../assets/sprites/monster/monster_walk03.png') | |
class LocationMarker extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
imageCounter: 0, |
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
componentWillReceiveProps(nextProps) { | |
if (nextProps.location.distanceAverage < 10) { | |
this.setState({ loopSpeed: 10 }); | |
} | |
else if (nextProps.location.distanceAverage < 100) { | |
this.setState({ loopSpeed: 100 }); | |
} | |
else if (nextProps.location.distanceAverage < 1000) { | |
this.setState({ loopSpeed: 500 }); | |
} |
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
componentDidMount = () => { | |
let animation = this.requestAnimationFrame(this.animationLooper.bind(this)); | |
} | |
animationLooper = () => { | |
let now = Date.now(); | |
let deltaTime = now - this.state.then; | |
// user distance = time * rate to determine the amount the marker should grow or shrink | |
let growth = deltaTime / 1000 * this.state.markerGrowthSpeed; |
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
render() { | |
return ( | |
<Expo.MapView.Marker | |
key={this.props.key} | |
coordinate={{ | |
latitude: this.props.location.loc[0], | |
longitude: this.props.location.loc[1], | |
}}> | |
<FontAwesome |
OlderNewer