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
HOME: '/', | |
ABOUT: '/about', | |
PICTURES: { | |
path: '/pictures', | |
thunk: (dispatch, getState) => { | |
fetch(`https://jsonplaceholder.typicode.com/photos`) | |
.then(payload => { | |
return payload.json(); | |
}) | |
.then(data => { |
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
LIST: { | |
path: '/list/:category', | |
thunk: (dispatch, getState) => { | |
const { category } = getState().location.payload | |
fetchData(`/api/videos/${category}`) | |
.then(payload => dispatch({ type: 'VIDEOS_FETCHED', payload })) | |
} | |
}, |
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
let collideUnit | |
movingUnits.forEach((unit, index) => { | |
movingUnits.forEach((compare, index) => { | |
if(unit.active | |
&& !compare.active | |
&& compare.id !== unit.id | |
&& compare.x === unit.x | |
&& compare.y === unit.y) { | |
collideUnit = compare | |
} |
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
liveUnits.forEach((unit, index) => { | |
let element = document.querySelectorAll('#unit_' + unit.id + ' .position') | |
let rect = element[0].getBoundingClientRect(); | |
let offsetTop = rect.top + document.body.scrollTop | |
let offsetLeft = rect.left + document.body.scrollLeft | |
let xx = Math.floor(offsetLeft) - Math.floor(mainX) | |
let yy = Math.floor(offsetTop) - Math.floor(mainY) | |
//https://en.wikipedia.org/wiki/Rounding#Round_half_to_even | |
let x = getBankersRounding(xx / 100) |
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
export const Map = function() { | |
this.getTiles = () => { | |
return [ | |
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
2, 0, 0, 0, 0, 0, 0, 0, 0, 2, | |
2, 1, 0, 0, 0, 2, 1, 0, 0, 2, | |
0, 0, 0, 0, 0, 0, 1, 0, 0, 2, | |
0, 0, 0, 0, 1, 1, 1, 0, 0, 2, | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 2, | |
2, 2, 0, 2, 2, 2, 0, 0, 0, 2, |
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
export let AStar = (_grid, start, end, units, currentSelectionID) => { | |
// Reset score of cells | |
_grid.resetCells() | |
// pass tanks to grid and make them obstacles | |
_grid.makeObstaclesOfUnitsWithHigherMass(units[currentSelectionID], units, currentSelectionID) | |
// Add possible cell neighbors, pass unit A* style | |
let aStarStyle = units[currentSelectionID].aStarStyle | |
_grid.addCellNeighbors(aStarStyle) | |
let openSet = [] | |
let closedSet = [] |
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
import { Cell } from './Cell' | |
import { Map } from './maps/Map' | |
// Grid singleton | |
export const Dimensions = () => ({ | |
width: 1000, | |
height: 2000, | |
tileSize: 100 | |
}) |
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
<BasePosition moveSpeed={tankUnit.moveSpeed} position={this.coordinates(position, cellWidth, cellHeight)} > | |
<Body specs={tankUnit} speed={this.getSpeed(position)} rotate={shouldRotate} rotation={angle}> | |
<Tracks specs={tankUnit}/> | |
</Body> | |
<Cannon debugAim={this.props.aimMode} | |
specs={tankUnit} rotate={shouldRotate} | |
rotation={angle} | |
shooting={this.getIsThisUnitShooting(tankUnit, index)}/> | |
<HP specs={tankUnit} /> | |
</BasePosition> |