Skip to content

Instantly share code, notes, and snippets.

@anchetaWern
Last active May 27, 2019 05:26
Show Gist options
  • Select an option

  • Save anchetaWern/dd3ce861f3656fe1ea86d0c2949b704e to your computer and use it in GitHub Desktop.

Select an option

Save anchetaWern/dd3ce861f3656fe1ea86d0c2949b704e to your computer and use it in GitHub Desktop.
React Native Accelerometer Maze: Get entities
// App.js
_getEntities = (engine, world, maze, ball, goal) => {
const entities = {
physics: {
engine,
world
},
playerBall: {
body: ball,
bgColor: '#FF5877',
borderColor: '#FFC1C1',
renderer: Circle
},
goalBox: {
body: goal,
size: [GOAL_SIZE, GOAL_SIZE],
color: '#414448',
renderer: Rectangle
}
}
const walls = Matter.Composite.allBodies(maze);
walls.forEach((body, index) => {
const { min, max } = body.bounds;
const width = max.x - min.x;
const height = max.y - min.y;
Object.assign(entities, {
['wall_' + index]: {
body: body,
size: [width, height],
color: '#fbb050',
renderer: Rectangle
}
});
});
return entities;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment