Last active
May 27, 2019 05:26
-
-
Save anchetaWern/dd3ce861f3656fe1ea86d0c2949b704e to your computer and use it in GitHub Desktop.
React Native Accelerometer Maze: Get entities
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
| // 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